Repository: ignite Updated Branches: refs/heads/master f337f142b -> 11881782b
IGNITE-5170 .NET: Compute peer deployment example This closes #2104 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/11881782 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/11881782 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/11881782 Branch: refs/heads/master Commit: 11881782b6aa1d45bfa541b2edf077672f1e5447 Parents: f337f14 Author: Pavel Tupitsyn <[email protected]> Authored: Tue Jun 13 16:03:58 2017 +0300 Committer: Pavel Tupitsyn <[email protected]> Committed: Tue Jun 13 16:03:58 2017 +0300 ---------------------------------------------------------------------- .../Examples/ExamplesTest.cs | 13 ++- .../NuGet/LINQPad/BinaryModeExample.linq | 1 + .../NuGet/LINQPad/ComputeExample.linq | 17 +++- .../NuGet/LINQPad/PutGetExample.linq | 1 + .../NuGet/LINQPad/QueryExample.linq | 1 + .../NuGet/LINQPad/QueryExample.linq | 1 + .../Apache.Ignite.Examples.csproj | 1 + .../examples/Apache.Ignite.Examples/App.config | 3 +- .../Compute/PeerAssemblyLoadingExample.cs | 96 ++++++++++++++++++++ .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- 11 files changed, 132 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs index 9389185..edc95fa 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs @@ -41,7 +41,16 @@ namespace Apache.Ignite.Core.Tests.Examples }; /** */ - private static readonly string[] NoDllExamples = { "BinaryModeExample", "NearCacheExample" }; + private static readonly string[] RemoteOnlyExamples = + { + "PeerAssemblyLoadingExample", "MessagingExample", "NearCacheExample" + }; + + /** */ + private static readonly string[] NoDllExamples = + { + "BinaryModeExample", "NearCacheExample", "PeerAssemblyLoadingExample" + }; /** Config file path. */ private string _configPath; @@ -210,7 +219,7 @@ namespace Apache.Ignite.Core.Tests.Examples // ReSharper disable once MemberCanBeMadeStatic.Global public IEnumerable<Example> TestCasesLocal { - get { return AllExamples.Where(x => x.Name != "NearCacheExample"); } + get { return AllExamples.Where(x => !RemoteOnlyExamples.Contains(x.Name)); } } /// <summary> http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq index b90402d..2220650 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/BinaryModeExample.linq @@ -28,6 +28,7 @@ /// /// Requirements: /// * Java Runtime Environment (JRE): http://www.oracle.com/technetwork/java/javase/downloads/index.html (x86 for regular LINQPad, x64 for AnyCPU LINQPad) +/// * Microsoft Visual C++ 2010 Redistributable Package: http://www.microsoft.com/en-us/download/details.aspx?id=14632 (x86 for regular LINQPad, x64 for AnyCPU LINQPad) /// </summary> // Force new LINQPad query process to reinit JVM. http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/ComputeExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/ComputeExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/ComputeExample.linq index 6886ddb..75823d1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/ComputeExample.linq +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/ComputeExample.linq @@ -29,15 +29,30 @@ /// /// Requirements: /// * Java Runtime Environment (JRE): http://www.oracle.com/technetwork/java/javase/downloads/index.html (x86 for regular LINQPad, x64 for AnyCPU LINQPad) +/// * Microsoft Visual C++ 2010 Redistributable Package: http://www.microsoft.com/en-us/download/details.aspx?id=14632 (x86 for regular LINQPad, x64 for AnyCPU LINQPad) /// </summary> void Main() { // Force new LINQPad query process to reinit JVM Util.NewProcess = true; + + // Enable peer assembly loading. + // This example can be run with standalone nodes started with Apache.Ignite.exe. + // To download and start a standalone node from NuGet: + // 1) > nuget install Apache.Ignite + // 2) > cd Apache.Ignite*\lib\net40 + // 3) Enable peer assembly loading in Apache.Ignite.exe.config: + // <igniteConfiguration peerAssemblyLoadingMode='CurrentAppDomain'> + // 4) Run Apache.Ignite.exe (one or more times) + // 5) Start this example, check output in the standalone node`s console + var cfg = new IgniteConfiguration + { + PeerAssemblyLoadingMode = PeerAssemblyLoadingMode.CurrentAppDomain + }; // Start instance - using (var ignite = Ignition.Start()) + using (var ignite = Ignition.Start(cfg)) { // Split the string by spaces to count letters in each word in parallel. var words = "Count characters using closure".Split(); http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/PutGetExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/PutGetExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/PutGetExample.linq index ea396da..ef37a3c 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/PutGetExample.linq +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/PutGetExample.linq @@ -28,6 +28,7 @@ /// /// Requirements: /// * Java Runtime Environment (JRE): http://www.oracle.com/technetwork/java/javase/downloads/index.html (x86 for regular LINQPad, x64 for AnyCPU LINQPad) +/// * Microsoft Visual C++ 2010 Redistributable Package: http://www.microsoft.com/en-us/download/details.aspx?id=14632 (x86 for regular LINQPad, x64 for AnyCPU LINQPad) /// </summary> void Main() http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq index 8a7dd10..19d55a3 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq +++ b/modules/platforms/dotnet/Apache.Ignite.Core/NuGet/LINQPad/QueryExample.linq @@ -31,6 +31,7 @@ /// /// Requirements: /// * Java Runtime Environment (JRE): http://www.oracle.com/technetwork/java/javase/downloads/index.html (x86 for regular LINQPad, x64 for AnyCPU LINQPad) +/// * Microsoft Visual C++ 2010 Redistributable Package: http://www.microsoft.com/en-us/download/details.aspx?id=14632 (x86 for regular LINQPad, x64 for AnyCPU LINQPad) /// </summary> void Main() http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/Apache.Ignite.Linq/NuGet/LINQPad/QueryExample.linq ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/NuGet/LINQPad/QueryExample.linq b/modules/platforms/dotnet/Apache.Ignite.Linq/NuGet/LINQPad/QueryExample.linq index fb44b12..7e82e22 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Linq/NuGet/LINQPad/QueryExample.linq +++ b/modules/platforms/dotnet/Apache.Ignite.Linq/NuGet/LINQPad/QueryExample.linq @@ -32,6 +32,7 @@ /// /// Requirements: /// * Java Runtime Environment (JRE): http://www.oracle.com/technetwork/java/javase/downloads/index.html (x86 for regular LINQPad, x64 for AnyCPU LINQPad) +/// * Microsoft Visual C++ 2010 Redistributable Package: http://www.microsoft.com/en-us/download/details.aspx?id=14632 (x86 for regular LINQPad, x64 for AnyCPU LINQPad) /// </summary> void Main() http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj index c3ea378..3206457 100644 --- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj +++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj @@ -54,6 +54,7 @@ <ItemGroup> <Compile Include="Compute\ClosureExample.cs" /> <Compile Include="Compute\TaskExample.cs" /> + <Compile Include="Compute\PeerAssemblyLoadingExample.cs" /> <Compile Include="Datagrid\ContinuousQueryExample.cs" /> <Compile Include="Datagrid\DataStreamerExample.cs" /> <Compile Include="Datagrid\MultiTieredCacheExample.cs" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config index ffec1ec..8f78382 100644 --- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config +++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config @@ -26,7 +26,8 @@ <gcServer enabled="true" /> </runtime> - <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection" localhost="127.0.0.1"> + <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection" + localhost="127.0.0.1" peerAssemblyLoadingMode="CurrentAppDomain"> <atomicConfiguration atomicSequenceReserveSize="10" /> <discoverySpi type="TcpDiscoverySpi"> http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/PeerAssemblyLoadingExample.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/PeerAssemblyLoadingExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/PeerAssemblyLoadingExample.cs new file mode 100644 index 0000000..868e40f --- /dev/null +++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Compute/PeerAssemblyLoadingExample.cs @@ -0,0 +1,96 @@ +/* + * 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.Examples.Compute +{ + using System; + using Apache.Ignite.Core; + using Apache.Ignite.Core.Compute; + + /// <summary> + /// Example demonstrating compute execution with peer assembly loading. + /// + /// Before executing the example start one or more standalone Apache Ignite.NET nodes without "-assembly" + /// command line argument. That argument is not required on remote nodes because the assemblies are + /// loaded automatically whenever is needed. + /// + /// Modify and re-run this example while keeping standalone nodes running to see that the + /// modified version of the computation will be executed because of automatic deployment of the updated assembly. + /// + /// Version is updated automatically on build because of '*' in AssemblyVersion (see AssemblyInfo.cs). + /// <para /> + /// 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 example (F5 or Ctrl+F5). + /// <para /> + /// This example must be run with standalone Apache Ignite.NET node: + /// 1) Run %IGNITE_HOME%/platforms/dotnet/bin/Apache.Ignite.exe: + /// Apache.Ignite.exe -configFileName=platforms\dotnet\examples\apache.ignite.examples\app.config + /// 2) Start example. + /// </summary> + public class PeerAssemblyLoadingExample + { + /// <summary> + /// Runs the example. + /// </summary> + [STAThread] + public static void Main() + { + using (var ignite = Ignition.StartFromApplicationConfiguration()) + { + Console.WriteLine(); + Console.WriteLine(">>> Peer loading example started."); + + var remotes = ignite.GetCluster().ForRemotes(); + + if (remotes.GetNodes().Count == 0) + { + throw new Exception("This example requires remote nodes to be started. " + + "Please start at least 1 remote node. " + + "Refer to example's documentation for details on configuration."); + } + + Console.WriteLine(">>> Executing an action on all remote nodes..."); + + // Execute action on all remote cluster nodes. + remotes.GetCompute().Broadcast(new HelloAction()); + + Console.WriteLine(">>> Action executed, check output on remote nodes."); + } + + Console.WriteLine(); + Console.WriteLine(">>> Example finished, press any key to exit ..."); + Console.ReadKey(); + } + + /// <summary> + /// Compute action that prints a greeting and assembly version. + /// </summary> + private class HelloAction : IComputeAction + { + /// <summary> + /// Invokes action. + /// </summary> + public void Invoke() + { + Console.WriteLine("Hello from automatically deployed assembly! Version is " + + GetType().Assembly.GetName().Version); + } + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs index a87a8e0..73fd822 100644 --- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs @@ -31,6 +31,4 @@ using System.Runtime.InteropServices; [assembly: Guid("41a0cb95-3435-4c78-b867-900b28e2c9ee")] -[assembly: AssemblyVersion("2.1.0.19388")] -[assembly: AssemblyFileVersion("2.1.0.19388")] -[assembly: AssemblyInformationalVersion("2.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.*")] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/11881782/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs index 1e9dcc8..cc42a9c 100644 --- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs @@ -31,6 +31,4 @@ using System.Runtime.InteropServices; [assembly: Guid("ce65ec7c-d3cf-41ad-8f45-f90d5af68d77")] -[assembly: AssemblyVersion("2.1.0.19388")] -[assembly: AssemblyFileVersion("2.1.0.19388")] -[assembly: AssemblyInformationalVersion("2.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.*")] \ No newline at end of file
