ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [33/37] ignite git commit: IGNITE-1513: WIP on .Net.
Date Tue, 22 Sep 2015 07:19:35 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
new file mode 100644
index 0000000..12c9992
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
@@ -0,0 +1,217 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Threading;
+    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Tests.Process;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Base class for all task-related tests.
+    /// </summary>
+    public abstract class AbstractTaskTest
+    {
+        /** */
+        protected const string Grid1Name = "grid1";
+
+        /** */
+        protected const string Grid2Name = "grid2";
+
+        /** */
+        protected const string Grid3Name = "grid3";
+
+        /** */
+        protected const string Cache1Name = "cache1";
+
+        /** Whether this is a test with forked JVMs. */
+        private readonly bool _fork;
+
+        /** First node. */
+        [NonSerialized]
+        protected IIgnite Grid1;
+
+        /** Second node. */
+        [NonSerialized]
+        private IIgnite _grid2;
+
+        /** Third node. */
+        [NonSerialized]
+        private IIgnite _grid3;
+
+        /** Second process. */
+        [NonSerialized]
+        private IgniteProcess _proc2;
+
+        /** Third process. */
+        [NonSerialized]
+        private IgniteProcess _proc3;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="fork">Fork flag.</param>
+        protected AbstractTaskTest(bool fork)
+        {
+            _fork = fork;
+        }
+
+        /// <summary>
+        /// Initialization routine.
+        /// </summary>
+        [TestFixtureSetUp]
+        public void InitClient()
+        {
+            TestUtils.KillProcesses();
+
+            if (_fork)
+            {
+                Grid1 = Ignition.Start(Configuration("config\\compute\\compute-standalone.xml"));
+
+                _proc2 = Fork("config\\compute\\compute-standalone.xml");
+
+                while (true)
+                {
+                    if (!_proc2.Alive)
+                        throw new Exception("Process 2 died unexpectedly: " + _proc2.Join());
+
+                    if (Grid1.GetCluster().GetNodes().Count < 2)
+                        Thread.Sleep(100);
+                    else
+                        break;
+                }
+
+                _proc3 = Fork("config\\compute\\compute-standalone.xml");
+
+                while (true)
+                {
+                    if (!_proc3.Alive)
+                        throw new Exception("Process 3 died unexpectedly: " + _proc3.Join());
+
+                    if (Grid1.GetCluster().GetNodes().Count < 3)
+                        Thread.Sleep(100);
+                    else
+                        break;
+                }
+            }
+            else
+            {
+                Grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
+                _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+                _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
+            }
+        }
+
+        [SetUp]
+        public void BeforeTest()
+        {
+            Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
+        }
+
+        [TestFixtureTearDown]
+        public void StopClient()
+        {
+            if (Grid1 != null)
+                Ignition.Stop(Grid1.Name, true);
+
+            if (_fork)
+            {
+                if (_proc2 != null) {
+                    _proc2.Kill();
+
+                    _proc2.Join();
+                }
+
+                if (_proc3 != null)
+                {
+                    _proc3.Kill();
+
+                    _proc3.Join();
+                }
+            }
+            else
+            {
+                if (_grid2 != null)
+                    Ignition.Stop(_grid2.Name, true);
+
+                if (_grid3 != null)
+                    Ignition.Stop(_grid3.Name, true);
+            }
+        }
+
+        /// <summary>
+        /// Configuration for node.
+        /// </summary>
+        /// <param name="path">Path to Java XML configuration.</param>
+        /// <returns>Node configuration.</returns>
+        protected IgniteConfiguration Configuration(string path)
+        {
+            IgniteConfiguration cfg = new IgniteConfiguration();
+
+            if (!_fork)
+            {
+                PortableConfiguration portCfg = new PortableConfiguration();
+
+                ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+
+                PortableTypeConfigurations(portTypeCfgs);
+
+                portCfg.TypeConfigurations = portTypeCfgs;
+
+                cfg.PortableConfiguration = portCfg;
+            }
+
+            cfg.JvmClasspath = TestUtils.CreateTestClasspath();
+
+            cfg.JvmOptions = TestUtils.TestJavaOptions();
+
+            cfg.SpringConfigUrl = path;
+
+            return cfg;
+        }
+
+        /// <summary>
+        /// Create forked process with the following Spring config.
+        /// </summary>
+        /// <param name="path">Path to Java XML configuration.</param>
+        /// <returns>Forked process.</returns>
+        private static IgniteProcess Fork(string path)
+        {
+            return new IgniteProcess(
+                "-springConfigUrl=" + path,
+                "-J-ea",
+                "-J-Xcheck:jni",
+                "-J-Xms512m",
+                "-J-Xmx512m",
+                "-J-DIGNITE_QUIET=false"
+                //"-J-Xnoagent", "-J-Djava.compiler=NONE", "-J-Xdebug", "-J-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006"
+            );
+        }
+
+        /// <summary>
+        /// Define portable types.
+        /// </summary>
+        /// <param name="portTypeCfgs">Portable type configurations.</param>
+        protected virtual void PortableTypeConfigurations(ICollection<PortableTypeConfiguration> portTypeCfgs)
+        {
+            // No-op.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
new file mode 100644
index 0000000..8664413
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
@@ -0,0 +1,390 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Compute;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests for distributed closure executions.
+    /// </summary>
+    public abstract class ClosureTaskTest : AbstractTaskTest
+    {
+        /** Amount of multiple clousres. */
+        private const int MultiCloCnt = 5;
+
+        /** */
+        protected const string ErrMsg = "An error has occurred.";
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        /// <param name="fork">Fork mode.</param>
+        protected ClosureTaskTest(bool fork) : base(fork) { }
+
+        /// <summary>
+        /// Test for single closure returning result.
+        /// </summary>
+        [Test]
+        public void TestExecuteSingle()
+        {
+            var res = Grid1.GetCompute().Call(OutFunc(false));
+
+            CheckResult(res);
+        }
+
+        /// <summary>
+        /// Test for single closure returning exception.
+        /// </summary>
+        [Test]
+        public void TestExecuteSingleException()
+        {
+            try
+            {
+                Grid1.GetCompute().Call(OutFunc(true));
+
+                Assert.Fail();
+            }
+            catch (Exception e)
+            {
+                CheckError(e);
+            }
+        }
+
+        /// <summary>
+        /// Test for multiple closures execution.
+        /// </summary>
+        [Test]
+        public void TestExecuteMultiple()
+        {
+            var clos = new List<IComputeFunc<object>>(MultiCloCnt);
+
+            for (int i = 0; i < MultiCloCnt; i++)
+                clos.Add(OutFunc(false));
+
+            ICollection<object> ress = Grid1.GetCompute().Call(clos);
+
+            foreach (object res in ress)
+                CheckResult(res);
+        }
+
+        /// <summary>
+        /// Test for multiple closures execution.
+        /// </summary>
+        [Test]
+        public void TestExecuteMultipleReduced()
+        {
+            var clos = new List<IComputeFunc<object>>(MultiCloCnt);
+
+            for (int i = 0; i < MultiCloCnt; i++)
+                clos.Add(OutFunc(false));
+
+            ICollection<object> ress = Grid1.GetCompute().Call(clos, new Reducer(false));
+
+            foreach (object res in ress)
+                CheckResult(res);
+        }
+
+        /// <summary>
+        /// Test for multiple closures execution with exceptions thrown from some of them.
+        /// </summary>
+        [Test]
+        public void TestExecuteMultipleException()
+        {
+            var clos = new List<IComputeFunc<object>>(MultiCloCnt);
+
+            for (int i = 0; i < MultiCloCnt; i++)
+                clos.Add(OutFunc(i % 2 == 0)); // Some closures will be faulty.
+
+            try
+            {
+                Grid1.GetCompute().Call(clos);
+
+                Assert.Fail();
+            }
+            catch (Exception e)
+            {
+                CheckError(e);
+            }
+        }
+
+        /// <summary>
+        /// Test broadcast out-closure execution.
+        /// </summary>
+        [Test]
+        public void TestBroadcastOut()
+        {
+            ICollection<object> ress = Grid1.GetCompute().Broadcast(OutFunc(false));
+
+            foreach (object res in ress)
+                CheckResult(res);
+        }
+
+        /// <summary>
+        /// Test broadcast out-closure execution with exception.
+        /// </summary>
+        [Test]
+        public void TestBroadcastOutException()
+        {
+            try
+            {
+                Grid1.GetCompute().Broadcast(OutFunc(true));
+
+                Assert.Fail();
+            }
+            catch (Exception e)
+            {
+                CheckError(e);
+            }
+        }
+
+        /// <summary>
+        /// Test broadcast in-out-closure execution.
+        /// </summary>
+        [Test]
+        public void TestBroadcastInOut()
+        {
+            ICollection<object> ress = Grid1.GetCompute().Broadcast(Func(false), 1);
+
+            foreach (object res in ress)
+                CheckResult(res);
+        }
+
+        /// <summary>
+        /// Test broadcast in-out-closure execution with exception.
+        /// </summary>
+        [Test]
+        public void TestBroadcastInOutException()
+        {
+            try
+            {
+                Grid1.GetCompute().Broadcast(Func(true), 1);
+
+                Assert.Fail();
+            }
+            catch (Exception e)
+            {
+                CheckError(e);
+            }
+        }
+
+        /// <summary>
+        /// Test apply in-out-closure execution.
+        /// </summary>
+        [Test]
+        public void TestApply()
+        {
+            object res = Grid1.GetCompute().Apply(Func(false), 1);
+
+            CheckResult(res);
+        }
+
+        /// <summary>
+        /// Test apply in-out-closure execution with exception.
+        /// </summary>
+        [Test]
+        public void TestApplyException()
+        {
+            try
+            {
+                Grid1.GetCompute().Apply(Func(true), 1);
+
+                Assert.Fail();
+            }
+            catch (Exception e)
+            {
+                CheckError(e);
+            }
+        }
+
+        /// <summary>
+        /// Test apply multiple in-out-closures execution.
+        /// </summary>
+        [Test]
+        public void TestApplyMultiple()
+        {
+            var args = new List<object>(MultiCloCnt);
+
+            for (int i = 0; i < MultiCloCnt; i++)
+                args.Add(1);
+
+            Console.WriteLine("START TASK");
+
+            var ress = Grid1.GetCompute().Apply(Func(false), args);
+
+            Console.WriteLine("END TASK.");
+
+            foreach (object res in ress)
+                CheckResult(res);
+        }
+
+        /// <summary>
+        /// Test apply multiple in-out-closures execution with exception.
+        /// </summary>
+        [Test]
+        public void TestApplyMultipleException()
+        {
+            ICollection<int> args = new List<int>(MultiCloCnt);
+
+            for (int i = 0; i < MultiCloCnt; i++)
+                args.Add(1);
+
+            try
+            {
+                Grid1.GetCompute().Apply(Func(true), args);
+
+                Assert.Fail();
+            }
+            catch (Exception e)
+            {
+                CheckError(e);
+            }
+        }
+
+        /// <summary>
+        /// Test apply multiple in-out-closures execution with reducer.
+        /// </summary>
+        [Test]
+        public void TestApplyMultipleReducer()
+        {
+            var args = new List<object>(MultiCloCnt);
+
+            for (int i = 0; i < MultiCloCnt; i++)
+                args.Add(1);
+
+            ICollection<object> ress =
+                Grid1.GetCompute().Apply(Func(false), args, new Reducer(false));
+
+            foreach (object res in ress)
+                CheckResult(res);
+        }
+
+        /// <summary>
+        /// Test apply multiple in-out-closures execution with reducer and exception thrown from closure.
+        /// </summary>
+        [Test]
+        public void TestAppylMultipleReducerJobException()
+        {
+            List<object> args = new List<object>(MultiCloCnt);
+
+            for (int i = 0; i < MultiCloCnt; i++)
+                args.Add(1);
+
+            try
+            {
+                Grid1.GetCompute().Apply(Func(true), args, new Reducer(false));
+
+                Assert.Fail();
+            }
+            catch (Exception e)
+            {
+                CheckError(e);
+            }
+        }
+
+        /// <summary>
+        /// Test apply multiple in-out-closures execution with reducer and exception thrown from reducer.
+        /// </summary>
+        [Test]
+        public void TestAppylMultipleReducerReduceException()
+        {
+            var args = new List<object>(MultiCloCnt);
+
+            for (int i = 0; i < MultiCloCnt; i++)
+                args.Add(1);
+
+            try
+            {
+                Grid1.GetCompute().Apply(Func(false), args, new Reducer(true));
+
+                Assert.Fail();
+            }
+            catch (Exception e)
+            {
+                Assert.AreEqual(typeof(Exception), e.GetType());
+
+                Assert.AreEqual(ErrMsg, e.Message);
+            }
+        }
+
+        /// <summary>
+        /// Create out-only closure.
+        /// </summary>
+        /// <param name="err">Error flag.</param>
+        /// <returns>Closure.</returns>
+        protected abstract IComputeFunc<object> OutFunc(bool err);
+
+        /// <summary>
+        /// Create in-out closure.
+        /// </summary>
+        /// <param name="err">Error flag.</param>
+        /// <returns>Closure.</returns>
+        protected abstract IComputeFunc<object, object> Func(bool err);
+
+        /// <summary>
+        /// Check result.
+        /// </summary>
+        /// <param name="res">Result.</param>
+        protected abstract void CheckResult(object res);
+
+        /// <summary>
+        /// Check error.
+        /// </summary>
+        /// <param name="err">Error.</param>
+        protected abstract void CheckError(Exception err);
+
+        /// <summary>
+        /// Test reducer.
+        /// </summary>
+        public class Reducer : IComputeReducer<object, ICollection<object>>
+        {
+            /** Whether to throw an error on reduce. */
+            private readonly bool _err;
+
+            /** Results. */
+            private readonly ICollection<object> _ress = new List<object>();
+
+            /// <summary>
+            /// Constructor.
+            /// </summary>
+            /// <param name="err">Error.</param>
+            public Reducer(bool err)
+            {
+                _err = err;
+            }
+
+            /** <inheritDoc /> */
+            public bool Collect(object res)
+            {
+                _ress.Add(res);
+
+                return true;
+            }
+
+            /** <inheritDoc /> */
+            public ICollection<object> Reduce()
+            {
+                if (_err)
+                    throw new Exception(ErrMsg);
+                return _ress;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
new file mode 100644
index 0000000..039813b
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -0,0 +1,1281 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ReSharper disable SpecifyACultureInStringConversionExplicitly
+namespace Apache.Ignite.Core.Tests.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using System.Threading;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Common;
+    using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl;
+    using Apache.Ignite.Core.Portable;
+    using Apache.Ignite.Core.Resource;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests for compute.
+    /// </summary>
+    public class ComputeApiTest
+    {
+        /** Echo task name. */
+        private const string EchoTask = "org.apache.ignite.platform.PlatformComputeEchoTask";
+
+        /** Portable argument task name. */
+        private const string PortableArgTask = "org.apache.ignite.platform.PlatformComputePortableArgTask";
+
+        /** Broadcast task name. */
+        private const string BroadcastTask = "org.apache.ignite.platform.PlatformComputeBroadcastTask";
+
+        /** Broadcast task name. */
+        private const string DecimalTask = "org.apache.ignite.platform.PlatformComputeDecimalTask";
+
+        /** Java portable class name. */
+        private const string JavaPortableCls = "GridInteropComputeJavaPortable";
+
+        /** Echo type: null. */
+        private const int EchoTypeNull = 0;
+
+        /** Echo type: byte. */
+        private const int EchoTypeByte = 1;
+
+        /** Echo type: bool. */
+        private const int EchoTypeBool = 2;
+
+        /** Echo type: short. */
+        private const int EchoTypeShort = 3;
+
+        /** Echo type: char. */
+        private const int EchoTypeChar = 4;
+
+        /** Echo type: int. */
+        private const int EchoTypeInt = 5;
+
+        /** Echo type: long. */
+        private const int EchoTypeLong = 6;
+
+        /** Echo type: float. */
+        private const int EchoTypeFloat = 7;
+
+        /** Echo type: double. */
+        private const int EchoTypeDouble = 8;
+
+        /** Echo type: array. */
+        private const int EchoTypeArray = 9;
+
+        /** Echo type: collection. */
+        private const int EchoTypeCollection = 10;
+
+        /** Echo type: map. */
+        private const int EchoTypeMap = 11;
+
+        /** Echo type: portable. */
+        private const int EchoTypePortable = 12;
+
+        /** Echo type: portable (Java only). */
+        private const int EchoTypePortableJava = 13;
+
+        /** Type: object array. */
+        private const int EchoTypeObjArray = 14;
+
+        /** Type: portable object array. */
+        private const int EchoTypePortableArray = 15;
+
+        /** Type: enum. */
+        private const int EchoTypeEnum = 16;
+
+        /** Type: enum array. */
+        private const int EchoTypeEnumArray = 17;
+
+        /** First node. */
+        private IIgnite _grid1;
+
+        /** Second node. */
+        private IIgnite _grid2;
+
+        /** Third node. */
+        private IIgnite _grid3;
+
+        /// <summary>
+        /// Initialization routine.
+        /// </summary>
+        [TestFixtureSetUp]
+        public void InitClient()
+        {
+            //TestUtils.JVM_DEBUG = true;
+            TestUtils.KillProcesses();
+
+            _grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
+            _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+            _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
+        }
+
+        [TestFixtureTearDown]
+        public void StopClient()
+        {
+            if (_grid1 != null)
+                Ignition.Stop(_grid1.Name, true);
+
+            if (_grid2 != null)
+                Ignition.Stop(_grid2.Name, true);
+
+            if (_grid3 != null)
+                Ignition.Stop(_grid3.Name, true);
+        }
+
+        [TearDown]
+        public void AfterTest()
+        {
+            TestUtils.AssertHandleRegistryIsEmpty(1000, _grid1, _grid2, _grid3);
+        }
+
+        /// <summary>
+        /// Test that it is possible to get projection from grid.
+        /// </summary>
+        [Test]
+        public void TestProjection()
+        {
+            IClusterGroup prj = _grid1.GetCluster();
+
+            Assert.NotNull(prj);
+
+            Assert.IsTrue(prj == prj.Ignite);
+        }
+
+        /// <summary>
+        /// Test getting cache with default (null) name.
+        /// </summary>
+        [Test]
+        public void TestCacheDefaultName()
+        {
+            var cache = _grid1.GetCache<int, int>(null);
+
+            Assert.IsNotNull(cache);
+
+            cache.GetAndPut(1, 1);
+
+            Assert.AreEqual(1, cache.Get(1));
+        }
+
+        /// <summary>
+        /// Test non-existent cache.
+        /// </summary>
+        [Test]
+        public void TestNonExistentCache()
+        {
+            Assert.Catch(typeof(ArgumentException), () =>
+            {
+                _grid1.GetCache<int, int>("bad_name");
+            });
+        }
+
+        /// <summary>
+        /// Test node content.
+        /// </summary>
+        [Test]
+        public void TestNodeContent()
+        {
+            ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+            foreach (IClusterNode node in nodes)
+            {
+                Assert.NotNull(node.Addresses);
+                Assert.IsTrue(node.Addresses.Count > 0);
+                Assert.Throws<NotSupportedException>(() => node.Addresses.Add("addr"));
+
+                Assert.NotNull(node.GetAttributes());
+                Assert.IsTrue(node.GetAttributes().Count > 0);
+                Assert.Throws<NotSupportedException>(() => node.GetAttributes().Add("key", "val"));
+
+                Assert.NotNull(node.HostNames);
+                Assert.Throws<NotSupportedException>(() => node.HostNames.Add("h"));
+
+                Assert.IsTrue(node.Id != Guid.Empty);
+
+                Assert.IsTrue(node.Order > 0);
+
+                Assert.NotNull(node.GetMetrics());
+            }
+        }
+
+        /// <summary>
+        /// Test cluster metrics.
+        /// </summary>
+        [Test]
+        public void TestClusterMetrics()
+        {
+            var cluster = _grid1.GetCluster();
+
+            IClusterMetrics metrics = cluster.GetMetrics();
+
+            Assert.IsNotNull(metrics);
+
+            Assert.AreEqual(cluster.GetNodes().Count, metrics.TotalNodes);
+
+            Thread.Sleep(2000);
+
+            IClusterMetrics newMetrics = cluster.GetMetrics();
+
+            Assert.IsFalse(metrics == newMetrics);
+            Assert.IsTrue(metrics.LastUpdateTime < newMetrics.LastUpdateTime);
+        }
+
+        /// <summary>
+        /// Test cluster metrics.
+        /// </summary>
+        [Test]
+        public void TestNodeMetrics()
+        {
+            var node = _grid1.GetCluster().GetNode();
+
+            IClusterMetrics metrics = node.GetMetrics();
+
+            Assert.IsNotNull(metrics);
+
+            Assert.IsTrue(metrics == node.GetMetrics());
+
+            Thread.Sleep(2000);
+
+            IClusterMetrics newMetrics = node.GetMetrics();
+
+            Assert.IsFalse(metrics == newMetrics);
+            Assert.IsTrue(metrics.LastUpdateTime < newMetrics.LastUpdateTime);
+        }
+
+        /// <summary>
+        /// Test cluster metrics.
+        /// </summary>
+        [Test]
+        public void TestResetMetrics()
+        {
+            var cluster = _grid1.GetCluster();
+
+            Thread.Sleep(2000);
+
+            var metrics1 = cluster.GetMetrics();
+
+            cluster.ResetMetrics();
+
+            var metrics2 = cluster.GetMetrics();
+
+            Assert.IsNotNull(metrics1);
+            Assert.IsNotNull(metrics2);
+        }
+
+        /// <summary>
+        /// Test node ping.
+        /// </summary>
+        [Test]
+        public void TestPingNode()
+        {
+            var cluster = _grid1.GetCluster();
+
+            Assert.IsTrue(cluster.GetNodes().Select(node => node.Id).All(cluster.PingNode));
+            
+            Assert.IsFalse(cluster.PingNode(Guid.NewGuid()));
+        }
+
+        /// <summary>
+        /// Tests the topology version.
+        /// </summary>
+        [Test]
+        public void TestTopologyVersion()
+        {
+            var cluster = _grid1.GetCluster();
+            
+            var topVer = cluster.TopologyVersion;
+
+            Ignition.Stop(_grid3.Name, true);
+
+            Assert.AreEqual(topVer + 1, _grid1.GetCluster().TopologyVersion);
+
+            _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
+
+            Assert.AreEqual(topVer + 2, _grid1.GetCluster().TopologyVersion);
+        }
+
+        /// <summary>
+        /// Tests the topology by version.
+        /// </summary>
+        [Test]
+        public void TestTopology()
+        {
+            var cluster = _grid1.GetCluster();
+
+            Assert.AreEqual(1, cluster.GetTopology(1).Count);
+
+            Assert.AreEqual(null, cluster.GetTopology(int.MaxValue));
+
+            // Check that Nodes and Topology return the same for current version
+            var topVer = cluster.TopologyVersion;
+
+            var top = cluster.GetTopology(topVer);
+
+            var nodes = cluster.GetNodes();
+
+            Assert.AreEqual(top.Count, nodes.Count);
+
+            Assert.IsTrue(top.All(nodes.Contains));
+
+            // Stop/start node to advance version and check that history is still correct
+            Assert.IsTrue(Ignition.Stop(_grid2.Name, true));
+
+            try
+            {
+                top = cluster.GetTopology(topVer);
+
+                Assert.AreEqual(top.Count, nodes.Count);
+
+                Assert.IsTrue(top.All(nodes.Contains));
+            }
+            finally 
+            {
+                _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+            }
+        }
+
+        /// <summary>
+        /// Test nodes in full topology.
+        /// </summary>
+        [Test]
+        public void TestNodes()
+        {
+            Assert.IsNotNull(_grid1.GetCluster().GetNode());
+
+            ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+            Assert.IsTrue(nodes.Count == 3);
+
+            // Check subsequent call on the same topology.
+            nodes = _grid1.GetCluster().GetNodes();
+
+            Assert.IsTrue(nodes.Count == 3);
+
+            Assert.IsTrue(Ignition.Stop(_grid2.Name, true));
+
+            // Check subsequent calls on updating topologies.
+            nodes = _grid1.GetCluster().GetNodes();
+
+            Assert.IsTrue(nodes.Count == 2);
+
+            nodes = _grid1.GetCluster().GetNodes();
+
+            Assert.IsTrue(nodes.Count == 2);
+
+            _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
+
+            nodes = _grid1.GetCluster().GetNodes();
+
+            Assert.IsTrue(nodes.Count == 3);
+        }
+
+        /// <summary>
+        /// Test "ForNodes" and "ForNodeIds".
+        /// </summary>
+        [Test]
+        public void TestForNodes()
+        {
+            ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+            IClusterNode first = nodes.ElementAt(0);
+            IClusterNode second = nodes.ElementAt(1);
+
+            IClusterGroup singleNodePrj = _grid1.GetCluster().ForNodeIds(first.Id);
+            Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
+            Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
+
+            singleNodePrj = _grid1.GetCluster().ForNodeIds(new List<Guid> { first.Id });
+            Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
+            Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
+
+            singleNodePrj = _grid1.GetCluster().ForNodes(first);
+            Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
+            Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
+
+            singleNodePrj = _grid1.GetCluster().ForNodes(new List<IClusterNode> { first });
+            Assert.AreEqual(1, singleNodePrj.GetNodes().Count);
+            Assert.AreEqual(first.Id, singleNodePrj.GetNodes().First().Id);
+
+            IClusterGroup multiNodePrj = _grid1.GetCluster().ForNodeIds(first.Id, second.Id);
+            Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
+            Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
+            Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
+
+            multiNodePrj = _grid1.GetCluster().ForNodeIds(new[] {first, second}.Select(x => x.Id));
+            Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
+            Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
+            Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
+
+            multiNodePrj = _grid1.GetCluster().ForNodes(first, second);
+            Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
+            Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
+            Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
+
+            multiNodePrj = _grid1.GetCluster().ForNodes(new List<IClusterNode> { first, second });
+            Assert.AreEqual(2, multiNodePrj.GetNodes().Count);
+            Assert.IsTrue(multiNodePrj.GetNodes().Contains(first));
+            Assert.IsTrue(multiNodePrj.GetNodes().Contains(second));
+        }
+
+        /// <summary>
+        /// Test "ForNodes" and "ForNodeIds". Make sure lazy enumerables are enumerated only once.
+        /// </summary>
+        [Test]
+        public void TestForNodesLaziness()
+        {
+            var nodes = _grid1.GetCluster().GetNodes().Take(2).ToArray();
+
+            var callCount = 0;
+            
+            Func<IClusterNode, IClusterNode> nodeSelector = node =>
+            {
+                callCount++;
+                return node;
+            };
+
+            Func<IClusterNode, Guid> idSelector = node =>
+            {
+                callCount++;
+                return node.Id;
+            };
+
+            var projection = _grid1.GetCluster().ForNodes(nodes.Select(nodeSelector));
+            Assert.AreEqual(2, projection.GetNodes().Count);
+            Assert.AreEqual(2, callCount);
+            
+            projection = _grid1.GetCluster().ForNodeIds(nodes.Select(idSelector));
+            Assert.AreEqual(2, projection.GetNodes().Count);
+            Assert.AreEqual(4, callCount);
+        }
+
+        /// <summary>
+        /// Test for local node projection.
+        /// </summary>
+        [Test]
+        public void TestForLocal()
+        {
+            IClusterGroup prj = _grid1.GetCluster().ForLocal();
+
+            Assert.AreEqual(1, prj.GetNodes().Count);
+            Assert.AreEqual(_grid1.GetCluster().GetLocalNode(), prj.GetNodes().First());
+        }
+
+        /// <summary>
+        /// Test for remote nodes projection.
+        /// </summary>
+        [Test]
+        public void TestForRemotes()
+        {
+            ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+            IClusterGroup prj = _grid1.GetCluster().ForRemotes();
+
+            Assert.AreEqual(2, prj.GetNodes().Count);
+            Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(0)));
+            Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(1)));
+        }
+
+        /// <summary>
+        /// Test for host nodes projection.
+        /// </summary>
+        [Test]
+        public void TestForHost()
+        {
+            ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+            IClusterGroup prj = _grid1.GetCluster().ForHost(nodes.First());
+
+            Assert.AreEqual(3, prj.GetNodes().Count);
+            Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(0)));
+            Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(1)));
+            Assert.IsTrue(nodes.Contains(prj.GetNodes().ElementAt(2)));
+        }
+
+        /// <summary>
+        /// Test for oldest, youngest and random projections.
+        /// </summary>
+        [Test]
+        public void TestForOldestYoungestRandom()
+        {
+            ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+            IClusterGroup prj = _grid1.GetCluster().ForYoungest();
+            Assert.AreEqual(1, prj.GetNodes().Count);
+            Assert.IsTrue(nodes.Contains(prj.GetNode()));
+
+            prj = _grid1.GetCluster().ForOldest();
+            Assert.AreEqual(1, prj.GetNodes().Count);
+            Assert.IsTrue(nodes.Contains(prj.GetNode()));
+
+            prj = _grid1.GetCluster().ForRandom();
+            Assert.AreEqual(1, prj.GetNodes().Count);
+            Assert.IsTrue(nodes.Contains(prj.GetNode()));
+        }
+
+        /// <summary>
+        /// Test for attribute projection.
+        /// </summary>
+        [Test]
+        public void TestForAttribute()
+        {
+            ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+            IClusterGroup prj = _grid1.GetCluster().ForAttribute("my_attr", "value1");
+            Assert.AreEqual(1, prj.GetNodes().Count);
+            Assert.IsTrue(nodes.Contains(prj.GetNode()));
+            Assert.AreEqual("value1", prj.GetNodes().First().GetAttribute<string>("my_attr"));
+        }
+        
+        /// <summary>
+        /// Test for cache/data/client projections.
+        /// </summary>
+        [Test]
+        public void TestForCacheNodes()
+        {
+            ICollection<IClusterNode> nodes = _grid1.GetCluster().GetNodes();
+
+            // Cache nodes.
+            IClusterGroup prjCache = _grid1.GetCluster().ForCacheNodes("cache1");
+
+            Assert.AreEqual(2, prjCache.GetNodes().Count);
+
+            Assert.IsTrue(nodes.Contains(prjCache.GetNodes().ElementAt(0)));
+            Assert.IsTrue(nodes.Contains(prjCache.GetNodes().ElementAt(1)));
+            
+            // Data nodes.
+            IClusterGroup prjData = _grid1.GetCluster().ForDataNodes("cache1");
+
+            Assert.AreEqual(2, prjData.GetNodes().Count);
+
+            Assert.IsTrue(prjCache.GetNodes().Contains(prjData.GetNodes().ElementAt(0)));
+            Assert.IsTrue(prjCache.GetNodes().Contains(prjData.GetNodes().ElementAt(1)));
+
+            // Client nodes.
+            IClusterGroup prjClient = _grid1.GetCluster().ForClientNodes("cache1");
+
+            Assert.AreEqual(0, prjClient.GetNodes().Count);
+        }
+        
+        /// <summary>
+        /// Test for cache predicate.
+        /// </summary>
+        [Test]
+        public void TestForPredicate()
+        {
+            IClusterGroup prj1 = _grid1.GetCluster().ForPredicate(new NotAttributePredicate("value1").Apply);
+            Assert.AreEqual(2, prj1.GetNodes().Count);
+
+            IClusterGroup prj2 = prj1.ForPredicate(new NotAttributePredicate("value2").Apply);
+            Assert.AreEqual(1, prj2.GetNodes().Count);
+
+            string val;
+
+            prj2.GetNodes().First().TryGetAttribute("my_attr", out val);
+
+            Assert.IsTrue(val == null || (!val.Equals("value1") && !val.Equals("value2")));
+        }
+
+        /// <summary>
+        /// Attribute predicate.
+        /// </summary>
+        private class NotAttributePredicate
+        {
+            /** Required attribute value. */
+            private readonly string _attrVal;
+
+            /// <summary>
+            /// Constructor.
+            /// </summary>
+            /// <param name="attrVal">Required attribute value.</param>
+            public NotAttributePredicate(string attrVal)
+            {
+                _attrVal = attrVal;
+            }
+
+            /** <inhreitDoc /> */
+            public bool Apply(IClusterNode node)
+            {
+                string val;
+
+                node.TryGetAttribute("my_attr", out val);
+
+                return val == null || !val.Equals(_attrVal);
+            }
+        }
+
+        /// <summary>
+        /// Test echo with decimals.
+        /// </summary>
+        [Test]
+        public void TestEchoDecimal()
+        {
+            decimal val;
+
+            Assert.AreEqual(val = decimal.Zero, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = new decimal(0, 0, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = new decimal(0, 1, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 1, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = new decimal(1, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = new decimal(1, 1, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 1, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = decimal.Parse("65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = decimal.Parse("4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = decimal.Parse("281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = decimal.Parse("18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = decimal.Parse("1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = decimal.MaxValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.MinValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.MaxValue - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.MinValue + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            Assert.AreEqual(val = decimal.Parse("11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+            Assert.AreEqual(val = decimal.Parse("-11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() }));
+
+            // Test echo with overflow.
+            try
+            {
+                _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { null, decimal.MaxValue.ToString() + 1 });
+
+                Assert.Fail();
+            }
+            catch (IgniteException)
+            {
+                // No-op.
+            }
+        }
+
+        /// <summary>
+        /// Test echo task returning null.
+        /// </summary>
+        [Test]
+        public void TestEchoTaskNull()
+        {
+            Assert.IsNull(_grid1.GetCompute().ExecuteJavaTask<object>(EchoTask, EchoTypeNull));
+        }
+
+        /// <summary>
+        /// Test echo task returning various primitives.
+        /// </summary>
+        [Test]
+        public void TestEchoTaskPrimitives()
+        {
+            Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<byte>(EchoTask, EchoTypeByte));
+            Assert.AreEqual(true, _grid1.GetCompute().ExecuteJavaTask<bool>(EchoTask, EchoTypeBool));
+            Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<short>(EchoTask, EchoTypeShort));
+            Assert.AreEqual((char)1, _grid1.GetCompute().ExecuteJavaTask<char>(EchoTask, EchoTypeChar));
+            Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<int>(EchoTask, EchoTypeInt));
+            Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<long>(EchoTask, EchoTypeLong));
+            Assert.AreEqual((float)1, _grid1.GetCompute().ExecuteJavaTask<float>(EchoTask, EchoTypeFloat));
+            Assert.AreEqual((double)1, _grid1.GetCompute().ExecuteJavaTask<double>(EchoTask, EchoTypeDouble));
+        }
+
+        /// <summary>
+        /// Test echo task returning compound types.
+        /// </summary>
+        [Test]
+        public void TestEchoTaskCompound()
+        {
+            int[] res1 = _grid1.GetCompute().ExecuteJavaTask<int[]>(EchoTask, EchoTypeArray);
+
+            Assert.AreEqual(1, res1.Length);
+            Assert.AreEqual(1, res1[0]);
+
+            IList<int> res2 = _grid1.GetCompute().ExecuteJavaTask<IList<int>>(EchoTask, EchoTypeCollection);
+
+            Assert.AreEqual(1, res2.Count);
+            Assert.AreEqual(1, res2[0]);
+
+            IDictionary<int, int> res3 = _grid1.GetCompute().ExecuteJavaTask<IDictionary<int, int>>(EchoTask, EchoTypeMap);
+
+            Assert.AreEqual(1, res3.Count);
+            Assert.AreEqual(1, res3[1]);
+        }
+
+        /// <summary>
+        /// Test echo task returning portable object.
+        /// </summary>
+        [Test]
+        public void TestEchoTaskPortable()
+        {
+            PlatformComputePortable res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputePortable>(EchoTask, EchoTypePortable);
+
+            Assert.AreEqual(1, res.Field);
+        }
+
+        /// <summary>
+        /// Test echo task returning portable object with no corresponding class definition.
+        /// </summary>
+        [Test]
+        public void TestEchoTaskPortableNoClass()
+        {
+            ICompute compute = _grid1.GetCompute();
+
+            compute.WithKeepPortable();
+
+            IPortableObject res = compute.ExecuteJavaTask<IPortableObject>(EchoTask, EchoTypePortableJava);
+
+            Assert.AreEqual(1, res.GetField<int>("field"));
+
+            // This call must fail because "keepPortable" flag is reset.
+            Assert.Catch(typeof(PortableException), () =>
+            {
+                compute.ExecuteJavaTask<IPortableObject>(EchoTask, EchoTypePortableJava);
+            });
+        }
+
+        /// <summary>
+        /// Tests the echo task returning object array.
+        /// </summary>
+        [Test]
+        public void TestEchoTaskObjectArray()
+        {
+            var res = _grid1.GetCompute().ExecuteJavaTask<string[]>(EchoTask, EchoTypeObjArray);
+            
+            Assert.AreEqual(new[] {"foo", "bar", "baz"}, res);
+        }
+
+        /// <summary>
+        /// Tests the echo task returning portable array.
+        /// </summary>
+        [Test]
+        public void TestEchoTaskPortableArray()
+        {
+            var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputePortable[]>(EchoTask, EchoTypePortableArray);
+            
+            Assert.AreEqual(3, res.Length);
+
+            for (var i = 0; i < res.Length; i++)
+                Assert.AreEqual(i + 1, res[i].Field);
+        }
+
+        /// <summary>
+        /// Tests the echo task returning enum.
+        /// </summary>
+        [Test]
+        public void TestEchoTaskEnum()
+        {
+            var res = _grid1.GetCompute().ExecuteJavaTask<InteropComputeEnum>(EchoTask, EchoTypeEnum);
+
+            Assert.AreEqual(InteropComputeEnum.Bar, res);
+        }
+
+        /// <summary>
+        /// Tests the echo task returning enum.
+        /// </summary>
+        [Test]
+        public void TestEchoTaskEnumArray()
+        {
+            var res = _grid1.GetCompute().ExecuteJavaTask<InteropComputeEnum[]>(EchoTask, EchoTypeEnumArray);
+
+            Assert.AreEqual(new[]
+            {
+                InteropComputeEnum.Bar,
+                InteropComputeEnum.Baz,
+                InteropComputeEnum.Foo
+            }, res);
+        }
+
+        /// <summary>
+        /// Test for portable argument in Java.
+        /// </summary>
+        [Test]
+        public void TestPortableArgTask()
+        {
+            ICompute compute = _grid1.GetCompute();
+
+            compute.WithKeepPortable();
+
+            PlatformComputeNetPortable arg = new PlatformComputeNetPortable();
+
+            arg.Field = 100;
+
+            int res = compute.ExecuteJavaTask<int>(PortableArgTask, arg);
+
+            Assert.AreEqual(arg.Field, res);
+        }
+
+        /// <summary>
+        /// Test running broadcast task.
+        /// </summary>
+        [Test]
+        public void TestBroadcastTask()
+        {
+            ICollection<Guid> res = _grid1.GetCompute().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+
+            Assert.AreEqual(3, res.Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
+
+            var prj = _grid1.GetCluster().ForPredicate(node => res.Take(2).Contains(node.Id));
+
+            Assert.AreEqual(2, prj.GetNodes().Count);
+
+            ICollection<Guid> filteredRes = prj.GetCompute().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+
+            Assert.AreEqual(2, filteredRes.Count);
+            Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
+            Assert.IsTrue(filteredRes.Contains(res.ElementAt(1)));
+        }
+
+        /// <summary>
+        /// Test running broadcast task in async mode.
+        /// </summary>
+        [Test]
+        public void TestBroadcastTaskAsync()
+        {
+            var gridCompute = _grid1.GetCompute().WithAsync();
+            Assert.IsNull(gridCompute.ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null));
+            ICollection<Guid> res = gridCompute.GetFuture<ICollection<Guid>>().Get();
+
+            Assert.AreEqual(3, res.Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
+
+            var prj = _grid1.GetCluster().ForPredicate(node => res.Take(2).Contains(node.Id));
+
+            Assert.AreEqual(2, prj.GetNodes().Count);
+
+            var compute = prj.GetCompute().WithAsync();
+            Assert.IsNull(compute.ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null));
+            ICollection<Guid> filteredRes = compute.GetFuture<ICollection<Guid>>().Get();
+
+            Assert.AreEqual(2, filteredRes.Count);
+            Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
+            Assert.IsTrue(filteredRes.Contains(res.ElementAt(1)));
+        }
+
+        /// <summary>
+        /// Tests the action broadcast.
+        /// </summary>
+        [Test]
+        public void TestBroadcastAction()
+        {
+            ComputeAction.InvokeCount = 0;
+            
+            _grid1.GetCompute().Broadcast(new ComputeAction());
+
+            Assert.AreEqual(_grid1.GetCluster().GetNodes().Count, ComputeAction.InvokeCount);
+        }
+
+        /// <summary>
+        /// Tests single action run.
+        /// </summary>
+        [Test]
+        public void TestRunAction()
+        {
+            ComputeAction.InvokeCount = 0;
+            
+            _grid1.GetCompute().Run(new ComputeAction());
+
+            Assert.AreEqual(1, ComputeAction.InvokeCount);
+        }
+
+        /// <summary>
+        /// Tests multiple actions run.
+        /// </summary>
+        [Test]
+        public void TestRunActions()
+        {
+            ComputeAction.InvokeCount = 0;
+
+            var actions = Enumerable.Range(0, 10).Select(x => new ComputeAction());
+            
+            _grid1.GetCompute().Run(actions);
+
+            Assert.AreEqual(10, ComputeAction.InvokeCount);
+        }
+
+        /// <summary>
+        /// Tests affinity run.
+        /// </summary>
+        [Test]
+        public void TestAffinityRun()
+        {
+            const string cacheName = null;
+
+            // Test keys for non-client nodes
+            var nodes = new[] {_grid1, _grid2}.Select(x => x.GetCluster().GetLocalNode());
+
+            var aff = _grid1.GetAffinity(cacheName);
+
+            foreach (var node in nodes)
+            {
+                var primaryKey = Enumerable.Range(1, int.MaxValue).First(x => aff.IsPrimary(node, x));
+
+                var affinityKey = _grid1.GetAffinity(cacheName).GetAffinityKey<int, int>(primaryKey);
+
+                _grid1.GetCompute().AffinityRun(cacheName, affinityKey, new ComputeAction());
+
+                Assert.AreEqual(node.Id, ComputeAction.LastNodeId);
+            }
+        }
+
+        /// <summary>
+        /// Tests affinity call.
+        /// </summary>
+        [Test]
+        public void TestAffinityCall()
+        {
+            const string cacheName = null;
+
+            // Test keys for non-client nodes
+            var nodes = new[] { _grid1, _grid2 }.Select(x => x.GetCluster().GetLocalNode());
+
+            var aff = _grid1.GetAffinity(cacheName);
+
+            foreach (var node in nodes)
+            {
+                var primaryKey = Enumerable.Range(1, int.MaxValue).First(x => aff.IsPrimary(node, x));
+
+                var affinityKey = _grid1.GetAffinity(cacheName).GetAffinityKey<int, int>(primaryKey);
+
+                var result = _grid1.GetCompute().AffinityCall(cacheName, affinityKey, new ComputeFunc());
+
+                Assert.AreEqual(result, ComputeFunc.InvokeCount);
+
+                Assert.AreEqual(node.Id, ComputeFunc.LastNodeId);
+            }
+        }
+
+        /// <summary>
+        /// Test "withNoFailover" feature.
+        /// </summary>
+        [Test]
+        public void TestWithNoFailover()
+        {
+            ICollection<Guid> res = _grid1.GetCompute().WithNoFailover().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+
+            Assert.AreEqual(3, res.Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
+        }
+
+        /// <summary>
+        /// Test "withTimeout" feature.
+        /// </summary>
+        [Test]
+        public void TestWithTimeout()
+        {
+            ICollection<Guid> res = _grid1.GetCompute().WithTimeout(1000).ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+
+            Assert.AreEqual(3, res.Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count);
+            Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(2)).GetNodes().Count);
+        }
+
+        /// <summary>
+        /// Test simple dotNet task execution.
+        /// </summary>
+        [Test]
+        public void TestNetTaskSimple()
+        {
+            int res = _grid1.GetCompute().Execute<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>(
+                    typeof(NetSimpleTask), new NetSimpleJobArgument(1)).Res;
+
+            Assert.AreEqual(_grid1.GetCompute().ClusterGroup.GetNodes().Count, res);
+        }
+
+        /// <summary>
+        /// Create configuration.
+        /// </summary>
+        /// <param name="path">XML config path.</param>
+        private IgniteConfiguration Configuration(string path)
+        {
+            IgniteConfiguration cfg = new IgniteConfiguration();
+
+            PortableConfiguration portCfg = new PortableConfiguration();
+
+            ICollection<PortableTypeConfiguration> portTypeCfgs = new List<PortableTypeConfiguration>();
+
+            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PlatformComputePortable)));
+            portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PlatformComputeNetPortable)));
+            portTypeCfgs.Add(new PortableTypeConfiguration(JavaPortableCls));
+
+            portCfg.TypeConfigurations = portTypeCfgs;
+
+            cfg.PortableConfiguration = portCfg;
+
+            cfg.JvmClasspath = IgniteManager.CreateClasspath(cfg, true);
+
+            cfg.JvmOptions = TestUtils.TestJavaOptions();
+
+            cfg.SpringConfigUrl = path;
+
+            return cfg;
+        }
+    }
+
+    class PlatformComputePortable
+    {
+        public int Field
+        {
+            get;
+            set;
+        }
+    }
+
+    class PlatformComputeNetPortable : PlatformComputePortable
+    {
+
+    }
+
+    [Serializable]
+    class NetSimpleTask : IComputeTask<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>
+    {
+        /** <inheritDoc /> */
+
+        public IDictionary<IComputeJob<NetSimpleJobResult>, IClusterNode> Map(IList<IClusterNode> subgrid,
+            NetSimpleJobArgument arg)
+        {
+            var jobs = new Dictionary<IComputeJob<NetSimpleJobResult>, IClusterNode>();
+
+            for (int i = 0; i < subgrid.Count; i++)
+            {
+                NetSimpleJob job = new NetSimpleJob {Arg = arg};
+
+                jobs[job] = subgrid[i];
+            }
+
+            return jobs;
+        }
+
+        /** <inheritDoc /> */
+        public ComputeJobResultPolicy Result(IComputeJobResult<NetSimpleJobResult> res,
+            IList<IComputeJobResult<NetSimpleJobResult>> rcvd)
+        {
+            return ComputeJobResultPolicy.Wait;
+        }
+
+        /** <inheritDoc /> */
+        public NetSimpleTaskResult Reduce(IList<IComputeJobResult<NetSimpleJobResult>> results)
+        {
+            return new NetSimpleTaskResult(results.Sum(res => res.Data().Res));
+        }
+    }
+
+    [Serializable]
+    class NetSimpleJob : IComputeJob<NetSimpleJobResult>
+    {
+        public NetSimpleJobArgument Arg;
+
+        /** <inheritDoc /> */
+        public NetSimpleJobResult Execute()
+        {
+            return new NetSimpleJobResult(Arg.Arg);
+        }
+
+        /** <inheritDoc /> */
+        public void Cancel()
+        {
+            // No-op.
+        }
+    }
+
+    [Serializable]
+    class NetSimpleJobArgument
+    {
+        public int Arg;
+
+        public NetSimpleJobArgument(int arg)
+        {
+            Arg = arg;
+        }
+    }
+
+    [Serializable]
+    class NetSimpleTaskResult
+    {
+        public int Res;
+
+        public NetSimpleTaskResult(int res)
+        {
+            Res = res;
+        }
+    }
+
+    [Serializable]
+    class NetSimpleJobResult
+    {
+        public int Res;
+
+        public NetSimpleJobResult(int res)
+        {
+            Res = res;
+        }
+    }
+
+    [Serializable]
+    class ComputeAction : IComputeAction
+    {
+        [InstanceResource]
+        #pragma warning disable 649
+        private IIgnite _grid;
+
+        public static int InvokeCount;
+
+        public static Guid LastNodeId;
+
+        public void Invoke()
+        {
+            Interlocked.Increment(ref InvokeCount);
+            LastNodeId = _grid.GetCluster().GetLocalNode().Id;
+        }
+    }
+
+    interface IUserInterface<out T>
+    {
+        T Invoke();
+    }
+
+    interface INestedComputeFunc : IComputeFunc<int>
+    {
+        
+    }
+
+    [Serializable]
+    class ComputeFunc : INestedComputeFunc, IUserInterface<int>
+    {
+        [InstanceResource]
+        private IIgnite _grid;
+
+        public static int InvokeCount;
+
+        public static Guid LastNodeId;
+
+        int IComputeFunc<int>.Invoke()
+        {
+            InvokeCount++;
+            LastNodeId = _grid.GetCluster().GetLocalNode().Id;
+            return InvokeCount;
+        }
+
+        int IUserInterface<int>.Invoke()
+        {
+            // Same signature as IComputeFunc<int>, but from different interface
+            throw new Exception("Invalid method");
+        }
+
+        public int Invoke()
+        {
+            // Same signature as IComputeFunc<int>, but due to explicit interface implementation this is a wrong method
+            throw new Exception("Invalid method");
+        }
+    }
+
+    public enum InteropComputeEnum
+    {
+        Foo,
+        Bar,
+        Baz
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/65bb69da/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
new file mode 100644
index 0000000..5b6874f
--- /dev/null
+++ b/modules/platform/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
@@ -0,0 +1,269 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Compute
+{
+    using System;
+    using System.Collections.Generic;
+    using Apache.Ignite.Core.Cluster;
+    using Apache.Ignite.Core.Compute;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests class.
+    /// </summary>
+    [Category(TestUtils.CategoryIntensive)]
+    public class ComputeMultithreadedTest : AbstractTaskTest
+    {
+        /** */
+        private static IList<Action<ICompute>> _actions;
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public ComputeMultithreadedTest() : base(false) { }
+
+        /// <summary>
+        /// Set-up routine.
+        /// </summary>
+        [SetUp]
+        public void SetUp()
+        {
+            _actions = new List<Action<ICompute>>
+            {
+                compute => { compute.Apply(new My1ArgClosure(), "zzzz"); },
+                compute => { compute.Broadcast(new My1ArgClosure(), "zzzz"); },
+                compute => { compute.Broadcast(new MyNoArgClosure("zzzz")); },
+                compute => { compute.Call(new MyNoArgClosure("zzzz")); },
+                compute => { compute.Execute(new StringLengthEmptyTask(), "zzzz"); },
+                compute =>
+                {
+                    compute.Apply(new My1ArgClosure(), new List<string> {"zzzz", "a", "b"}, new MyReducer());
+                }
+            };
+
+        }
+
+        /// <summary>
+        /// Tear-down routine.
+        /// </summary>
+        [TearDown]
+        public void TearDown()
+        {
+            _actions.Clear();
+        }
+
+        /// <summary>
+        /// Test not-marshalable error occurred during map step.
+        /// </summary>
+        [Test]
+        public void TestAllTaskTypeAtSameTime()
+        {
+            Assert.AreEqual(_actions.Count, 6);
+
+            var compute = Grid1.GetCompute();
+
+            TestUtils.RunMultiThreaded(() =>
+            {
+                _actions[TestUtils.Random.Next(_actions.Count)](compute);
+            }, 4, 60);
+        }
+
+        /// <summary>
+        ///
+        /// </summary>
+        [Test]
+        public void TestSingleTaskType0()
+        {
+            Assert.AreEqual(_actions.Count, 6);
+
+            TestUtils.RunMultiThreaded(() => _actions[0](Grid1.GetCompute()), 4, 20);
+        }
+
+        /// <summary>
+        ///
+        /// </summary>
+        [Test]
+        public void TestSingleTaskType1()
+        {
+            Assert.AreEqual(_actions.Count, 6);
+
+            TestUtils.RunMultiThreaded(() => _actions[1](Grid1.GetCompute()), 4, 20);
+        }
+
+        /// <summary>
+        ///
+        /// </summary>
+        [Test]
+        public void TestSingleTaskType2()
+        {
+            Assert.AreEqual(_actions.Count, 6);
+
+            TestUtils.RunMultiThreaded(() => _actions[2](Grid1.GetCompute()), 4, 20);
+        }
+
+        /// <summary>
+        ///
+        /// </summary>
+        [Test]
+        public void TestSingleTaskType3()
+        {
+            Assert.AreEqual(_actions.Count, 6);
+
+            TestUtils.RunMultiThreaded(() => _actions[3](Grid1.GetCompute()), 4, 20);
+        }
+        /// <summary>
+        ///
+        /// </summary>
+        [Test]
+        public void TestSingleTaskType4()
+        {
+            Assert.AreEqual(_actions.Count, 6);
+
+            TestUtils.RunMultiThreaded(() => _actions[4](Grid1.GetCompute()), 4, 20);
+        }
+
+        /// <summary>
+        ///
+        /// </summary>
+        [Test]
+        public void TestSingleTaskType5()
+        {
+            Assert.AreEqual(_actions.Count, 6);
+
+            TestUtils.RunMultiThreaded(() => _actions[5](Grid1.GetCompute()), 4, 20);
+        }
+    }
+
+    /// <summary>
+    /// Test class.
+    /// </summary>
+    [Serializable]
+    public class My1ArgClosure : IComputeFunc<string, int>
+    {
+        /** <inheritDoc /> */
+        public int Invoke(string s)
+        {
+            return s.Length;
+        }
+    }
+
+    /// <summary>
+    /// Test class.
+    /// </summary>
+    [Serializable]
+    public class MyNoArgClosure : IComputeFunc<int>
+    {
+        /** */
+        private readonly string _s;
+
+        /// <summary>
+        ///
+        /// </summary>
+        /// <param name="s"></param>
+        public MyNoArgClosure(string s)
+        {
+            _s = s;
+        }
+
+        /** <inheritDoc /> */
+        public int Invoke()
+        {
+            return _s.Length;
+        }
+    }
+
+    /// <summary>
+    ///
+    /// </summary>
+    public class StringLengthEmptyTask : IComputeTask<string, int, int>
+    {
+        /** <inheritDoc /> */
+        public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, string arg)
+        {
+            var res = new Dictionary<IComputeJob<int>, IClusterNode>();
+
+            var job = new StringLengthEmptyJob(arg);
+
+            IClusterNode node = subgrid[TestUtils.Random.Next(subgrid.Count)];
+
+            res.Add(job, node);
+
+            return res;
+        }
+
+        /** <inheritDoc /> */
+        public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
+        {
+            return ComputeJobResultPolicy.Wait;
+        }
+
+        /** <inheritDoc /> */
+        public int Reduce(IList<IComputeJobResult<int>> results)
+        {
+            return results.Count == 0 ? 0 : results[0].Data();
+        }
+    }
+
+    /// <summary>
+    /// Test class.
+    /// </summary>
+    [Serializable]
+    public class StringLengthEmptyJob: IComputeJob<int>
+    {
+        /** */
+        private string _s;
+
+        /// <summary>
+        ///
+        /// </summary>
+        /// <param name="s"></param>
+        public StringLengthEmptyJob(string s)
+        {
+            _s = s;
+        }
+
+        /** <inheritDoc /> */
+        public int Execute()
+        {
+            return _s.Length;
+        }
+
+        /** <inheritDoc /> */
+        public void Cancel()
+        {
+            // No-op
+        }
+    }
+
+    public class MyReducer : IComputeReducer<int, int>
+    {
+        /** */
+        private int _res;
+
+        public bool Collect(int res)
+        {
+            _res += res;
+            return true;
+        }
+
+        public int Reduce()
+        {
+            return _res;
+        }
+    }
+}


Mime
View raw message