IGNITE-2967 .NET: Provided meaningful error message when platform fails on Java-only node. This closes #630.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/34fc271f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/34fc271f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/34fc271f Branch: refs/heads/ignite-db-x-10884 Commit: 34fc271fd29700703d6b6c1aa55de598c3517ada Parents: 18077e0 Author: Pavel Tupitsyn <[email protected]> Authored: Tue Apr 12 16:06:20 2016 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Tue Apr 12 16:06:20 2016 +0300 ---------------------------------------------------------------------- .../platform/PlatformNoopProcessor.java | 4 +- .../platform/PlatformProcessorImpl.java | 9 ++ .../Compute/MixedClusterTest.cs | 122 ++++++++++++++----- 3 files changed, 103 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/34fc271f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java index 8fe17e1..06988ee 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java @@ -45,7 +45,9 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf /** {@inheritDoc} */ @Override public PlatformContext context() { - return null; + throw new IgniteException("Platforms are not available [nodeId=" + ctx.grid().localNode().id() + "] " + + "(Use Apache.Ignite.Core.Ignition.Start() or Apache.Ignite.exe to start Ignite.NET nodes; " + + "ignite::Ignition::Start() or ignite.exe to start Ignite C++ nodes)."); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/34fc271f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java index ff7bbd7..bcdd91d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java @@ -218,6 +218,15 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf /** {@inheritDoc} */ @Override public PlatformContext context() { + // This method is a single point of entry for all remote closures + // CPP platform does not currently support remote code execution + // Therefore, all remote execution attempts come from .NET + // Throw an error if current platform is not .NET + if (!PlatformUtils.PLATFORM_DOTNET.equals(interopCfg.platform())) { + throw new IgniteException(".NET platform is not available [nodeId=" + ctx.grid().localNode().id() + "] " + + "(Use Apache.Ignite.Core.Ignition.Start() or Apache.Ignite.exe to start Ignite.NET nodes)."); + } + return platformCtx; } http://git-wip-us.apache.org/repos/asf/ignite/blob/34fc271f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs index 57ea892..0688440 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs @@ -21,6 +21,9 @@ namespace Apache.Ignite.Core.Tests.Compute using System; using System.Collections; using System.Linq; + using Apache.Ignite.Core.Cache; + using Apache.Ignite.Core.Cache.Query; + using Apache.Ignite.Core.Common; using Apache.Ignite.Core.Compute; using NUnit.Framework; @@ -29,6 +32,8 @@ namespace Apache.Ignite.Core.Tests.Compute /// </summary> public class MixedClusterTest { + private IIgnite _ignite; + private string _javaNodeName; /** */ private const string SpringConfig = @"Config\Compute\compute-grid1.xml"; @@ -41,39 +46,32 @@ namespace Apache.Ignite.Core.Tests.Compute /** */ private const string StopTask = "org.apache.ignite.platform.PlatformStopIgniteTask"; - /// <summary> - /// Tests the compute. - /// </summary> - [Test] - public void TestCompute() + [TestFixtureSetUp] + public void FixtureSetUp() { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) {SpringConfigUrl = SpringConfig}; - using (var ignite = Ignition.Start(cfg)) - { - var javaNodeName = StartJavaNode(ignite, SpringConfig2); + _ignite = Ignition.Start(cfg); - try - { - Assert.IsTrue(ignite.WaitTopology(2)); + _javaNodeName = _ignite.GetCompute().ExecuteJavaTask<string>(StartTask, SpringConfig2); - TestDotNetTask(ignite); - TestJavaTask(ignite); - } - finally - { - StopJavaNode(ignite, javaNodeName); - } - } + Assert.IsTrue(_ignite.WaitTopology(2)); + } + + [TestFixtureTearDown] + public void FixtureTearDown() + { + _ignite.GetCompute().ExecuteJavaTask<object>(StopTask, _javaNodeName); + Ignition.StopAll(true); } /// <summary> /// Tests the dot net task. /// </summary> - /// <param name="ignite">The ignite.</param> - private static void TestDotNetTask(IIgnite ignite) + [Test] + public void TestDotNetTask() { - var results = ignite.GetCompute().Broadcast(new ComputeFunc()); + var results = _ignite.GetCompute().Broadcast(new ComputeFunc()); // There are two nodes, but only one can execute .NET jobs. Assert.AreEqual(new[] {int.MaxValue}, results.ToArray()); @@ -82,29 +80,65 @@ namespace Apache.Ignite.Core.Tests.Compute /// <summary> /// Tests the dot net task. /// </summary> - /// <param name="ignite">The ignite.</param> - private static void TestJavaTask(IIgnite ignite) + [Test] + public void TestJavaTask() { // Java task can execute on both nodes. - var res = ignite.GetCompute().ExecuteJavaTask<ICollection>(ComputeApiTest.BroadcastTask, null); + var res = _ignite.GetCompute().ExecuteJavaTask<ICollection>(ComputeApiTest.BroadcastTask, null); Assert.AreEqual(2, res.Count); } /// <summary> - /// Starts the java node. + /// Tests the scan query. /// </summary> - private static string StartJavaNode(IIgnite grid, string config) + [Test] + public void TestScanQuery() { - return grid.GetCompute().ExecuteJavaTask<string>(StartTask, config); + var cache = GetCache(); + + // Scan query does not work in the mixed cluster. + Assert.Throws<IgniteException>(() => cache.Query(new ScanQuery<int, int>(new ScanFilter())).GetAll()); } /// <summary> - /// Stops the java node. + /// Tests the cache invoke. /// </summary> - private static void StopJavaNode(IIgnite grid, string name) + [Test] + public void TestCacheInvoke() { - grid.GetCompute().ExecuteJavaTask<object>(StopTask, name); + var cache = GetCache(); + + var results = cache.InvokeAll(cache.Select(x => x.Key), new CacheProcessor(), 0); + + foreach (var res in results) + { + try + { + Assert.AreEqual(0, res.Value.Result); + } + catch (CacheEntryProcessorException ex) + { + // At least some results should throw an error + Assert.IsTrue(ex.ToString().Contains("Platforms are not available"), "Unexpected error: " + ex); + + return; + } + } + + Assert.Fail("InvokeAll unexpectedly succeeded in mixed-platform cluter."); + } + + /// <summary> + /// Gets the cache. + /// </summary> + private ICache<int, int> GetCache() + { + var cache = _ignite.GetOrCreateCache<int, int>("mixedCache"); + + cache.PutAll(Enumerable.Range(1, 1000).ToDictionary(x => x, x => x)); + + return cache; } /// <summary> @@ -119,5 +153,31 @@ namespace Apache.Ignite.Core.Tests.Compute return int.MaxValue; } } + + /// <summary> + /// Test filter. + /// </summary> + [Serializable] + private class ScanFilter : ICacheEntryFilter<int, int> + { + /** <inheritdoc /> */ + public bool Invoke(ICacheEntry<int, int> entry) + { + return entry.Key < 100; + } + } + + /// <summary> + /// Test processor. + /// </summary> + [Serializable] + private class CacheProcessor : ICacheEntryProcessor<int, int, int, int> + { + /** <inheritdoc /> */ + public int Process(IMutableCacheEntry<int, int> entry, int arg) + { + return arg; + } + } } }
