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:29 UTC
[2/3] ignite git commit: IGNITE-1496: Added .Net examples.
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>