Repository: ignite Updated Branches: refs/heads/master 1463311cd -> 88429f2ec
IGNITE-1626 : .NET: Added NuGet support. This closes #342. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/88429f2e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/88429f2e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/88429f2e Branch: refs/heads/master Commit: 88429f2ecd82b4d9b92521dc9422ff5cc445dcdf Parents: 1463311 Author: Pavel Tupitsyn <[email protected]> Authored: Fri Feb 19 16:54:29 2016 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Fri Feb 19 16:54:29 2016 +0300 ---------------------------------------------------------------------- .gitignore | 1 + .../Apache.Ignite.Core.Tests.NuGet.csproj | 103 ++++++++++++++++++ .../Apache.Ignite.Core.Tests.NuGet.sln | 26 +++++ ...ache.Ignite.Core.Tests.NuGet.sln.DotSettings | 4 + .../Apache.Ignite.Core.Tests.NuGet/CacheTest.cs | 107 +++++++++++++++++++ .../ComputeTest.cs | 84 +++++++++++++++ .../Config/ignite-config.xml | 50 +++++++++ .../Apache.Ignite.Core.Tests.NuGet/NuGet.config | 34 ++++++ .../Properties/AssemblyInfo.cs | 35 ++++++ .../StartupTest.cs | 66 ++++++++++++ .../TestRunner.cs | 70 ++++++++++++ .../Apache.Ignite.Core.Tests.NuGet/TestUtil.cs | 43 ++++++++ .../install-package.cmd | 3 + .../Apache.Ignite.Core.csproj | 4 + .../Apache.Ignite.Core.nuspec | 80 ++++++++++++++ .../Impl/Common/IgniteHome.cs | 11 +- .../dotnet/Apache.Ignite.Core/NuGet/Install.ps1 | 44 ++++++++ .../NuGet/LINQPad/ComputeExample.linq | 106 ++++++++++++++++++ .../NuGet/LINQPad/PutGetExample.linq | 69 ++++++++++++ .../NuGet/LINQPad/QueryExample.linq | 96 +++++++++++++++++ .../Apache.Ignite.Core/NuGet/PostBuild.ps1 | 20 ++++ .../Apache.Ignite.Core/NuGet/Uninstall.ps1 | 21 ++++ parent/pom.xml | 2 + 23 files changed, 1075 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 4073a58..5268e18 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ git-patch-prop-local.sh **/cpp/**/vs/x64/ **/cpp/**/vs/Win32/ **/dotnet/**/obj/ +**/dotnet/**/bin/ /modules/platforms/cpp/doc/ .settings .classpath http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.csproj new file mode 100644 index 0000000..4283de4 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.csproj @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">x64</Platform> + <ProjectGuid>{134707F6-155D-47F6-9EB2-C67ABBF3C009}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Apache.Ignite.Core.Tests.NuGet</RootNamespace> + <AssemblyName>Apache.Ignite.Core.Tests.NuGet</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x64\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + <OutputPath>bin\x64\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup> + <StartupObject>Apache.Ignite.Core.Tests.NuGet.TestRunner</StartupObject> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> + <OutputPath>bin\x86\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <ItemGroup> + <Reference Include="Apache.Ignite.Core"> + <SpecificVersion>False</SpecificVersion> + <HintPath>pkg\lib\net40\Apache.Ignite.Core.dll</HintPath> + </Reference> + <Reference Include="nunit-console-runner"> + <HintPath>..\libs\nunit-console-runner.dll</HintPath> + </Reference> + <Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\libs\nunit.framework.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + </ItemGroup> + <ItemGroup> + <Compile Include="ComputeTest.cs" /> + <Compile Include="StartupTest.cs" /> + <Compile Include="CacheTest.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="TestRunner.cs" /> + <Compile Include="TestUtil.cs" /> + </ItemGroup> + <ItemGroup> + <Content Include="Config\ignite-config.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + </ItemGroup> + <ItemGroup> + <None Include="Apache.Ignite.Core.Tests.NuGet.sln.DotSettings" /> + <None Include="install-package.cmd" /> + <None Include="NuGet.config" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <PropertyGroup> + <PostBuildEvent>if not exist $(TargetDir)Libs md $(TargetDir)Libs +xcopy /s /y $(ProjectDir)pkg\Libs $(TargetDir)Libs</PostBuildEvent> + </PropertyGroup> + <PropertyGroup> + <PreBuildEvent>cd $(ProjectDir) +if not exist pkg install-package.cmd</PreBuildEvent> + </PropertyGroup> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.sln ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.sln b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.sln new file mode 100644 index 0000000..1c79873 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests.NuGet", "Apache.Ignite.Core.Tests.NuGet.csproj", "{134707F6-155D-47F6-9EB2-C67ABBF3C009}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {134707F6-155D-47F6-9EB2-C67ABBF3C009}.Debug|x64.ActiveCfg = Debug|x64 + {134707F6-155D-47F6-9EB2-C67ABBF3C009}.Debug|x64.Build.0 = Debug|x64 + {134707F6-155D-47F6-9EB2-C67ABBF3C009}.Debug|x86.ActiveCfg = Debug|x64 + {134707F6-155D-47F6-9EB2-C67ABBF3C009}.Debug|x86.Build.0 = Debug|x64 + {134707F6-155D-47F6-9EB2-C67ABBF3C009}.Release|x64.ActiveCfg = Release|x64 + {134707F6-155D-47F6-9EB2-C67ABBF3C009}.Release|x64.Build.0 = Release|x64 + {134707F6-155D-47F6-9EB2-C67ABBF3C009}.Release|x86.ActiveCfg = Release|x86 + {134707F6-155D-47F6-9EB2-C67ABBF3C009}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.sln.DotSettings ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.sln.DotSettings b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.sln.DotSettings new file mode 100644 index 0000000..187a909 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Apache.Ignite.Core.Tests.NuGet.sln.DotSettings @@ -0,0 +1,4 @@ +<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> + <s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AddImportsToDeepestScope/@EntryValue">True</s:Boolean> + + <s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">True</s:Boolean></wpf:ResourceDictionary> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/CacheTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/CacheTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/CacheTest.cs new file mode 100644 index 0000000..ba0487b --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/CacheTest.cs @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ReSharper disable UnusedAutoPropertyAccessor.Local +namespace Apache.Ignite.Core.Tests.NuGet +{ + using System.Linq; + using Apache.Ignite.Core.Binary; + using Apache.Ignite.Core.Cache.Configuration; + using Apache.Ignite.Core.Cache.Query; + using NUnit.Framework; + + /// <summary> + /// Cache test. + /// </summary> + public class CacheTest + { + /// <summary> + /// Fixture set up. + /// </summary> + [TestFixtureSetUp] + public void FixtureSetUp() + { + var cfg = new IgniteConfiguration + { + DiscoverySpi = TestUtil.GetLocalDiscoverySpi(), + BinaryConfiguration = new BinaryConfiguration(typeof(Person)) + }; + + Ignition.Start(cfg); + } + + /// <summary> + /// Fixture tear down. + /// </summary> + [TestFixtureTearDown] + public void FixtureTearDown() + { + Ignition.StopAll(true); + } + + /// <summary> + /// Tests cache put/get. + /// </summary> + [Test] + public void TestPutGet() + { + var ignite = Ignition.GetIgnite(); + + var cache = ignite.CreateCache<int, int>("cache"); + + cache[1] = 5; + + Assert.AreEqual(5, cache[1]); + } + + /// <summary> + /// Tests the SQL. + /// </summary> + [Test] + public void TestSql() + { + var ignite = Ignition.GetIgnite(); + + var cache = ignite.GetOrCreateCache<int, Person>(new CacheConfiguration("sqlCache", typeof (Person))); + + cache.PutAll(Enumerable.Range(1, 100).ToDictionary(x => x, x => new Person {Name = "Name" + x, Age = x})); + + var sqlRes = cache.Query(new SqlQuery(typeof (Person), "age < ?", 30)).GetAll(); + + Assert.AreEqual(29, sqlRes.Count); + Assert.IsTrue(sqlRes.All(x => x.Value.Age < 30)); + } + + /// <summary> + /// Query class. + /// </summary> + private class Person + { + /// <summary> + /// Gets or sets the name. + /// </summary> + [QuerySqlField] + public string Name { get; set; } + + /// <summary> + /// Gets or sets the age. + /// </summary> + [QuerySqlField] + public int Age { get; set; } + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/ComputeTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/ComputeTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/ComputeTest.cs new file mode 100644 index 0000000..53764f7 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/ComputeTest.cs @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ReSharper disable UnusedAutoPropertyAccessor.Local +namespace Apache.Ignite.Core.Tests.NuGet +{ + using System; + using Apache.Ignite.Core.Compute; + using NUnit.Framework; + + /// <summary> + /// Compute test. + /// </summary> + public class ComputeTest + { + /// <summary> + /// Fixture set up. + /// </summary> + [TestFixtureSetUp] + public void FixtureSetUp() + { + Ignition.Start(new IgniteConfiguration + { + DiscoverySpi = TestUtil.GetLocalDiscoverySpi(), + }); + } + + /// <summary> + /// Fixture tear down. + /// </summary> + [TestFixtureTearDown] + public void FixtureTearDown() + { + Ignition.StopAll(true); + } + + /// <summary> + /// Tests cache put/get. + /// </summary> + [Test] + public void TestCompute() + { + var ignite = Ignition.GetIgnite(); + + var compute = ignite.GetCompute(); + + ComputeAction.RunCount = 0; + + compute.Broadcast(new ComputeAction()); + + Assert.AreEqual(1, ComputeAction.RunCount); + } + + /// <summary> + /// Test action. + /// </summary> + [Serializable] + private class ComputeAction : IComputeAction + { + /// <summary> The run count. </summary> + public static volatile int RunCount; + + /** <inheritdoc /> */ + public void Invoke() + { + RunCount++; + } + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Config/ignite-config.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Config/ignite-config.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Config/ignite-config.xml new file mode 100644 index 0000000..3f8f5f9 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Config/ignite-config.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + <bean class="org.apache.ignite.configuration.IgniteConfiguration"> + <property name="localHost" value="127.0.0.1" /> + + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> + <property name="addresses"> + <list> + <value>127.0.0.1:47500..47502</value> + </list> + </property> + </bean> + </property> + </bean> + </property> + + <property name="cacheConfiguration"> + <list> + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="testcache"/> + <property name="startSize" value="10"/> + </bean> + </list> + </property> + </bean> +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/NuGet.config ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/NuGet.config b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/NuGet.config new file mode 100644 index 0000000..5099ff0 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/NuGet.config @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<configuration> + <packageRestore> + <!-- Allow NuGet to download missing packages --> + <add key="enabled" value="True" /> + <!-- Automatically check for missing packages during build in Visual Studio --> + <add key="automatic" value="True" /> + </packageRestore> + <packageSources> + <add key="ParentFolder" value="..\" /> + </packageSources> + <!-- Used to specify which one of the sources are active --> + <activePackageSource> + <add key="ParentFolder" value="..\" /> + </activePackageSource> +</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b270b5e --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Apache.Ignite.Core.Tests.NuGet")] +[assembly: AssemblyDescription("Apache Ignite.NET NuGet tests")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Apache Software Foundation")] +[assembly: AssemblyProduct("Apache Ignite.NET")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] +[assembly: Guid("134707f6-155d-47f6-9eb2-c67abbf3c009")] + +[assembly: AssemblyVersion("1.6.0.8653")] +[assembly: AssemblyFileVersion("1.6.0.8653")] +[assembly: AssemblyInformationalVersion("1.6.0")] http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/StartupTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/StartupTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/StartupTest.cs new file mode 100644 index 0000000..5b38bde --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/StartupTest.cs @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests.NuGet +{ + using Apache.Ignite.Core.Cache.Configuration; + using NUnit.Framework; + + /// <summary> + /// Cache test. + /// </summary> + public class StartupTest + { + /// <summary> + /// Tests code configuration. + /// </summary> + [Test] + public void TestCodeConfig() + { + var cfg = new IgniteConfiguration + { + DiscoverySpi = TestUtil.GetLocalDiscoverySpi(), + CacheConfiguration = new[] {new CacheConfiguration("testcache")} + }; + + using (var ignite = Ignition.Start(cfg)) + { + var cache = ignite.GetCache<int, int>("testcache"); + + cache[1] = 5; + + Assert.AreEqual(5, cache[1]); + } + } + + /// <summary> + /// Tests code configuration. + /// </summary> + [Test] + public void TestSpringConfig() + { + using (var ignite = Ignition.Start("config\\ignite-config.xml")) + { + var cache = ignite.GetCache<int, int>("testcache"); + + cache[1] = 5; + + Assert.AreEqual(5, cache[1]); + } + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestRunner.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestRunner.cs new file mode 100644 index 0000000..c5abcb7 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestRunner.cs @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests.NuGet +{ + using System; + using System.Diagnostics; + using System.Reflection; + using NUnit.ConsoleRunner; + + /// <summary> + /// Console test runner + /// </summary> + public static class TestRunner + { + [STAThread] + static void Main() + { + Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); + Debug.AutoFlush = true; + + TestAllInAssembly(); + } + + private static void TestOne(Type testClass, string method) + { + string[] args = { "/run:" + testClass.FullName + "." + method, Assembly.GetAssembly(testClass).Location }; + + int returnCode = Runner.Main(args); + + if (returnCode != 0) + Console.Beep(); + } + + private static void TestAll(Type testClass) + { + string[] args = { "/run:" + testClass.FullName, Assembly.GetAssembly(testClass).Location }; + + int returnCode = Runner.Main(args); + + if (returnCode != 0) + Console.Beep(); + } + + private static void TestAllInAssembly() + { + string[] args = { Assembly.GetAssembly(typeof(CacheTest)).Location }; + + int returnCode = Runner.Main(args); + + if (returnCode != 0) + Console.Beep(); + } + + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestUtil.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestUtil.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestUtil.cs new file mode 100644 index 0000000..43e5097 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/TestUtil.cs @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Apache.Ignite.Core.Tests.NuGet +{ + using Apache.Ignite.Core.Discovery; + using Apache.Ignite.Core.Discovery.Tcp; + using Apache.Ignite.Core.Discovery.Tcp.Static; + + /// <summary> + /// Test utils. + /// </summary> + public static class TestUtil + { + /// <summary> + /// Gets the local discovery spi. + /// </summary> + public static IDiscoverySpi GetLocalDiscoverySpi() + { + return new TcpDiscoverySpi + { + IpFinder = new TcpDiscoveryStaticIpFinder + { + Endpoints = new[] {"127.0.0.1:47500..47503"} + } + }; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/install-package.cmd ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/install-package.cmd b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/install-package.cmd new file mode 100644 index 0000000..e1b57a8 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/install-package.cmd @@ -0,0 +1,3 @@ +rmdir pkg /S /Q +nuget install Apache.Ignite.NET +move Apache.Ignite.NET* pkg \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj index 661040b..1b66f0c 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj @@ -441,6 +441,10 @@ </ItemGroup> <ItemGroup> <None Include="Apache.Ignite.Core.ruleset" /> + <None Include="Apache.Ignite.Core.nuspec" /> + <None Include="NuGet\Uninstall.ps1" /> + <None Include="NuGet\PostBuild.ps1" /> + <None Include="NuGet\Install.ps1" /> <None Include="Apache.Ignite.Core.snk" /> <None Include="IgniteConfigurationSection.xsd"> <SubType>Designer</SubType> http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec new file mode 100644 index 0000000..54a4a9e --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec @@ -0,0 +1,80 @@ +<?xml version="1.0"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- + +Creating NuGet package: +1) Build Java: mvn clean package -DskipTests -U -Plgpl +2) Build Apache.Ignite.sln (x64 configuration) +3) Create package (use csproj instead of nuspec so that template substitution works): + nuget pack Apache.Ignite.Core.csproj -Prop Configuration=Release -Prop Platform=x64 + +--> + +<package > + <metadata> + <id>Apache.Ignite.NET</id> + <title>Apache Ignite.NET x64</title> + <!-- --> + <version>$version$</version> + <authors>Apache Ignite</authors> + <owners>Apache Software Foundation</owners> + <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl> + <projectUrl>https://ignite.apache.org/</projectUrl> + <iconUrl>https://ignite.apache.org/images/logo_ignite_32_32.png</iconUrl> + <requireLicenseAcceptance>false</requireLicenseAcceptance> + <description> +Apache Ignite.NET In-Memory Data Fabric is a high-performance, integrated and distributed in-memory platform for computing and transacting on large-scale data sets in real-time, orders of magnitude faster than possible with traditional disk-based or flash technologies. + +More info: https://apacheignite-net.readme.io/ + +WARNING: this only works with x64 build targets. + </description> + <summary> + High-performance in-memory platform for computing and transacting on large-scale data sets in real-time. + </summary> + <releaseNotes></releaseNotes> + <copyright>Copyright 2015</copyright> + <tags>Apache Ignite In-Memory Distributed Computing SQL NoSQL Grid Map Reduce Cache linqpad-samples</tags> + </metadata> + <files> + <!-- Dll will be included automatically in the lib folder. --> + <!--<file src="bin\x64\Release\*.dll" target="lib\net40" />--> + + <!-- Install script should be in tools --> + <file src="NuGet\Install.ps1" target="tools" /> + <file src="NuGet\Uninstall.ps1" target="tools" /> + <file src="NuGet\PostBuild.ps1" target="tools" /> + + <!-- Other files should go to Content folder to be automatically included in project. --> + <!--<file src="..\..\..\..\config\default-config.xml" target="Content\Config" />--> + + <!-- + Library files (jars) should not be included in project, so that NuGet package restore works properly. + We keep jars in NuGet dir and copy them over in PostBuild event. + --> + <file src="..\..\..\..\target\release-package\libs\*.jar" target="Libs" /> + <file src="..\..\..\..\target\release-package\libs\ignite-spring\*.jar" target="Libs" /> + <file src="..\..\..\..\target\release-package\libs\ignite-indexing\*.jar" target="Libs" /> + <file src="..\..\..\..\target\release-package\libs\licenses\*.*" target="Licenses" /> + + <!-- LINQPad samples --> + <file src="NuGet\LINQPad\*.*" target="linqpad-samples" /> + </files> +</package> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs index 335c55a..ebf5e0f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteHome.cs @@ -78,7 +78,7 @@ namespace Apache.Ignite.Core.Impl.Common } } - return null; + throw new IgniteException("Failed to resolve Ignite home."); } /// <summary> @@ -89,9 +89,12 @@ namespace Apache.Ignite.Core.Impl.Common private static bool IsIgniteHome(DirectoryInfo dir) { return dir.Exists && - dir.EnumerateDirectories().Count(x => x.Name == "examples" || x.Name == "bin") == 2 && - (dir.EnumerateDirectories().Count(x => x.Name == "modules") == 1 || - dir.EnumerateDirectories().Count(x => x.Name == "platforms") == 1); + (dir.EnumerateDirectories().Count(x => x.Name == "examples" || x.Name == "bin") == 2 && + dir.EnumerateDirectories().Count(x => x.Name == "modules" || x.Name == "platforms") == 1) + || // NuGet home + (dir.EnumerateDirectories().Any(x => x.Name == "Libs") && + (dir.EnumerateFiles("Apache.Ignite.Core.dll").Any() || + dir.EnumerateFiles("Apache.Ignite.*.nupkg").Any())); } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/Install.ps1 ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/Install.ps1 b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/Install.ps1 new file mode 100644 index 0000000..c1c591b --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/Install.ps1 @@ -0,0 +1,44 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +param($installPath, $toolsPath, $package, $project) + +Write-Host "Updating project properties..." + +Function SetProperties +{ + param ($projItem) + + Write-Host $projItem.Name + + $projItem.Properties.Item("CopyToOutputDirectory").Value = 2 # copy if newer +} + +# Copy default config to output dir for user conveniece +SetProperties $project.ProjectItems.Item("Config").ProjectItems.Item("default-config.xml") + +# ForEach ($item in $project.ProjectItems.Item("Libs").ProjectItems) +# { +# SetProperties $item +# } + +. (Join-Path $toolsPath "PostBuild.ps1") + +# Get the current Post Build Event cmd +$currentPostBuildCmd = $project.Properties.Item("PostBuildEvent").Value + +# Append our post build command if it's not already there +if (!$currentPostBuildCmd.Contains($IgnitePostBuildCmd)) { + $project.Properties.Item("PostBuildEvent").Value += $IgnitePostBuildCmd +} + +Write-Host "Welcome to Apache Ignite.NET!" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/ComputeExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/ComputeExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/ComputeExample.linq new file mode 100644 index 0000000..194858c --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/ComputeExample.linq @@ -0,0 +1,106 @@ +<Query Kind="Program"> + <NuGetReference>Apache.Ignite.NET</NuGetReference> + <Namespace>Apache.Ignite.Core</Namespace> + <Namespace>Apache.Ignite.Core.Binary</Namespace> + <Namespace>Apache.Ignite.Core.Cache.Configuration</Namespace> + <Namespace>Apache.Ignite.Core.Cache.Query</Namespace> + <Namespace>Apache.Ignite.Core.Compute</Namespace> +</Query> + +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/// <summary> +/// Example demonstrating closure execution. +/// </summary> + +void Main() +{ + if (!Environment.Is64BitProcess) + throw new Exception("x64 LINQPad is required to run this sample (see AnyCPU build: http://www.linqpad.net/Download.aspx)"); + + // Force new LINQPad query process to reinit JVM + Util.NewProcess = true; + + // Start instance + using (var ignite = Ignition.Start()) + { + // Split the string by spaces to count letters in each word in parallel. + var words = "Count characters using closure".Split(); + + var res = ignite.GetCompute().Apply(new CharacterCountClosure(), words); + + int totalLen = res.Sum(); // reduce manually + + totalLen.Dump("Total character count with manual reduce"); + + totalLen = ignite.GetCompute().Apply(new CharacterCountClosure(), words, new CharacterCountReducer()); + + totalLen.Dump("Total character count with reducer"); + } +} + +/// <summary> +/// Closure counting characters in a string. +/// </summary> +[Serializable] +public class CharacterCountClosure : IComputeFunc<string, int> +{ + /// <summary> + /// Calculate character count of the given word. + /// </summary> + /// <param name="arg">Word.</param> + /// <returns>Character count.</returns> + public int Invoke(string arg) + { + int len = arg.Length; + + Console.WriteLine("Character count in word \"" + arg + "\": " + len); + + return len; + } +} + +/// <summary> +/// Character count reducer which collects individual string lengths and aggregate them. +/// </summary> +public class CharacterCountReducer : IComputeReducer<int, int> +{ + /// <summary> Total length. </summary> + private int _length; + + /// <summary> + /// Collect character counts of distinct words. + /// </summary> + /// <param name="res">Character count of a distinct word.</param> + /// <returns><c>True</c> to continue collecting results until all closures are finished.</returns> + public bool Collect(int res) + { + _length += res; + + return true; + } + + /// <summary> + /// Reduce all collected results. + /// </summary> + /// <returns>Total character count.</returns> + public int Reduce() + { + return _length; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/PutGetExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/PutGetExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/PutGetExample.linq new file mode 100644 index 0000000..0569da6 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/PutGetExample.linq @@ -0,0 +1,69 @@ +<Query Kind="Program"> + <NuGetReference>Apache.Ignite.NET</NuGetReference> + <Namespace>Apache.Ignite.Core</Namespace> + <Namespace>Apache.Ignite.Core.Binary</Namespace> +</Query> +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/// <summary> +/// This example demonstrates put-get operations on Ignite cache +/// with binary values. Note that binary object can be retrieved in +/// fully-deserialized form or in binary object format using special +/// cache projection. +/// </summary> + +void Main() +{ + if (!Environment.Is64BitProcess) + throw new Exception("x64 LINQPad is required to run this sample (see AnyCPU build: http://www.linqpad.net/Download.aspx)"); + + // Force new LINQPad query process to reinit JVM + Util.NewProcess = true; + + // Configure cacheable types + var cfg = new IgniteConfiguration {BinaryConfiguration = new BinaryConfiguration(typeof(Organization))}; + + // Start instance + using (var ignite = Ignition.Start(cfg)) + { + // Create new cache + var cache = ignite.CreateCache<int, Organization>("orgs"); + + // Put data entry to cache + cache.Put(1, new Organization {Name = "Apache", Type="Private"}); + + // Retrieve data entry in fully deserialized form + cache.Get(1).Dump("Retrieved organization instance from cache"); + + // Create projection that will get values as binary objects + var binaryCache = cache.WithKeepBinary<int, IBinaryObject>(); + + // Get recently created organization as a binary object + var binaryOrg = binaryCache.Get(1); + + // Get organization's name from binary object (note that object doesn't need to be fully deserialized) + binaryOrg.GetField<string>("name").Dump("Retrieved organization name from binary object"); + } +} + +public class Organization +{ + public string Name { get; set; } + + public string Type { get; set; } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq new file mode 100644 index 0000000..b13e1e9 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq @@ -0,0 +1,96 @@ +<Query Kind="Program"> + <NuGetReference>Apache.Ignite.NET</NuGetReference> + <Namespace>Apache.Ignite.Core</Namespace> + <Namespace>Apache.Ignite.Core.Binary</Namespace> + <Namespace>Apache.Ignite.Core.Cache.Configuration</Namespace> + <Namespace>Apache.Ignite.Core.Cache.Query</Namespace> +</Query> + +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/// <summary> +/// This example demonstrates put-get operations on Ignite cache +/// with binary values. Note that binary object can be retrieved in +/// fully-deserialized form or in binary object format using special +/// cache projection. +/// </summary> + +void Main() +{ + if (!Environment.Is64BitProcess) + throw new Exception("x64 LINQPad is required to run this sample (see AnyCPU build: http://www.linqpad.net/Download.aspx)"); + + // Force new LINQPad query process to reinit JVM + Util.NewProcess = true; + + // Configure cacheable types + var cfg = new IgniteConfiguration { BinaryConfiguration = new BinaryConfiguration(typeof(Organization), typeof(Person)) }; + + // Start instance + using (var ignite = Ignition.Start(cfg)) + { + // Create and populate organization cache + var orgs = ignite.GetOrCreateCache<int, Organization>(new CacheConfiguration("orgs", + new QueryEntity(typeof(int), typeof(Organization)))); + orgs[1] = new Organization { Name = "Apache", Type = "Private", Size = 5300 }; + orgs[2] = new Organization { Name = "Microsoft", Type = "Private", Size = 110000 }; + orgs[3] = new Organization { Name = "Red Cross", Type = "Non-Profit", Size = 35000 }; + + // Create and populate person cache + var persons = ignite.CreateCache<int, Person>(new CacheConfiguration("persons", typeof(Person))); + persons[1] = new Person { OrgId = 1, Name = "James Wilson" }; + persons[2] = new Person { OrgId = 1, Name = "Daniel Adams" }; + persons[3] = new Person { OrgId = 2, Name = "Christian Moss" }; + persons[4] = new Person { OrgId = 3, Name = "Allison Mathis" }; + persons[5] = new Person { OrgId = 3, Name = "Christopher Adams" }; + + // SQL query + orgs.Query(new SqlQuery(typeof(Organization), "size < ?", 100000)).Dump("Organizations with size less than 100K"); + + // SQL query with join + const string orgName = "Apache"; + persons.Query(new SqlQuery(typeof(Person), "from Person, \"orgs\".Organization where Person.OrgId = \"orgs\".Organization._key and \"orgs\".Organization.Name = ?", orgName)) + .Dump("Persons working for " + orgName); + + // Fields query + orgs.QueryFields(new SqlFieldsQuery("select name, size from Organization")).Dump("Fields query"); + + // Full text query + persons.Query(new TextQuery(typeof(Person), "Chris*")).Dump("Persons starting with 'Chris'"); + } +} + +public class Organization +{ + [QuerySqlField] + public string Name { get; set; } + + public string Type { get; set; } + + [QuerySqlField] + public int Size { get; set;} +} + +public class Person +{ + [QueryTextField] + public string Name { get; set; } + + [QuerySqlField] + public int OrgId { get; set; } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/PostBuild.ps1 ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/PostBuild.ps1 b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/PostBuild.ps1 new file mode 100644 index 0000000..ed111d1 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/PostBuild.ps1 @@ -0,0 +1,20 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$solutionDir = [System.IO.Path]::GetDirectoryName($dte.Solution.FullName) + "\" +$path = $installPath.Replace($solutionDir, "`$(SolutionDir)") + +$Jars = Join-Path $path "Libs\*.*" + +$IgnitePostBuildCmd = " +if not exist `"`$(TargetDir)Libs`" md `"`$(TargetDir)Libs`" +xcopy /s /y `"$Jars`" `"`$(TargetDir)Libs`"" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/Uninstall.ps1 ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/Uninstall.ps1 b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/Uninstall.ps1 new file mode 100644 index 0000000..f81f41c --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/Uninstall.ps1 @@ -0,0 +1,21 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +param($installPath, $toolsPath, $package, $project) + +. (Join-Path $toolsPath "PostBuild.ps1") + +# Get the current Post Build Event cmd +$currentPostBuildCmd = $project.Properties.Item("PostBuildEvent").Value + +# Remove our post build command from it (if it's there) +$project.Properties.Item("PostBuildEvent").Value = $currentPostBuildCmd.Replace($IgnitePostBuildCmd, "") http://git-wip-us.apache.org/repos/asf/ignite/blob/88429f2e/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index e189807..9d6c39f 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -860,6 +860,8 @@ <exclude>**/bin/x64/**</exclude> <exclude>**/bin/x86/**</exclude> <exclude>**/*.dxg</exclude> + <exclude>**/*.cmd</exclude> + <exclude>**/*.ps1</exclude> </excludes> </configuration> </execution>
