You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/17 16:26:28 UTC
[1/3] ignite git commit: IGNITE-1496: Added .Net examples.
Repository: ignite
Updated Branches:
refs/heads/ignite-1282 c5fd4a5b1 -> 1a5e5ff32
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Config/example-cache.xml b/modules/platform/src/main/dotnet/Examples/Config/example-cache.xml
new file mode 100644
index 0000000..a262ce1
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Config/example-cache.xml
@@ -0,0 +1,83 @@
+<?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"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Set to true to enable distributed class loading for examples, default is false. -->
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache*"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="tx"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="backups" value="1"/>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Config/example-compute.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Config/example-compute.xml b/modules/platform/src/main/dotnet/Examples/Config/example-compute.xml
new file mode 100644
index 0000000..3a48a9c
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Config/example-compute.xml
@@ -0,0 +1,70 @@
+<?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"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <!-- Enable task execution events for examples. -->
+ <property name="includeEventTypes">
+ <list>
+ <!-- Task execution events -->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
+
+ <!-- Job execution events -->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_MAPPED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_RESULTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED_OVER"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_STARTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FINISHED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_TIMEDOUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_REJECTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_FAILED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_QUEUED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_CANCELLED"/>
+ </list>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 226f95f..faa5a61 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -96,6 +96,10 @@
<Compile Include="Compute\TaskResultTest.cs" />
<Compile Include="Dataload\DataStreamerTest.cs" />
<Compile Include="EventsTest.cs" />
+ <Compile Include="Examples\Example.cs" />
+ <Compile Include="Examples\ExamplesTest.cs" />
+ <Compile Include="Examples\PathUtil.cs" />
+ <Compile Include="Examples\ProjectFilesTest.cs" />
<Compile Include="ExceptionsTest.cs" />
<Compile Include="ExecutableTest.cs" />
<Compile Include="FutureTest.cs" />
@@ -130,6 +134,18 @@
<Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
<Name>Apache.Ignite.Core</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\..\main\dotnet\Apache.Ignite\Apache.Ignite.csproj">
+ <Project>{27F7F3C6-BDDE-43A9-B565-856F8395A04B}</Project>
+ <Name>Apache.Ignite</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\main\dotnet\Examples\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
+ <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
+ <Name>Apache.Ignite.ExamplesDll</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\main\dotnet\Examples\Apache.Ignite.Examples\Apache.Ignite.Examples.csproj">
+ <Project>{069fa680-3c4d-43a9-b84f-e67513b87827}</Project>
+ <Name>Apache.Ignite.Examples</Name>
+ </ProjectReference>
<ProjectReference Include="..\Apache.Ignite.Core.Tests.TestDll\Apache.Ignite.Core.Tests.TestDll.csproj">
<Project>{F4A69E2D-908E-4F0F-A794-84D508D60E5F}</Project>
<Name>Apache.Ignite.Core.Tests.TestDll</Name>
@@ -144,6 +160,7 @@
</Content>
<Content Include="Config\cache-query.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ <SubType>Designer</SubType>
</Content>
<Content Include="Config\Cache\Store\cache-store-session.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
new file mode 100644
index 0000000..edb04cb
--- /dev/null
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/Example.cs
@@ -0,0 +1,137 @@
+/*
+ * 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.Examples
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Text.RegularExpressions;
+ using Apache.Ignite.Examples.Compute;
+ using Apache.Ignite.ExamplesDll.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Represents an Example to be tested.
+ /// </summary>
+ public class Example
+ {
+ /** All examples */
+ private static readonly Example[] Examples = GetExamples().ToArray();
+
+ /** Execute action */
+ private Action _runAction;
+
+ /** Config url */
+ public string SpringConfigUrl { get; private set; }
+
+ /** Source path */
+ public string SourceFilePath { get; private set; }
+
+ /** Dll load flag */
+ public bool NeedsTestDll { get; private set; }
+
+ /** Name */
+ public string Name { get; private set; }
+
+ /// <summary>
+ /// Runs this example.
+ /// </summary>
+ public void Run()
+ {
+ try
+ {
+ _runAction();
+ }
+ catch (InvalidOperationException ex)
+ {
+ // Each example has a ReadKey at the end, which throws an exception in test environment.
+ if (ex.Message != "Cannot read keys when either application does not have a console or " +
+ "when console input has been redirected from a file. Try Console.Read.")
+ throw;
+ }
+ }
+
+ /// <summary>
+ /// Gets all examples.
+ /// </summary>
+ public static IEnumerable<Example> All
+ {
+ get { return Examples; }
+ }
+
+ /// <summary>
+ /// Gets all examples.
+ /// </summary>
+ private static IEnumerable<Example> GetExamples()
+ {
+ var examplesAsm = typeof (ClosureExample).Assembly;
+
+ var sourceFiles = Directory.GetFiles(PathUtil.ExamplesSourcePath, "*.cs", SearchOption.AllDirectories);
+
+ Assert.IsTrue(sourceFiles.Any());
+
+ var types = examplesAsm.GetTypes().Where(x => x.GetMethod("Main") != null).ToArray();
+
+ Assert.IsTrue(types.Any());
+
+ var examplesDllName = typeof(AverageSalaryJob).Assembly.GetName().Name;
+
+ foreach (var type in types)
+ {
+ var sourceFile = sourceFiles.Single(x => x.EndsWith(string.Format("\\{0}.cs", type.Name)));
+
+ var sourceCode = File.ReadAllText(sourceFile);
+
+ yield return new Example
+ {
+ SourceFilePath = sourceFile,
+ SpringConfigUrl = PathUtil.GetFullConfigPath(GetSpringConfigUrl(sourceCode)),
+ NeedsTestDll = sourceCode.Contains(examplesDllName),
+ _runAction = GetRunAction(type),
+ Name = type.Name
+ };
+ }
+ }
+
+ /// <summary>
+ /// Gets the run action.
+ /// </summary>
+ private static Action GetRunAction(Type type)
+ {
+ return (Action) Delegate.CreateDelegate(typeof (Action), type.GetMethod("Main"));
+ }
+
+ /// <summary>
+ /// Gets the spring configuration URL.
+ /// </summary>
+ private static string GetSpringConfigUrl(string code)
+ {
+ var match = Regex.Match(code, "-springConfigUrl=(.*?.xml)");
+
+ return match.Success ? match.Groups[1].Value : null;
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ // This will be displayed in TeamCity and R# test runner
+ return Name;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
new file mode 100644
index 0000000..0f4ba5e
--- /dev/null
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
@@ -0,0 +1,137 @@
+/*
+ * 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.Examples
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using Apache.Ignite.Core.Tests.Process;
+ using Apache.Ignite.ExamplesDll.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests all examples in various modes.
+ /// </summary>
+ [Category(TestUtils.CategoryIntensive)]
+ public class ExamplesTest
+ {
+ /// <summary>
+ /// Tests the example in a single node mode.
+ /// </summary>
+ /// <param name="example">The example to run.</param>
+ [Test, TestCaseSource("TestCases")]
+ public void TestLocalNode(Example example)
+ {
+ example.Run();
+ }
+
+ /// <summary>
+ /// Tests the example with standalone Apache.Ignite.exe nodes.
+ /// </summary>
+ /// <param name="example">The example to run.</param>
+ [Test, TestCaseSource("TestCases")]
+ public void TestRemoteNodes(Example example)
+ {
+ TestRemoteNodes(example, false);
+ }
+
+ /// <summary>
+ /// Tests the example with standalone Apache.Ignite.exe nodes while local node is in client mode.
+ /// </summary>
+ /// <param name="example">The example to run.</param>
+ [Test, TestCaseSource("TestCases")]
+ public void TestRemoteNodesClientMode(Example example)
+ {
+ TestRemoteNodes(example, true);
+ }
+
+ /// <summary>
+ /// Tests the example with standalone Apache.Ignite.exe nodes.
+ /// </summary>
+ /// <param name="example">The example to run.</param>
+ /// <param name="clientMode">Client mode flag.</param>
+ private static void TestRemoteNodes(Example example, bool clientMode)
+ {
+ // Exclude CrossPlatformExample and LifecycleExample
+ if (string.IsNullOrEmpty(example.SpringConfigUrl))
+ {
+ Assert.IsTrue(new[] {"CrossPlatformExample", "LifecycleExample"}.Contains(example.Name));
+
+ return;
+ }
+
+ Assert.IsTrue(File.Exists(example.SpringConfigUrl));
+
+ var gridConfig = new IgniteConfiguration {SpringConfigUrl = example.SpringConfigUrl};
+
+ // Try with multiple standalone nodes
+ for (var i = 0; i < 2; i++)
+ {
+ // Start a grid to monitor topology
+ // Stop it after topology check so we don't interfere with example
+ Ignition.ClientMode = false;
+
+ using (var ignite = Ignition.Start(gridConfig))
+ {
+ var args = new List<string> {"-springConfigUrl=" + example.SpringConfigUrl};
+
+ if (example.NeedsTestDll)
+ args.Add(" -assembly=" + typeof(AverageSalaryJob).Assembly.Location);
+
+ // ReSharper disable once UnusedVariable
+ var proc = new IgniteProcess(args.ToArray());
+
+ Assert.IsTrue(ignite.WaitTopology(i + 2, 30000));
+ }
+
+ Ignition.ClientMode = clientMode;
+ example.Run();
+ }
+ }
+
+ /// <summary>
+ /// Fixture setup.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void FixtureSetUp()
+ {
+ Environment.SetEnvironmentVariable("IGNITE_NATIVE_TEST_CLASSPATH", "true");
+
+ Directory.SetCurrentDirectory(PathUtil.IgniteHome);
+ }
+
+ /// <summary>
+ /// Test teardown.
+ /// </summary>
+ [TearDown]
+ public void TearDown()
+ {
+ Ignition.ClientMode = false;
+ IgniteProcess.KillAll();
+ }
+
+ /// <summary>
+ /// Gets the test cases.
+ /// </summary>
+ public IEnumerable<Example> TestCases
+ {
+ get { return Example.All; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
new file mode 100644
index 0000000..2959d4d
--- /dev/null
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
@@ -0,0 +1,52 @@
+/*
+ * 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.Examples
+{
+ using System.IO;
+ using Apache.Ignite.Core.Impl;
+
+ /// <summary>
+ /// Grid path resolver.
+ /// </summary>
+ public static class PathUtil
+ {
+ public static readonly string IgniteHome = IgniteManager.GetIgniteHome(null);
+
+ /// <summary>
+ /// Full Apache.Ignite.exe path.
+ /// </summary>
+ public static readonly string IgniteExePath = typeof(IgniteRunner).Assembly.Location;
+
+ /// <summary>
+ /// Examples source code path.
+ /// </summary>
+ public static readonly string ExamplesSourcePath = Path.Combine(IgniteHome,
+ @"modules\platform\src\main\dotnet\Examples");
+
+ /// <summary>
+ /// Gets the full configuration path.
+ /// </summary>
+ public static string GetFullConfigPath(string springConfigUrl)
+ {
+ if (string.IsNullOrEmpty(springConfigUrl))
+ return springConfigUrl;
+
+ return Path.GetFullPath(Path.Combine(IgniteHome, springConfigUrl));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs
new file mode 100644
index 0000000..24bd663
--- /dev/null
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Examples/ProjectFilesTest.cs
@@ -0,0 +1,45 @@
+/*
+ * 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.Examples
+{
+ using System.IO;
+ using System.Linq;
+ using System.Text.RegularExpressions;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests project files.
+ /// </summary>
+ public class ProjectFilesTest
+ {
+ /// <summary>
+ /// Checks config files in examples comments for existence.
+ /// </summary>
+ [Test]
+ public void CheckConfigFilesExist()
+ {
+ Directory.GetFiles(PathUtil.ExamplesSourcePath, "*.cs", SearchOption.AllDirectories)
+ .Select(File.ReadAllText)
+ .SelectMany(src => Regex.Matches(src, @"modules\\platform[^\s]+.xml").OfType<Match>())
+ .Where(match => match.Success)
+ .Select(match => Path.Combine(PathUtil.IgniteHome, match.Value))
+ .ToList()
+ .ForEach(path => Assert.IsTrue(File.Exists(path), "Config file does not exist: " + path));
+ }
+ }
+}
\ No newline at end of file
[2/3] ignite git commit: IGNITE-1496: Added .Net examples.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
new file mode 100644
index 0000000..db0e5d6
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Misc/LifecycleExample.cs
@@ -0,0 +1,111 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Lifecycle;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.Examples.Misc
+{
+ /// <summary>
+ /// This example shows how to provide your own <see cref="ILifecycleBean"/> implementation
+ /// to be able to hook into Apache lifecycle. Example bean will output occurred lifecycle
+ /// events to the console.
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// This example does not require remote nodes to be started.
+ /// </summary>
+ public class LifecycleExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Lifecycle example started.");
+
+ // Create new configuration.
+ var lifecycleExampleBean = new LifecycleExampleBean();
+
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" },
+ LifecycleBeans = new List<ILifecycleBean> { lifecycleExampleBean }
+ };
+
+ // Provide lifecycle bean to configuration.
+ using (Ignition.Start(cfg))
+ {
+ // Make sure that lifecycle bean was notified about Ignite startup.
+ Console.WriteLine();
+ Console.WriteLine(">>> Started (should be true): " + lifecycleExampleBean.Started);
+ }
+
+ // Make sure that lifecycle bean was notified about Ignite stop.
+ Console.WriteLine();
+ Console.WriteLine(">>> Started (should be false): " + lifecycleExampleBean.Started);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Sample lifecycle bean implementation.
+ /// </summary>
+ private class LifecycleExampleBean : ILifecycleBean
+ {
+ /** Auto-injected Ignite instance. */
+ [InstanceResource]
+#pragma warning disable 649
+ private IIgnite _ignite;
+#pragma warning restore 649
+
+ /** <inheritDoc /> */
+ public void OnLifecycleEvent(LifecycleEventType evt)
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Ignite lifecycle event occurred: " + evt);
+ Console.WriteLine(">>> Ignite name: " + (_ignite != null ? _ignite.Name : "not available"));
+
+ if (evt == LifecycleEventType.AfterNodeStart)
+ Started = true;
+ else if (evt == LifecycleEventType.AfterNodeStop)
+ Started = false;
+ }
+
+ /// <summary>
+ /// Started flag.
+ /// </summary>
+ public bool Started
+ {
+ get;
+ private set;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..555a35f
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/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 Examples")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("41a0cb95-3435-4c78-b867-900b28e2c9ee")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs
new file mode 100644
index 0000000..7253a0b
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Services/IMapService.cs
@@ -0,0 +1,56 @@
+/*
+ * 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 Apache.Ignite.ExamplesDll.Services;
+
+namespace Apache.Ignite.Examples.Services
+{
+ /// <summary>
+ /// Interface for service proxy interaction.
+ /// Actual service class (<see cref="MapService{TK,TV}"/>) does not have to implement this interface.
+ /// Target method/property will be searched by signature (name, arguments).
+ /// </summary>
+ public interface IMapService<TK, TV>
+ {
+ /// <summary>
+ /// Puts an entry to the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="value">The value.</param>
+ void Put(TK key, TV value);
+
+ /// <summary>
+ /// Gets an entry from the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <returns>Entry value.</returns>
+ TV Get(TK key);
+
+ /// <summary>
+ /// Clears the map.
+ /// </summary>
+ void Clear();
+
+ /// <summary>
+ /// Gets the size of the map.
+ /// </summary>
+ /// <value>
+ /// The size.
+ /// </value>
+ int Size { get; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs
new file mode 100644
index 0000000..604658d
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Services/ServicesExample.cs
@@ -0,0 +1,79 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Services;
+
+namespace Apache.Ignite.Examples.Services
+{
+ /// <summary>
+ /// Example demonstrating Ignite services.
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll if you havent't done it yet (select it -> right-click -> Build);
+ /// 2) Locate created Apache.Ignite.ExamplesDll.dll file (Apache.Ignite.ExamplesDll project -> right-click -> Properties -> Build -> Output path);
+ /// 3) Locate Apache.Ignite.exe file (Apache.Ignite project -> right-click -> Properties -> Build -> Output path)
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// </summary>
+ public class ServicesExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine(">>> Services example started.");
+ Console.WriteLine();
+
+ // Deploy a service
+ var svc = new MapService<int, string>();
+ Console.WriteLine(">>> Deploying service to all nodes...");
+ ignite.GetServices().DeployNodeSingleton("service", svc);
+
+ // Get a sticky service proxy so that we will always be contacting the same remote node.
+ var prx = ignite.GetServices().GetServiceProxy<IMapService<int, string>>("service", true);
+
+ for (var i = 0; i < 10; i++)
+ prx.Put(i, i.ToString());
+
+ var mapSize = prx.Size;
+
+ Console.WriteLine(">>> Map service size: " + mapSize);
+
+ ignite.GetServices().CancelAll();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
new file mode 100644
index 0000000..cb2ff6f
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.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)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{DFB08363-202E-412D-8812-349EF10A8702}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.ExamplesDll</RootNamespace>
+ <AssemblyName>Apache.Ignite.ExamplesDll</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\AverageSalaryJob.cs" />
+ <Compile Include="Compute\AverageSalaryTask.cs" />
+ <Compile Include="Compute\CharacterCountClosure.cs" />
+ <Compile Include="Compute\CharacterCountReducer.cs" />
+ <Compile Include="Datagrid\EmployeeStorePredicate.cs" />
+ <Compile Include="Datagrid\ContinuousQueryFilter.cs" />
+ <Compile Include="Datagrid\EmployeeStore.cs" />
+ <Compile Include="Events\LocalListener.cs" />
+ <Compile Include="Events\RemoteFilter.cs" />
+ <Compile Include="Messaging\LocalListener.cs" />
+ <Compile Include="Messaging\RemoteOrderedListener.cs" />
+ <Compile Include="Messaging\RemoteUnorderedListener.cs" />
+ <Compile Include="Messaging\Topic.cs" />
+ <Compile Include="Portable\Account.cs" />
+ <Compile Include="Portable\Address.cs" />
+ <Compile Include="Portable\Employee.cs" />
+ <Compile Include="Portable\EmployeeKey.cs" />
+ <Compile Include="Portable\Organization.cs" />
+ <Compile Include="Portable\OrganizationType.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\MapService.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+ <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+ <Name>Apache.Ignite.Core</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- 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/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
new file mode 100644
index 0000000..e4713d4
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryJob.cs
@@ -0,0 +1,65 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Average salary job.
+ /// </summary>
+ [Serializable]
+ public class AverageSalaryJob : ComputeJobAdapter<Tuple<long, int>>
+ {
+ /// <summary> Employees. </summary>
+ private readonly ICollection<Employee> _employees = new List<Employee>();
+
+ /// <summary>
+ /// Adds employee.
+ /// </summary>
+ /// <param name="employee">Employee.</param>
+ public void Add(Employee employee)
+ {
+ _employees.Add(employee);
+ }
+
+ /// <summary>
+ /// Execute the job.
+ /// </summary>
+ /// <returns>Job result: tuple with total salary in the first item and employees count in the second.</returns>
+ override public Tuple<long, int> Execute()
+ {
+ long sum = 0;
+ int count = 0;
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Executing salary job for " + _employees.Count + " employee(s) ...");
+ Console.WriteLine();
+
+ foreach (Employee emp in _employees)
+ {
+ sum += emp.Salary;
+ count++;
+ }
+
+ return new Tuple<long, int>(sum, count);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
new file mode 100644
index 0000000..f8acb01
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <summary>
+ /// Average salary task.
+ /// </summary>
+ public class AverageSalaryTask : ComputeTaskSplitAdapter<ICollection<Employee>, Tuple<long, int>, long>
+ {
+ /// <summary>
+ /// Split the task distributing employees between several jobs.
+ /// </summary>
+ /// <param name="gridSize">Number of available grid nodes.</param>
+ /// <param name="arg">Task execution argument.</param>
+ protected override ICollection<IComputeJob<Tuple<long, int>>> Split(int gridSize, ICollection<Employee> arg)
+ {
+ ICollection<Employee> employees = arg;
+
+ var jobs = new List<IComputeJob<Tuple<long, int>>>(gridSize);
+
+ int count = 0;
+
+ foreach (Employee employee in employees)
+ {
+ int idx = count++ % gridSize;
+
+ AverageSalaryJob job;
+
+ if (idx >= jobs.Count)
+ {
+ job = new AverageSalaryJob();
+
+ jobs.Add(job);
+ }
+ else
+ job = (AverageSalaryJob) jobs[idx];
+
+ job.Add(employee);
+ }
+
+ return jobs;
+ }
+
+ /// <summary>
+ /// Calculate average salary after all jobs are finished.
+ /// </summary>
+ /// <param name="results">Job results.</param>
+ /// <returns>Average salary.</returns>
+ public override long Reduce(IList<IComputeJobResult<Tuple<long, int>>> results)
+ {
+ long sum = 0;
+ int count = 0;
+
+ foreach (var t in results.Select(result => result.Data()))
+ {
+ sum += t.Item1;
+ count += t.Item2;
+ }
+
+ return sum / count;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.cs
new file mode 100644
index 0000000..2823221
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountClosure.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.
+ */
+
+using System;
+using Apache.Ignite.Core.Compute;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <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;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
new file mode 100644
index 0000000..6825046
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Compute/CharacterCountReducer.cs
@@ -0,0 +1,51 @@
+/*
+ * 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 Apache.Ignite.Core.Compute;
+
+namespace Apache.Ignite.ExamplesDll.Compute
+{
+ /// <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;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
new file mode 100644
index 0000000..8c05f42
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/ContinuousQueryFilter.cs
@@ -0,0 +1,50 @@
+/*
+ * 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;
+using Apache.Ignite.Core.Cache.Event;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+ /// <summary>
+ /// Filter for continuous query example.
+ /// </summary>
+ [Serializable]
+ public class ContinuousQueryFilter : ICacheEntryEventFilter<int, string>
+ {
+ /// <summary> Threshold. </summary>
+ private readonly int _threshold;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="threshold">Threshold.</param>
+ public ContinuousQueryFilter(int threshold)
+ {
+ _threshold = threshold;
+ }
+
+ /// <summary>
+ /// Evaluates cache entry event.
+ /// </summary>
+ /// <param name="evt">Event.</param>
+ public bool Evaluate(ICacheEntryEvent<int, string> evt)
+ {
+ return evt.Key >= _threshold;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
new file mode 100644
index 0000000..742b048
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStore.cs
@@ -0,0 +1,121 @@
+/*
+ * 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;
+using System.Collections;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Store;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+ /// <summary>
+ /// Example cache store implementation.
+ /// </summary>
+ public class EmployeeStore : CacheStoreAdapter
+ {
+ /// <summary>
+ /// Dictionary representing the store.
+ /// </summary>
+ private readonly ConcurrentDictionary<object, object> _db = new ConcurrentDictionary<object, object>(
+ new List<KeyValuePair<object, object>>
+ {
+ new KeyValuePair<object, object>(1, new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new List<string> {"Development"}
+ )),
+
+ new KeyValuePair<object, object>(2, new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new List<string> {"Sales"}
+ ))
+ });
+
+ /// <summary>
+ /// Loads all values from underlying persistent storage.
+ /// This method gets called as a result of <see cref="ICache{TK,TV}.LoadCache"/> call.
+ /// </summary>
+ /// <param name="act">Action that loads a cache entry.</param>
+ /// <param name="args">Optional arguments.</param>
+ public override void LoadCache(Action<object, object> act, params object[] args)
+ {
+ // Iterate over whole underlying store and call act on each entry to load it into the cache.
+ foreach (var entry in _db)
+ act(entry.Key, entry.Value);
+ }
+
+ /// <summary>
+ /// Loads multiple objects from the cache store.
+ /// This method gets called as a result of <see cref="ICache{K,V}.GetAll"/> call.
+ /// </summary>
+ /// <param name="keys">Keys to load.</param>
+ /// <returns>
+ /// A map of key, values to be stored in the cache.
+ /// </returns>
+ public override IDictionary LoadAll(ICollection keys)
+ {
+ var result = new Dictionary<object, object>();
+
+ foreach (var key in keys)
+ result[key] = Load(key);
+
+ return result;
+ }
+
+ /// <summary>
+ /// Loads an object from the cache store.
+ /// This method gets called as a result of <see cref="ICache{K,V}.Get"/> call.
+ /// </summary>
+ /// <param name="key">Key to load.</param>
+ /// <returns>Loaded value</returns>
+ public override object Load(object key)
+ {
+ object val;
+
+ _db.TryGetValue(key, out val);
+
+ return val;
+ }
+
+ /// <summary>
+ /// Write key-value pair to store.
+ /// </summary>
+ /// <param name="key">Key to write.</param>
+ /// <param name="val">Value to write.</param>
+ public override void Write(object key, object val)
+ {
+ _db[key] = val;
+ }
+
+ /// <summary>
+ /// Delete cache entry form store.
+ /// </summary>
+ /// <param name="key">Key to delete.</param>
+ public override void Delete(object key)
+ {
+ object val;
+
+ _db.TryRemove(key, out val);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
new file mode 100644
index 0000000..a585e5e
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Datagrid/EmployeeStorePredicate.cs
@@ -0,0 +1,40 @@
+/*
+ * 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;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Datagrid
+{
+ /// <summary>
+ /// Example cache entry predicate.
+ /// </summary>
+ [Serializable]
+ public class EmployeeStorePredicate : ICacheEntryFilter<int, Employee>
+ {
+ /// <summary>
+ /// Returns a value indicating whether provided cache entry satisfies this predicate.
+ /// </summary>
+ /// <param name="entry">Cache entry.</param>
+ /// <returns>Value indicating whether provided cache entry satisfies this predicate.</returns>
+ public bool Invoke(ICacheEntry<int, Employee> entry)
+ {
+ return entry.Key == 1;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
new file mode 100644
index 0000000..8a28355
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/LocalListener.cs
@@ -0,0 +1,55 @@
+/*
+ * 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;
+using System.Threading;
+using Apache.Ignite.Core.Events;
+
+namespace Apache.Ignite.ExamplesDll.Events
+{
+ /// <summary>
+ /// Local event listener.
+ /// </summary>
+ public class LocalListener : IEventFilter<IEvent>
+ {
+ /** Сount of received events. */
+ private int _eventsReceived;
+
+ /// <summary>
+ /// Gets the count of received events.
+ /// </summary>
+ public int EventsReceived
+ {
+ get { return _eventsReceived; }
+ }
+
+ /// <summary>
+ /// Determines whether specified event passes this filter.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="evt">Event.</param>
+ /// <returns>Value indicating whether specified event passes this filter.</returns>
+ public bool Invoke(Guid nodeId, IEvent evt)
+ {
+ Interlocked.Increment(ref _eventsReceived);
+
+ Console.WriteLine("Local listener received an event [evt={0}]", evt.Name);
+
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
new file mode 100644
index 0000000..db3204a
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Events/RemoteFilter.cs
@@ -0,0 +1,42 @@
+/*
+ * 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;
+using Apache.Ignite.Core.Events;
+
+namespace Apache.Ignite.ExamplesDll.Events
+{
+ /// <summary>
+ /// Remote event filter.
+ /// </summary>
+ [Serializable]
+ public class RemoteFilter : IEventFilter<IEvent>
+ {
+ /// <summary>
+ /// Determines whether specified event passes this filter.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="evt">Event.</param>
+ /// <returns>Value indicating whether specified event passes this filter.</returns>
+ public bool Invoke(Guid nodeId, IEvent evt)
+ {
+ Console.WriteLine("Remote filter received event [evt={0}]", evt.Name);
+
+ return evt is JobEvent;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
new file mode 100644
index 0000000..7659bb4
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/LocalListener.cs
@@ -0,0 +1,59 @@
+/*
+ * 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;
+using System.Threading;
+using Apache.Ignite.Core.Messaging;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Local message listener which signals countdown event on each received message.
+ /// </summary>
+ public class LocalListener : IMessageFilter<int>
+ {
+ /** Countdown event. */
+ private readonly CountdownEvent _countdown;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LocalListener"/> class.
+ /// </summary>
+ /// <param name="countdown">The countdown event.</param>
+ public LocalListener(CountdownEvent countdown)
+ {
+ if (countdown == null)
+ throw new ArgumentNullException("countdown");
+
+ _countdown = countdown;
+ }
+
+ /// <summary>
+ /// Receives a message and returns a value
+ /// indicating whether provided message and node id satisfy this predicate.
+ /// Returning false will unsubscribe this listener from future notifications.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+ public bool Invoke(Guid nodeId, int message)
+ {
+ _countdown.Signal();
+
+ return !_countdown.IsSet;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
new file mode 100644
index 0000000..8ae5ac1
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteOrderedListener.cs
@@ -0,0 +1,54 @@
+/*
+ * 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;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Messaging;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Listener for Ordered topic.
+ /// </summary>
+ [Serializable]
+ public class RemoteOrderedListener : IMessageFilter<int>
+ {
+ /** Injected Ignite instance. */
+ [InstanceResource]
+#pragma warning disable 649
+ private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+ /// <summary>
+ /// Receives a message and returns a value
+ /// indicating whether provided message and node id satisfy this predicate.
+ /// Returning false will unsubscribe this listener from future notifications.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+ public bool Invoke(Guid nodeId, int message)
+ {
+ Console.WriteLine("Received ordered message [msg={0}, fromNodeId={1}]", message, nodeId);
+
+ _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Ordered);
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
new file mode 100644
index 0000000..166dbd6
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/RemoteUnorderedListener.cs
@@ -0,0 +1,54 @@
+/*
+ * 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;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Messaging;
+using Apache.Ignite.Core.Resource;
+
+namespace Apache.Ignite.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Listener for Unordered topic.
+ /// </summary>
+ [Serializable]
+ public class RemoteUnorderedListener : IMessageFilter<int>
+ {
+ /** Injected Ignite instance. */
+ [InstanceResource]
+#pragma warning disable 649
+ private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+ /// <summary>
+ /// Receives a message and returns a value
+ /// indicating whether provided message and node id satisfy this predicate.
+ /// Returning false will unsubscribe this listener from future notifications.
+ /// </summary>
+ /// <param name="nodeId">Node identifier.</param>
+ /// <param name="message">Message.</param>
+ /// <returns>Value indicating whether provided message and node id satisfy this predicate.</returns>
+ public bool Invoke(Guid nodeId, int message)
+ {
+ Console.WriteLine("Received unordered message [msg={0}, fromNodeId={1}]", message, nodeId);
+
+ _ignite.GetCluster().ForNodeIds(nodeId).GetMessaging().Send(message, Topic.Unordered);
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
new file mode 100644
index 0000000..bda0bfe
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Messaging/Topic.cs
@@ -0,0 +1,28 @@
+/*
+ * 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.ExamplesDll.Messaging
+{
+ /// <summary>
+ /// Message topics.
+ /// </summary>
+ public static class Topic
+ {
+ public const int Ordered = 1;
+ public const int Unordered = 2;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
new file mode 100644
index 0000000..8e247e3
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Account.cs
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Account object. Used in transaction example.
+ /// </summary>
+ [Serializable]
+ public class Account
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">Account ID.</param>
+ /// <param name="balance">Account balance.</param>
+ public Account(int id, decimal balance)
+ {
+ Id = id;
+ Balance = balance;
+ }
+
+ /// <summary>
+ /// Account ID.
+ /// </summary>
+ public int Id { get; set; }
+
+ /// <summary>
+ /// Account balance.
+ /// </summary>
+ public decimal Balance { get; set; }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ override public String ToString()
+ {
+ return string.Format("{0} [id={1}, balance={2}]", typeof(Account).Name, Id, Balance);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
new file mode 100644
index 0000000..ca069cb
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Address.cs
@@ -0,0 +1,81 @@
+/*
+ * 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;
+using Apache.Ignite.Core.Portable;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Address.
+ /// </summary>
+ [Serializable]
+ public class Address : IPortableMarshalAware
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="street">Street.</param>
+ /// <param name="zip">ZIP code.</param>
+ public Address(string street, int zip)
+ {
+ Street = street;
+ Zip = zip;
+ }
+
+ /// <summary>
+ /// Street.
+ /// </summary>
+ public string Street { get; set; }
+
+ /// <summary>
+ /// ZIP code.
+ /// </summary>
+ public int Zip { get; set; }
+
+ /// <summary>
+ /// Writes this object to the given writer.
+ /// </summary>
+ /// <param name="writer">Writer.</param>
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteString("street", Street);
+ writer.WriteInt("zip", Zip);
+ }
+
+ /// <summary>
+ /// Reads this object from the given reader.
+ /// </summary>
+ /// <param name="reader">Reader.</param>
+ public void ReadPortable(IPortableReader reader)
+ {
+ Street = reader.ReadString("street");
+ Zip = reader.ReadInt("zip");
+ }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ override public string ToString()
+ {
+ return string.Format("{0} [street={1}, zip={2}]", typeof(Address).Name, Street, Zip);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
new file mode 100644
index 0000000..7f4388d
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Employee.cs
@@ -0,0 +1,93 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Employee.
+ /// </summary>
+ [Serializable]
+ public class Employee
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="salary">Salary.</param>
+ /// <param name="address">Address.</param>
+ /// <param name="departments">Departments.</param>
+ public Employee(string name, long salary, Address address, ICollection<string> departments)
+ {
+ Name = name;
+ Salary = salary;
+ Address = address;
+ Departments = departments;
+ }
+
+ /// <summary>
+ /// Name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Salary.
+ /// </summary>
+ public long Salary { get; set; }
+
+ /// <summary>
+ /// Address.
+ /// </summary>
+ public Address Address { get; set; }
+
+ /// <summary>
+ /// Departments.
+ /// </summary>
+ public ICollection<string> Departments { get; set; }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ override public string ToString()
+ {
+ return string.Format("{0} [name={1}, salary={2}, address={3}, departments={4}]", typeof(Employee).Name,
+ Name, Salary, Address, CollectionToString(Departments));
+ }
+
+ /// <summary>
+ /// Get string representation of collection.
+ /// </summary>
+ /// <returns></returns>
+ private static string CollectionToString<T>(ICollection<T> col)
+ {
+ if (col == null)
+ return "null";
+
+ var elements = col.Any()
+ ? col.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y)
+ : string.Empty;
+
+ return string.Format("[{0}]", elements);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
new file mode 100644
index 0000000..2267154
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/EmployeeKey.cs
@@ -0,0 +1,86 @@
+/*
+ * 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;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Employee key. Used in query example to co-locate employees with their organizations.
+ /// </summary>
+ [Serializable]
+ public class EmployeeKey
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="id">ID.</param>
+ /// <param name="orgId">Organization ID.</param>
+ public EmployeeKey(int id, int orgId)
+ {
+ Id = id;
+ OrganizationId = orgId;
+ }
+
+ /// <summary>
+ /// ID.
+ /// </summary>
+ public int Id { get; private set; }
+
+ /// <summary>
+ /// Organization ID.
+ /// </summary>
+ public int OrganizationId { get; private set; }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
+ /// </summary>
+ /// <returns>
+ /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
+ /// </returns>
+ /// <param name="obj">The object to compare with the current object. </param><filterpriority>2</filterpriority>
+ public override bool Equals(object obj)
+ {
+ EmployeeKey other = obj as EmployeeKey;
+
+ return other != null && Id == other.Id && OrganizationId == other.OrganizationId;
+ }
+
+ /// <summary>
+ /// Serves as a hash function for a particular type.
+ /// </summary>
+ /// <returns>
+ /// A hash code for the current <see cref="T:System.Object"/>.
+ /// </returns>
+ /// <filterpriority>2</filterpriority>
+ public override int GetHashCode()
+ {
+ return 31 * Id + OrganizationId;
+ }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format("{0} [id={1}, organizationId={2}]", typeof (EmployeeKey).Name, Id, OrganizationId);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.cs
new file mode 100644
index 0000000..e23c3c1
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/Organization.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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Organization.
+ /// </summary>
+ [Serializable]
+ public class Organization
+ {
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public Organization()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="address">Address.</param>
+ /// <param name="type">Type.</param>
+ /// <param name="lastUpdated">Last update time.</param>
+ public Organization(string name, Address address, OrganizationType type, DateTime lastUpdated)
+ {
+ Name = name;
+ Address = address;
+ Type = type;
+ LastUpdated = lastUpdated;
+ }
+
+ /// <summary>
+ /// Name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Address.
+ /// </summary>
+ public Address Address { get; set; }
+
+ /// <summary>
+ /// Type.
+ /// </summary>
+ public OrganizationType Type { get; set; }
+
+ /// <summary>
+ /// Last update time.
+ /// </summary>
+ public DateTime LastUpdated { get; set; }
+
+ /// <summary>
+ /// Returns a string that represents the current object.
+ /// </summary>
+ /// <returns>
+ /// A string that represents the current object.
+ /// </returns>
+ /// <filterpriority>2</filterpriority>
+ public override string ToString()
+ {
+ return string.Format("{0} [name={1}, address={2}, type={3}, lastUpdated={4}]", typeof (Organization).Name,
+ Name, Address, Type, LastUpdated);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.cs
new file mode 100644
index 0000000..198edb1
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Portable/OrganizationType.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.
+ */
+
+using System;
+
+namespace Apache.Ignite.ExamplesDll.Portable
+{
+ /// <summary>
+ /// Organization type.
+ /// </summary>
+ [Serializable]
+ public enum OrganizationType
+ {
+ /// <summary>
+ /// Non-profit organization.
+ /// </summary>
+ NonProfit,
+
+ /// <summary>
+ /// Private organization.
+ /// </summary>
+ Private,
+
+ /// <summary>
+ /// Government organization.
+ /// </summary>
+ Government
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f149d64
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/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 Examples Dll")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache Ignite")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("ce65ec7c-d3cf-41ad-8f45-f90d5af68d77")]
+
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
new file mode 100644
index 0000000..d577ff7
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.ExamplesDll/Services/MapService.cs
@@ -0,0 +1,119 @@
+/*
+ * 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;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Resource;
+using Apache.Ignite.Core.Services;
+
+namespace Apache.Ignite.ExamplesDll.Services
+{
+ /// <summary>
+ /// Service implementation.
+ /// </summary>
+ [Serializable]
+ public class MapService<TK, TV> : IService
+ {
+ /** Injected Ignite instance. */
+#pragma warning disable 649
+ [InstanceResource] private readonly IIgnite _ignite;
+#pragma warning restore 649
+
+ /** Cache. */
+ private ICache<TK, TV> _cache;
+
+ /// <summary>
+ /// Initializes this instance before execution.
+ /// </summary>
+ /// <param name="context">Service execution context.</param>
+ public void Init(IServiceContext context)
+ {
+ // Create a new cache for every service deployment.
+ // Note that we use service name as cache name, which allows
+ // for each service deployment to use its own isolated cache.
+ _cache = _ignite.GetOrCreateCache<TK, TV>("MapService_" + context.Name);
+
+ Console.WriteLine("Service initialized: " + context.Name);
+ }
+
+ /// <summary>
+ /// Starts execution of this service. This method is automatically invoked whenever an instance of the service
+ /// is deployed on an Ignite node. Note that service is considered deployed even after it exits the Execute
+ /// method and can be cancelled (or undeployed) only by calling any of the Cancel methods on
+ /// <see cref="IServices"/> API. Also note that service is not required to exit from Execute method until
+ /// Cancel method was called.
+ /// </summary>
+ /// <param name="context">Service execution context.</param>
+ public void Execute(IServiceContext context)
+ {
+ Console.WriteLine("Service started: " + context.Name);
+ }
+
+ /// <summary>
+ /// Cancels this instance.
+ /// <para/>
+ /// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
+ /// method whenever <see cref="IService.Cancel"/> is called. It is up to the user to
+ /// make sure that the service code properly reacts to cancellations.
+ /// </summary>
+ /// <param name="context">Service execution context.</param>
+ public void Cancel(IServiceContext context)
+ {
+ Console.WriteLine("Service cancelled: " + context.Name);
+ }
+
+ /// <summary>
+ /// Puts an entry to the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="value">The value.</param>
+ public void Put(TK key, TV value)
+ {
+ _cache.Put(key, value);
+ }
+
+ /// <summary>
+ /// Gets an entry from the map.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <returns>Entry value.</returns>
+ public TV Get(TK key)
+ {
+ return _cache.Get(key);
+ }
+
+ /// <summary>
+ /// Clears the map.
+ /// </summary>
+ public void Clear()
+ {
+ _cache.Clear();
+ }
+
+ /// <summary>
+ /// Gets the size of the map.
+ /// </summary>
+ /// <value>
+ /// The size.
+ /// </value>
+ public int Size
+ {
+ get { return _cache.GetSize(); }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Config/example-cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Config/example-cache-query.xml b/modules/platform/src/main/dotnet/Examples/Config/example-cache-query.xml
new file mode 100644
index 0000000..c9ea7e1
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Config/example-cache-query.xml
@@ -0,0 +1,111 @@
+<?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"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="portableConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetPortableConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
+ <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <!-- Cache configurations (all properties are optional). -->
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+
+ <!-- Configure type metadata to enable queries. -->
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="keyType" value="java.lang.Integer"/>
+ <property name="valueType" value="Organization"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ </map>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="keyType" value="EmployeeKey"/>
+ <property name="valueType" value="Employee"/>
+ <property name="ascendingFields">
+ <map>
+ <entry key="organizationId" value="java.lang.Integer"/>
+ <entry key="address.zip" value="java.lang.Integer"/>
+ </map>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ <entry key="salary" value="java.lang.Long"/>
+ </map>
+ </property>
+ <property name="textFields">
+ <list>
+ <value>address.street</value>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Config/example-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Config/example-cache-store.xml b/modules/platform/src/main/dotnet/Examples/Config/example-cache-store.xml
new file mode 100644
index 0000000..adc5f45
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Config/example-cache-store.xml
@@ -0,0 +1,60 @@
+<?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"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="writeThrough" value="true"/>
+ <property name="readThrough" value="true"/>
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+ <property name="assemblyName" value="Apache.Ignite.ExamplesDll"/>
+ <property name="className" value="Apache.Ignite.ExamplesDll.Datagrid.EmployeeStore"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
[3/3] ignite git commit: IGNITE-1496: Added .Net examples.
Posted by vo...@apache.org.
IGNITE-1496: Added .Net examples.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1a5e5ff3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1a5e5ff3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1a5e5ff3
Branch: refs/heads/ignite-1282
Commit: 1a5e5ff32bc544ae6b1a32dfe07ef6204dc2053b
Parents: c5fd4a5
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Sep 17 17:27:05 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Sep 17 17:27:05 2015 +0300
----------------------------------------------------------------------
.../platform/src/main/dotnet/Apache.Ignite.sln | 20 ++
.../dotnet/Examples/Apache.Ignite.Examples.sln | 72 ++++++
.../Apache.Ignite.Examples.csproj | 80 +++++++
.../Examples/Apache.Ignite.Examples/App.config | 24 ++
.../Compute/ClosureExample.cs | 89 ++++++++
.../Compute/TaskExample.cs | 145 ++++++++++++
.../Datagrid/ContinuousQueryExample.cs | 105 +++++++++
.../Datagrid/CrossPlatformExample.cs | 208 +++++++++++++++++
.../Datagrid/DataStreamerExample.cs | 101 +++++++++
.../Datagrid/PutGetExample.cs | 219 ++++++++++++++++++
.../Datagrid/QueryExample.cs | 226 +++++++++++++++++++
.../Datagrid/StoreExample.cs | 116 ++++++++++
.../Datagrid/TransactionExample.cs | 104 +++++++++
.../Events/EventsExample.cs | 122 ++++++++++
.../Messaging/MessagingExample.cs | 119 ++++++++++
.../Misc/LifecycleExample.cs | 111 +++++++++
.../Properties/AssemblyInfo.cs | 35 +++
.../Services/IMapService.cs | 56 +++++
.../Services/ServicesExample.cs | 79 +++++++
.../Apache.Ignite.ExamplesDll.csproj | 75 ++++++
.../Compute/AverageSalaryJob.cs | 65 ++++++
.../Compute/AverageSalaryTask.cs | 84 +++++++
.../Compute/CharacterCountClosure.cs | 43 ++++
.../Compute/CharacterCountReducer.cs | 51 +++++
.../Datagrid/ContinuousQueryFilter.cs | 50 ++++
.../Datagrid/EmployeeStore.cs | 121 ++++++++++
.../Datagrid/EmployeeStorePredicate.cs | 40 ++++
.../Events/LocalListener.cs | 55 +++++
.../Events/RemoteFilter.cs | 42 ++++
.../Messaging/LocalListener.cs | 59 +++++
.../Messaging/RemoteOrderedListener.cs | 54 +++++
.../Messaging/RemoteUnorderedListener.cs | 54 +++++
.../Messaging/Topic.cs | 28 +++
.../Portable/Account.cs | 60 +++++
.../Portable/Address.cs | 81 +++++++
.../Portable/Employee.cs | 93 ++++++++
.../Portable/EmployeeKey.cs | 86 +++++++
.../Portable/Organization.cs | 84 +++++++
.../Portable/OrganizationType.cs | 43 ++++
.../Properties/AssemblyInfo.cs | 35 +++
.../Services/MapService.cs | 119 ++++++++++
.../Examples/Config/example-cache-query.xml | 111 +++++++++
.../Examples/Config/example-cache-store.xml | 60 +++++
.../dotnet/Examples/Config/example-cache.xml | 83 +++++++
.../dotnet/Examples/Config/example-compute.xml | 70 ++++++
.../Apache.Ignite.Core.Tests.csproj | 17 ++
.../Examples/Example.cs | 137 +++++++++++
.../Examples/ExamplesTest.cs | 137 +++++++++++
.../Examples/PathUtil.cs | 52 +++++
.../Examples/ProjectFilesTest.cs | 45 ++++
50 files changed, 4165 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Apache.Ignite.sln
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.sln b/modules/platform/src/main/dotnet/Apache.Ignite.sln
index e9886ed..e46d30f 100644
--- a/modules/platform/src/main/dotnet/Apache.Ignite.sln
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.sln
@@ -13,6 +13,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core.Tests.Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Examples\Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Examples\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -61,6 +65,22 @@ Global
{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
{27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.Build.0 = Debug|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.Build.0 = Debug|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.Build.0 = Release|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples.sln
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples.sln b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples.sln
new file mode 100644
index 0000000..c1337f3
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples.sln
@@ -0,0 +1,72 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.31101.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Core", "..\Apache.Ignite.Core\Apache.Ignite.Core.csproj", "{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\..\cpp\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.Examples", "Apache.Ignite.Examples\Apache.Ignite.Examples.csproj", "{069FA680-3C4D-43A9-B84F-E67513B87827}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite.ExamplesDll", "Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj", "{DFB08363-202E-412D-8812-349EF10A8702}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{F1491682-C798-4C23-8239-16C5BC2C5A02}"
+ ProjectSection(SolutionItems) = preProject
+ Config\example-cache-query.xml = Config\example-cache-query.xml
+ Config\example-cache-store.xml = Config\example-cache-store.xml
+ Config\example-cache.xml = Config\example-cache.xml
+ Config\example-compute.xml = Config\example-compute.xml
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Ignite", "..\Apache.Ignite\Apache.Ignite.csproj", "{27F7F3C6-BDDE-43A9-B565-856F8395A04B}"
+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
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.ActiveCfg = Debug|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x64.Build.0 = Debug|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.ActiveCfg = Debug|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Debug|x86.Build.0 = Debug|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.ActiveCfg = Release|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x64.Build.0 = Release|x64
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.ActiveCfg = Release|x86
+ {4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}.Release|x86.Build.0 = Release|x86
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.ActiveCfg = Debug|Win32
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x86.Build.0 = Debug|Win32
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.ActiveCfg = Release|Win32
+ {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x86.Build.0 = Release|Win32
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.ActiveCfg = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x64.Build.0 = Debug|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.ActiveCfg = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Debug|x86.Build.0 = Debug|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.ActiveCfg = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x64.Build.0 = Release|x64
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.ActiveCfg = Release|x86
+ {069FA680-3C4D-43A9-B84F-E67513B87827}.Release|x86.Build.0 = Release|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x64.ActiveCfg = Debug|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Debug|x86.ActiveCfg = Debug|x86
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x64.ActiveCfg = Release|x64
+ {DFB08363-202E-412D-8812-349EF10A8702}.Release|x86.ActiveCfg = Release|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.ActiveCfg = Debug|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x64.Build.0 = Debug|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.ActiveCfg = Debug|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Debug|x86.Build.0 = Debug|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.ActiveCfg = Release|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x64.Build.0 = Release|x64
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.ActiveCfg = Release|x86
+ {27F7F3C6-BDDE-43A9-B565-856F8395A04B}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
new file mode 100644
index 0000000..8ee90d9
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.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)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{069FA680-3C4D-43A9-B84F-E67513B87827}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Apache.Ignite.Examples</RootNamespace>
+ <AssemblyName>Apache.Ignite.Examples</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ <PlatformTarget>x64</PlatformTarget>
+ <OutputPath>bin\x64\Release\</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject>Apache.Ignite.Examples.Compute.TaskExample</StartupObject>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Compute\ClosureExample.cs" />
+ <Compile Include="Compute\TaskExample.cs" />
+ <Compile Include="Datagrid\ContinuousQueryExample.cs" />
+ <Compile Include="Datagrid\CrossPlatformExample.cs" />
+ <Compile Include="Datagrid\DataStreamerExample.cs" />
+ <Compile Include="Datagrid\PutGetExample.cs" />
+ <Compile Include="Datagrid\QueryExample.cs" />
+ <Compile Include="Datagrid\StoreExample.cs" />
+ <Compile Include="Datagrid\TransactionExample.cs" />
+ <Compile Include="Events\EventsExample.cs" />
+ <Compile Include="Messaging\MessagingExample.cs" />
+ <Compile Include="Misc\LifecycleExample.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Services\IMapService.cs" />
+ <Compile Include="Services\ServicesExample.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Apache.Ignite.Core\Apache.Ignite.Core.csproj">
+ <Project>{4CD2F726-7E2B-46C4-A5BA-057BB82EECB6}</Project>
+ <Name>Apache.Ignite.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Apache.Ignite.ExamplesDll\Apache.Ignite.ExamplesDll.csproj">
+ <Project>{dfb08363-202e-412d-8812-349ef10a8702}</Project>
+ <Name>Apache.Ignite.ExamplesDll</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- 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/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/App.config
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/App.config b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/App.config
new file mode 100644
index 0000000..8e69aeb
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/App.config
@@ -0,0 +1,24 @@
+<?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>
+ <runtime>
+ <gcServer enabled="true" />
+ </runtime>
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
new file mode 100644
index 0000000..cdc39ac
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Compute/ClosureExample.cs
@@ -0,0 +1,89 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Compute;
+
+namespace Apache.Ignite.Examples.Compute
+{
+ /// <summary>
+ /// Example demonstrating closure execution.
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll if you havent't done it yet (select it -> right-click -> Build);
+ /// 2) Locate created Apache.Ignite.ExamplesDll.dll file (Apache.Ignite.ExamplesDll project -> right-click ->
+ /// Properties -> Build -> Output path);
+ /// 3) Go to .Net binaries folder [IGNITE_HOME]\platforms\dotnet and run Apache.Ignite.exe as follows:
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// <para />
+ /// As a result you will see console jobs output on one or several nodes.
+ /// </summary>
+ public class ClosureExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Closure execution example started.");
+
+ // Split the string by spaces to count letters in each word in parallel.
+ ICollection<string> words = "Count characters using closure".Split().ToList();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Calculating character count with manual reducing:");
+
+ var res = ignite.GetCompute().Apply(new CharacterCountClosure(), words);
+
+ int totalLen = res.Sum();
+
+ Console.WriteLine(">>> Total character count: " + totalLen);
+ Console.WriteLine();
+ Console.WriteLine(">>> Calculating character count with reducer:");
+
+ totalLen = ignite.GetCompute().Apply(new CharacterCountClosure(), words, new CharacterCountReducer());
+
+ Console.WriteLine(">>> Total character count: " + totalLen);
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs
new file mode 100644
index 0000000..9124a35
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Compute/TaskExample.cs
@@ -0,0 +1,145 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Compute;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Compute
+{
+ /// <summary>
+ /// Example demonstrating task execution.
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll if you haven't done it yet (select it -> right-click -> Build);
+ /// 2) Locate created Apache.Ignite.ExamplesDll.dll file (Apache.Ignite.ExamplesDll project -> right-click ->
+ /// Properties -> Build -> Output path);
+ /// 3) Go to .Net binaries folder [IGNITE_HOME]\platforms\dotnet and run Apache.Ignite.exe as follows:
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// <para />
+ /// As a result you will see console jobs output on one or several nodes.
+ /// </summary>
+ public class TaskExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Task execution example started.");
+
+ // Generate employees to calculate average salary for.
+ ICollection<Employee> employees = Employees();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Calculating average salary for employees:");
+
+ foreach (Employee employee in employees)
+ Console.WriteLine(">>> " + employee);
+
+ // Execute task and get average salary.
+ var avgSalary = ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Average salary for all employees: " + avgSalary);
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Generates collection of employees for example.
+ /// </summary>
+ /// <returns>Collection of employees.</returns>
+ private static ICollection<Employee> Employees()
+ {
+ return new []
+ {
+ new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new List<string> {"Human Resources", "Customer Service"}
+ ),
+ new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ new List<string> {"Development", "QA"}
+ ),
+ new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ new List<string> {"Logistics"}
+ ),
+ new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, Hornitos, CA", 95325),
+ new List<string> {"Development"}
+ ),
+ new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78758),
+ new List<string> {"Sales"}
+ ),
+ new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ new List<string> {"Sales"}
+ ),
+ new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 02110),
+ new List<string> {"Development", "QA"}
+ ),
+ new Employee(
+ "Jack Yang",
+ 12900,
+ new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130),
+ new List<string> {"Sales"}
+ )
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
new file mode 100644
index 0000000..c22577c
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/ContinuousQueryExample.cs
@@ -0,0 +1,105 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using System.Threading;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache.Event;
+using Apache.Ignite.Core.Cache.Query.Continuous;
+using Apache.Ignite.ExamplesDll.Datagrid;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates continuous query API.
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll if you havent't done it yet (select it -> right-click -> Build);
+ /// 2) Locate created Apache.Ignite.ExamplesDll.dll file (Apache.Ignite.ExamplesDll project -> right-click -> Properties -> Build -> Output path);
+ /// 3) Locate Apache.Ignite.exe file (Apache.Ignite project -> right-click -> Properties -> Build -> Output path)
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-cache.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// </summary>
+ public class ContinuousQueryExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache continuous query example started.");
+
+ var cache = ignite.GetOrCreateCache<int, string>("cache_continuous_query");
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ const int keyCnt = 20;
+
+ for (int i = 0; i < keyCnt; i++)
+ cache.Put(i, i.ToString());
+
+ var qry = new ContinuousQuery<int, string>(new Listener<string>(), new ContinuousQueryFilter(15));
+
+
+ // Create new continuous query.
+ using (cache.QueryContinuous(qry))
+ {
+ // Add a few more keys and watch more query notifications.
+ for (var i = keyCnt; i < keyCnt + 5; i++)
+ cache.Put(i, i.ToString());
+
+ // Wait for a while while callback is notified about remaining puts.
+ Thread.Sleep(2000);
+ }
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Callback for continuous query example.
+ /// </summary>
+ private class Listener<T> : ICacheEntryEventListener<int, T>
+ {
+ public void OnEvent(IEnumerable<ICacheEntryEvent<int, T>> events)
+ {
+ foreach (var e in events)
+ Console.WriteLine("Queried entry [key=" + e.Key + ", val=" + e.Value + ']');
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
new file mode 100644
index 0000000..6d50144
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
@@ -0,0 +1,208 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Portable;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates use of portable objects between different platforms.
+ /// <para/>
+ /// This example must be run with standalone Java node. To achieve this start a node from IGNITE_HOME
+ /// using "ignite.bat" with proper configuration:
+ /// <example>'bin\ignite.bat examples\config\example-server.xml'</example>.
+ /// <para />
+ /// Once remote node is started, launch this example as follows:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// To see how objects can be transferred between platforms, start cross-platform Java example
+ /// without restarting remote node.
+ /// </summary>
+ public class CrossPlatformExample
+ {
+ /// <summary>Key for Java object.</summary>
+ private const int KeyJava = 100;
+
+ /// <summary>Key for .Net object.</summary>
+ private const int KeyDotnet = 200;
+
+ /// <summary>Key for C++ object.</summary>
+ private const int KeyCpp = 300;
+
+ /// <summary>Cache Name.</summary>
+ private const string CacheName = "cacheCrossPlatform";
+
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cross-platform example started.");
+
+ if (ignite.GetCluster().ForRemotes().GetNodes().Count == 0)
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> This example requires remote nodes to be started.");
+ Console.WriteLine(">>> Please start at least 1 remote node.");
+ Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
+ Console.WriteLine();
+ }
+ else
+ {
+ var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
+
+ // Create new Organization object to store in cache.
+ Organization org = new Organization(
+ "Apache",
+ new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ // Put created data entry to cache.
+ cache.Put(KeyDotnet, org);
+
+ // Retrieve value stored by Java client.
+ GetFromJava(ignite);
+
+ // Retrieve value stored by C++ client.
+ GetFromCpp(ignite);
+
+ // Gets portable value from cache in portable format, without de-serializing it.
+ GetDotNetPortableInstance(ignite);
+
+ // Gets portable value form cache as a strongly-typed fully de-serialized instance.
+ GetDotNetTypedInstance(ignite);
+
+ Console.WriteLine();
+ }
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Gets entry put by Java client. In order for entry to be in cache, Java client example
+ /// must be run before this example.
+ /// </summary>
+ /// <param name="Ignite">Ignite instance.</param>
+ private static void GetFromJava(IIgnite ignite)
+ {
+ var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+ .WithKeepPortable<int, IPortableObject>().WithAsync();
+
+ cache.Get(KeyJava);
+
+ var orgPortable = cache.GetFuture<IPortableObject>().ToTask().Result;
+
+ if (orgPortable == null)
+ {
+ Console.WriteLine(">>> Java client hasn't put entry to cache. Run Java example before this example " +
+ "to see the output.");
+ }
+ else
+ {
+ Console.WriteLine(">>> Entry from Java client:");
+ Console.WriteLine(">>> Portable: " + orgPortable);
+ Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
+ }
+ }
+
+ /// <summary>
+ /// Gets entry put by C++ client. In order for entry to be in cache, C++ client example
+ /// must be run before this example.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void GetFromCpp(IIgnite ignite)
+ {
+ var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+ .WithKeepPortable<int, IPortableObject>().WithAsync();
+
+ cache.Get(KeyCpp);
+
+ var orgPortable = cache.GetFuture<IPortableObject>().Get();
+
+ Console.WriteLine();
+
+ if (orgPortable == null)
+ {
+ Console.WriteLine(">>> CPP client hasn't put entry to cache. Run CPP example before this example " +
+ "to see the output.");
+ }
+ else
+ {
+ Console.WriteLine(">>> Entry from CPP client:");
+ Console.WriteLine(">>> Portable: " + orgPortable);
+ Console.WriteLine(">>> Deserialized: " + orgPortable.Deserialize<Organization>());
+ }
+ }
+
+ /// <summary>
+ /// Gets portable value from cache in portable format, without de-serializing it.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void GetDotNetPortableInstance(IIgnite ignite)
+ {
+ // Apply "KeepPortable" flag on data projection.
+ var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
+ .WithKeepPortable<int, IPortableObject>();
+
+ var org = cache.Get(KeyDotnet);
+
+ string name = org.GetField<string>("name");
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization name from portable field: " + name);
+ }
+
+ /// <summary>
+ /// Gets portable value form cache as a strongly-typed fully de-serialized instance.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void GetDotNetTypedInstance(IIgnite ignite)
+ {
+ var cache = ignite.GetOrCreateCache<int, Organization>(CacheName);
+
+ // Get recently created employee as a strongly-typed fully de-serialized instance.
+ Organization emp = cache.Get(KeyDotnet);
+
+ string name = emp.Name;
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization name from deserialized Organization instance: " + name);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
new file mode 100644
index 0000000..0974761
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/DataStreamerExample.cs
@@ -0,0 +1,101 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using System.Diagnostics;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Datastream;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// Demonstrates how cache can be populated with data utilizing <see cref="IDataStreamer{TK,TV}"/>.
+ /// Data streamer is a lot more efficient to use than standard cache put operation
+ /// as it properly buffers cache requests together and properly manages load on remote nodes.
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Locate Apache.Ignite.exe file (Apache.Ignite project -> right-click -> Properties -> Build -> Output path)
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-cache.xml
+ /// </summary>
+ public class DataStreamerExample
+ {
+ /// <summary>Number of entries to load.</summary>
+ private const int EntryCount = 500000;
+
+ /// <summary>Cache name.</summary>
+ private const string CacheName = "cache_data_streamer";
+
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache data streamer example started.");
+
+ // Clean up caches on all nodes before run.
+ ignite.GetOrCreateCache<int, Account>(CacheName).Clear();
+
+ Stopwatch timer = new Stopwatch();
+
+ timer.Start();
+
+ using (var ldr = ignite.GetDataStreamer<int, Account>(CacheName))
+ {
+ ldr.PerNodeBufferSize = 1024;
+
+ for (int i = 0; i < EntryCount; i++)
+ {
+ ldr.AddData(i, new Account(i, i));
+
+ // Print out progress while loading cache.
+ if (i > 0 && i % 10000 == 0)
+ Console.WriteLine("Loaded " + i + " accounts.");
+ }
+ }
+
+ timer.Stop();
+
+ long dur = timer.ElapsedMilliseconds;
+
+ Console.WriteLine(">>> Loaded " + EntryCount + " accounts in " + dur + "ms.");
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
new file mode 100644
index 0000000..ca2dfd1
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/PutGetExample.cs
@@ -0,0 +1,219 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Portable;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates several put-get operations on Ignite cache
+ /// with portable values. Note that portable object can be retrieved in
+ /// fully-deserialized form or in portable object format using special
+ /// cache projection.
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Locate Apache.Ignite.exe file (Apache.Ignite project -> right-click -> Properties -> Build -> Output path)
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-cache.xml
+ /// </summary>
+ public class PutGetExample
+ {
+ /// <summary>Cache name.</summary>
+ private const string CacheName = "cache_put_get";
+
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache put-get example started.");
+
+ // Clean up caches on all nodes before run.
+ ignite.GetOrCreateCache<object, object>(CacheName).Clear();
+
+ PutGet(ignite);
+ PutGetPortable(ignite);
+ PutAllGetAll(ignite);
+ PutAllGetAllPortable(ignite);
+
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Execute individual Put and Get.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutGet(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organization to store in cache.
+ Organization org = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ // Put created data entry to cache.
+ cache.Put(1, org);
+
+ // Get recently created employee as a strongly-typed fully de-serialized instance.
+ Organization orgFromCache = cache.Get(1);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization instance from cache: " + orgFromCache);
+ }
+
+ /// <summary>
+ /// Execute individual Put and Get, getting value in portable format, without de-serializing it.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutGetPortable(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organization to store in cache.
+ Organization org = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ // Put created data entry to cache.
+ cache.Put(1, org);
+
+ // Create projection that will get values as portable objects.
+ var portableCache = cache.WithKeepPortable<int, IPortableObject>();
+
+ // Get recently created organization as a portable object.
+ var portableOrg = portableCache.Get(1);
+
+ // Get organization's name from portable object (note that object doesn't need to be fully deserialized).
+ string name = portableOrg.GetField<string>("name");
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization name from portable object: " + name);
+ }
+
+ /// <summary>
+ /// Execute bulk Put and Get operations.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutAllGetAll(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organizations to store in cache.
+ Organization org1 = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ Organization org2 = new Organization(
+ "Red Cross",
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ OrganizationType.NonProfit,
+ DateTime.Now
+ );
+
+ var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
+
+ // Put created data entries to cache.
+ cache.PutAll(map);
+
+ // Get recently created organizations as a strongly-typed fully de-serialized instances.
+ IDictionary<int, Organization> mapFromCache = cache.GetAll(new List<int> { 1, 2 });
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization instances from cache:");
+
+ foreach (Organization org in mapFromCache.Values)
+ Console.WriteLine(">>> " + org);
+ }
+
+ /// <summary>
+ /// Execute bulk Put and Get operations getting values in portable format, without de-serializing it.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void PutAllGetAllPortable(IIgnite ignite)
+ {
+ var cache = ignite.GetCache<int, Organization>(CacheName);
+
+ // Create new Organizations to store in cache.
+ Organization org1 = new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ );
+
+ Organization org2 = new Organization(
+ "Red Cross",
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ OrganizationType.NonProfit,
+ DateTime.Now
+ );
+
+ var map = new Dictionary<int, Organization> { { 1, org1 }, { 2, org2 } };
+
+ // Put created data entries to cache.
+ cache.PutAll(map);
+
+ // Create projection that will get values as portable objects.
+ var portableCache = cache.WithKeepPortable<int, IPortableObject>();
+
+ // Get recently created organizations as portable objects.
+ IDictionary<int, IPortableObject> portableMap =
+ portableCache.GetAll(new List<int> { 1, 2 });
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Retrieved organization names from portable objects:");
+
+ foreach (IPortableObject poratbleOrg in portableMap.Values)
+ Console.WriteLine(">>> " + poratbleOrg.GetField<string>("name"));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
new file mode 100644
index 0000000..b25c401
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/QueryExample.cs
@@ -0,0 +1,226 @@
+/*
+ * 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;
+using System.Collections;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Cache;
+using Apache.Ignite.Core.Cache.Query;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example populates cache with sample data and runs several SQL and
+ /// full text queries over this data.
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Locate Apache.Ignite.exe file (Apache.Ignite project -> right-click -> Properties -> Build -> Output path)
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-cache-query.xml
+ /// </summary>
+ public class QueryExample
+ {
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-cache-query.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache query example started.");
+
+ var cache = ignite.GetCache<object, object>(null);
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ // Populate cache with sample data entries.
+ PopulateCache(cache);
+
+ // Create cache that will work with specific types.
+ var employeeCache = ignite.GetCache<EmployeeKey, Employee>(null);
+
+ // Run SQL query example.
+ SqlQueryExample(employeeCache);
+
+ // Run SQL query with join example.
+ SqlJoinQueryExample(employeeCache);
+
+ // Run SQL fields query example.
+ SqlFieldsQueryExample(employeeCache);
+
+ // Run full text query example.
+ FullTextQueryExample(employeeCache);
+
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Queries employees that have provided ZIP code in address.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ const int zip = 94109;
+
+ var qry = cache.Query(new SqlQuery(typeof(Employee), "zip = ?", zip));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees with zipcode " + zip + ":");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Queries employees that work for organization with provided name.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlJoinQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ const string orgName = "Apache";
+
+ var qry = cache.Query(new SqlQuery("Employee",
+ "from Employee, Organization " +
+ "where Employee.organizationId = Organization._key and Organization.name = ?", orgName));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees working for " + orgName + ":");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Queries names and salaries for all employees.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void SqlFieldsQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ var qry = cache.QueryFields(new SqlFieldsQuery("select name, salary from Employee"));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employee names and their salaries:");
+
+ foreach (IList row in qry)
+ Console.WriteLine(">>> [Name=" + row[0] + ", salary=" + row[1] + ']');
+ }
+
+ /// <summary>
+ /// Queries employees that live in Texas using full-text query API.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void FullTextQueryExample(ICache<EmployeeKey, Employee> cache)
+ {
+ var qry = cache.Query(new TextQuery("Employee", "TX"));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Employees living in Texas:");
+
+ foreach (var entry in qry)
+ Console.WriteLine(">>> " + entry.Value);
+ }
+
+ /// <summary>
+ /// Populate cache with data for this example.
+ /// </summary>
+ /// <param name="cache">Cache.</param>
+ private static void PopulateCache(ICache<object, object> cache)
+ {
+ cache.Put(1, new Organization(
+ "Apache",
+ new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+ OrganizationType.Private,
+ DateTime.Now
+ ));
+
+ cache.Put(2, new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.Private,
+ DateTime.Now
+ ));
+
+ cache.Put(new EmployeeKey(1, 1), new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new List<string> { "Human Resources", "Customer Service" }
+ ));
+
+ cache.Put(new EmployeeKey(2, 1), new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78130),
+ new List<string> { "Development", "QA" }
+ ));
+
+ cache.Put(new EmployeeKey(3, 1), new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ new List<string> { "Logistics" }
+ ));
+
+ cache.Put(new EmployeeKey(4, 2), new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new List<string> { "Development" }
+ ));
+
+ cache.Put(new EmployeeKey(5, 2), new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new List<string> { "Sales" }
+ ));
+
+ cache.Put(new EmployeeKey(6, 2), new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ new List<string> { "Sales" }
+ ));
+
+ cache.Put(new EmployeeKey(7, 2), new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+ new List<string> { "Development", "QA" }
+ ));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
new file mode 100644
index 0000000..020fc11
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/StoreExample.cs
@@ -0,0 +1,116 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Datagrid;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// Example demonstrating cache store.
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll if you havent't done it yet (select it -> right-click -> Build);
+ /// 2) Locate created Apache.Ignite.ExamplesDll.dll file (Apache.Ignite.ExamplesDll project -> right-click -> Properties -> Build -> Output path);
+ /// 3) Locate Apache.Ignite.exe file (Apache.Ignite project -> right-click -> Properties -> Build -> Output path)
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-cache-store.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// </summary>
+ class StoreExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-cache-store.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Cache store example started.");
+
+ var cache = ignite.GetCache<int, Employee>(null);
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Cleared values from cache.");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Load entries from store which pass provided filter.
+ cache.LoadCache(new EmployeeStorePredicate());
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Loaded entry from store through ICache.LoadCache().");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Load entry from store calling ICache.Get() method.
+ Employee emp = cache.Get(2);
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Loaded entry from store through ICache.Get(): " + emp);
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Put an entry to the cache
+ cache.Put(3, new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ new List<string> { "Human Resources", "Customer Service" }
+ ));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Put entry to cache. ");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Clear values again.
+ cache.Clear();
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Cleared values from cache again.");
+ Console.WriteLine(">>> Current cache size: " + cache.GetSize());
+
+ // Read values from cache after clear.
+ Console.WriteLine();
+ Console.WriteLine(">>> Read values after clear:");
+
+ for (int i = 1; i <= 3; i++)
+ Console.WriteLine(">>> Key=" + i + ", value=" + cache.Get(i));
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
new file mode 100644
index 0000000..ffa0fc1
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Datagrid/TransactionExample.cs
@@ -0,0 +1,104 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Transactions;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Datagrid
+{
+ /// <summary>
+ /// This example demonstrates how to use transactions on Apache cache.
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Locate Apache.Ignite.exe file (Apache.Ignite project -> right-click -> Properties -> Build -> Output path)
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-cache.xml
+ /// </summary>
+ class TransactionExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-cache.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine();
+ Console.WriteLine(">>> Transaction example started.");
+
+ var cache = ignite.GetCache<int, Account>("tx");
+
+ // Clean up caches on all nodes before run.
+ cache.Clear();
+
+ // Initialize.
+ cache.Put(1, new Account(1, 100));
+ cache.Put(2, new Account(2, 200));
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Accounts before transfer: ");
+ Console.WriteLine(">>> " + cache.Get(1));
+ Console.WriteLine(">>> " + cache.Get(2));
+ Console.WriteLine();
+
+ // Transfer money between accounts in a single transaction.
+ using (var tx = cache.Ignite.GetTransactions().TxStart(TransactionConcurrency.Pessimistic,
+ TransactionIsolation.RepeatableRead))
+ {
+ Account acc1 = cache.Get(1);
+ Account acc2 = cache.Get(2);
+
+ acc1.Balance += 100;
+ acc2.Balance -= 100;
+
+ cache.Put(1, acc1);
+ cache.Put(2, acc2);
+
+ tx.Commit();
+ }
+
+ Console.WriteLine(">>> Transfer finished.");
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Accounts after transfer: ");
+ Console.WriteLine(">>> " + cache.Get(1));
+ Console.WriteLine(">>> " + cache.Get(2));
+ Console.WriteLine();
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs
new file mode 100644
index 0000000..7c2f6a3
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Events/EventsExample.cs
@@ -0,0 +1,122 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.Ignite.Core;
+using Apache.Ignite.Core.Events;
+using Apache.Ignite.ExamplesDll.Compute;
+using Apache.Ignite.ExamplesDll.Events;
+using Apache.Ignite.ExamplesDll.Portable;
+
+namespace Apache.Ignite.Examples.Events
+{
+ /// <summary>
+ /// Example demonstrating Ignite events.
+ /// <para />
+ /// This example can be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll if you havent't done it yet (select it -> right-click -> Build);
+ /// 2) Locate created Apache.Ignite.ExamplesDll.dll file (Apache.Ignite.ExamplesDll project -> right-click -> Properties -> Build -> Output path);
+ /// 3) Locate Apache.Ignite.exe file (Apache.Ignite project -> right-click -> Properties -> Build -> Output path)
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// As a result you will see console events output on all nodes.
+ /// </summary>
+ public class EventsExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> {"-Xms512m", "-Xmx1024m"}
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ Console.WriteLine(">>> Events example started.");
+ Console.WriteLine();
+
+ // Local listen example
+ Console.WriteLine(">>> Listening for a local event...");
+
+ var listener = new LocalListener();
+ ignite.GetEvents().LocalListen(listener, EventType.EvtsTaskExecution);
+
+ ExecuteTask(ignite);
+
+ ignite.GetEvents().StopLocalListen(listener);
+
+ Console.WriteLine(">>> Received events count: " + listener.EventsReceived);
+ Console.WriteLine();
+
+ // Remote listen example (start standalone nodes for better demonstration)
+ Console.WriteLine(">>> Listening for remote events...");
+
+ var localListener = new LocalListener();
+ var remoteFilter = new RemoteFilter();
+
+ var listenId = ignite.GetEvents().RemoteListen(localListener: localListener,
+ remoteFilter: remoteFilter, types: EventType.EvtsJobExecution);
+
+ ExecuteTask(ignite);
+
+ ignite.GetEvents().StopRemoteListen(listenId);
+
+ Console.WriteLine(">>> Received events count: " + localListener.EventsReceived);
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+
+ /// <summary>
+ /// Executes a task to generate events.
+ /// </summary>
+ /// <param name="ignite">Ignite instance.</param>
+ private static void ExecuteTask(IIgnite ignite)
+ {
+ var employees = Enumerable.Range(1, 10).SelectMany(x => new[]
+ {
+ new Employee("Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ new[] {"Development"}),
+
+ new Employee("Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ new[] {"Sales"})
+ }).ToArray();
+
+ ignite.GetCompute().Execute(new AverageSalaryTask(), employees);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a5e5ff3/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
new file mode 100644
index 0000000..8d0a169
--- /dev/null
+++ b/modules/platform/src/main/dotnet/Examples/Apache.Ignite.Examples/Messaging/MessagingExample.cs
@@ -0,0 +1,119 @@
+/*
+ * 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;
+using System.Collections.Generic;
+using System.Threading;
+using Apache.Ignite.Core;
+using Apache.Ignite.ExamplesDll.Messaging;
+
+namespace Apache.Ignite.Examples.Messaging
+{
+ /// <summary>
+ /// Example demonstrating Ignite messaging.
+ /// <para />
+ /// This example should be run in conjunction with standalone Apache Ignite .Net node.
+ /// To start standalone node please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll if you havent't done it yet (select it -> right-click -> Build);
+ /// 2) Locate created Apache.Ignite.ExamplesDll.dll file (Apache.Ignite.ExamplesDll project -> right-click -> Properties -> Build -> Output path);
+ /// 3) Locate Apache.Ignite.exe file (Apache.Ignite project -> right-click -> Properties -> Build -> Output path)
+ /// Apache.Ignite.exe -IgniteHome=[path_to_IGNITE_HOME] -springConfigUrl=modules\platform\src\main\dotnet\examples\config\example-compute.xml -assembly=[path_to_Apache.Ignite.ExamplesDll.dll]
+ /// <para />
+ /// To run the example please do the following:
+ /// 1) Build the project Apache.Ignite.ExamplesDll (select it -> right-click -> Build);
+ /// 2) Set this class as startup object (Apache.Ignite.Examples project -> right-click -> Properties ->
+ /// Application -> Startup object);
+ /// 3) Start application (F5 or Ctrl+F5).
+ /// <para />
+ /// As a result you will see console messages output on all nodes.
+ /// </summary>
+ public class MessagingExample
+ {
+ /// <summary>
+ /// Runs the example.
+ /// </summary>
+ [STAThread]
+ public static void Main()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ SpringConfigUrl = @"modules\platform\src\main\dotnet\examples\config\example-compute.xml",
+ JvmOptions = new List<string> { "-Xms512m", "-Xmx1024m" }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var remotes = ignite.GetCluster().ForRemotes();
+
+ if (remotes.GetNodes().Count == 0)
+ {
+ Console.WriteLine(">>> This example requires remote nodes to be started.");
+ Console.WriteLine(">>> Please start at least 1 remote node.");
+ Console.WriteLine(">>> Refer to example's documentation for details on configuration.");
+ }
+ else
+ {
+ Console.WriteLine(">>> Messaging example started.");
+ Console.WriteLine();
+
+ // Set up local listeners
+ var localMessaging = ignite.GetCluster().ForLocal().GetMessaging();
+
+ var msgCount = remotes.GetNodes().Count * 10;
+
+ var orderedCounter = new CountdownEvent(msgCount);
+ var unorderedCounter = new CountdownEvent(msgCount);
+
+ localMessaging.LocalListen(new LocalListener(unorderedCounter), Topic.Unordered);
+ localMessaging.LocalListen(new LocalListener(orderedCounter), Topic.Ordered);
+
+ // Set up remote listeners
+ var remoteMessaging = remotes.GetMessaging();
+
+ remoteMessaging.RemoteListen(new RemoteUnorderedListener(), Topic.Unordered);
+ remoteMessaging.RemoteListen(new RemoteOrderedListener(), Topic.Ordered);
+
+ // Send unordered
+ Console.WriteLine(">>> Sending unordered messages...");
+
+ for (var i = 0; i < 10; i++)
+ remoteMessaging.Send(i, Topic.Unordered);
+
+ Console.WriteLine(">>> Finished sending unordered messages.");
+
+ // Send ordered
+ Console.WriteLine(">>> Sending ordered messages...");
+
+ for (var i = 0; i < 10; i++)
+ remoteMessaging.SendOrdered(i, Topic.Ordered);
+
+ Console.WriteLine(">>> Finished sending ordered messages.");
+
+ Console.WriteLine(">>> Check output on all nodes for message printouts.");
+ Console.WriteLine(">>> Waiting for messages acknowledgements from all remote nodes...");
+
+ unorderedCounter.Wait();
+ orderedCounter.Wait();
+ }
+ }
+
+ Console.WriteLine();
+ Console.WriteLine(">>> Example finished, press any key to exit ...");
+ Console.ReadKey();
+ }
+ }
+}