Repository: ignite Updated Branches: refs/heads/master 40d863246 -> 94ecfe01c
IGNITE-3329 .NET: Fix TestDeployNodeSingleton and TestRunActions Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/94ecfe01 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/94ecfe01 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/94ecfe01 Branch: refs/heads/master Commit: 94ecfe01cb92d5595611ff31df6b3c7d494b7ea2 Parents: 40d8632 Author: Pavel Tupitsyn <[email protected]> Authored: Wed Jun 29 17:04:40 2016 +0300 Committer: Pavel Tupitsyn <[email protected]> Committed: Wed Jun 29 17:04:40 2016 +0300 ---------------------------------------------------------------------- .../services/PlatformAbstractService.java | 3 +- .../Compute/ComputeApiTest.cs | 42 ++++++++++++++------ .../Services/ServicesTest.cs | 1 + .../Impl/Services/Services.cs | 17 ++++---- .../Impl/Unmanaged/UnmanagedCallbacks.cs | 7 +++- 5 files changed, 47 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/94ecfe01/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java index 0840275..d6a6e16 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java @@ -213,7 +213,8 @@ public abstract class PlatformAbstractService implements PlatformService, Extern @IgniteInstanceResource public void setIgniteInstance(Ignite ignite) { // Ignite instance can be null here because service processor invokes "cleanup" on resource manager. - platformCtx = ignite != null ? PlatformUtils.platformContext(ignite) : null; + if (ignite != null && platformCtx == null) + platformCtx = PlatformUtils.platformContext(ignite); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/94ecfe01/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs index d431aed..bc26e4c 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs @@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Tests.Compute { using System; using System.Collections; + using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -1008,11 +1009,11 @@ namespace Apache.Ignite.Core.Tests.Compute [Test] public void TestBroadcastAction() { - ComputeAction.InvokeCount = 0; + var id = Guid.NewGuid(); - _grid1.GetCompute().Broadcast(new ComputeAction()); + _grid1.GetCompute().Broadcast(new ComputeAction(id)); - Assert.AreEqual(2, ComputeAction.InvokeCount); + Assert.AreEqual(2, ComputeAction.InvokeCount(id)); } /// <summary> @@ -1021,11 +1022,11 @@ namespace Apache.Ignite.Core.Tests.Compute [Test] public void TestRunAction() { - ComputeAction.InvokeCount = 0; - - _grid1.GetCompute().Run(new ComputeAction()); + var id = Guid.NewGuid(); + + _grid1.GetCompute().Run(new ComputeAction(id)); - Assert.AreEqual(1, ComputeAction.InvokeCount); + Assert.AreEqual(1, ComputeAction.InvokeCount(id)); } /// <summary> @@ -1053,13 +1054,13 @@ namespace Apache.Ignite.Core.Tests.Compute [Test] public void TestRunActions() { - ComputeAction.InvokeCount = 0; + var id = Guid.NewGuid(); - var actions = Enumerable.Range(0, 10).Select(x => new ComputeAction()); + var actions = Enumerable.Range(0, 10).Select(x => new ComputeAction(id)); _grid1.GetCompute().Run(actions); - Assert.AreEqual(10, ComputeAction.InvokeCount); + Assert.AreEqual(10, ComputeAction.InvokeCount(id)); } /// <summary> @@ -1324,16 +1325,33 @@ namespace Apache.Ignite.Core.Tests.Compute #pragma warning disable 649 private IIgnite _grid; - public static int InvokeCount; + public static ConcurrentBag<Guid> Invokes = new ConcurrentBag<Guid>(); public static Guid LastNodeId; + public Guid Id { get; set; } + + public ComputeAction() + { + // No-op. + } + + public ComputeAction(Guid id) + { + Id = id; + } + public void Invoke() { Thread.Sleep(10); - Interlocked.Increment(ref InvokeCount); + Invokes.Add(Id); LastNodeId = _grid.GetCluster().GetLocalNode().Id; } + + public static int InvokeCount(Guid id) + { + return Invokes.Count(x => x == id); + } } class InvalidComputeAction : ComputeAction http://git-wip-us.apache.org/repos/asf/ignite/blob/94ecfe01/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs index 2bacf50..c6af077 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs @@ -684,6 +684,7 @@ namespace Apache.Ignite.Core.Tests.Services { foreach (var grid in Grids) Assert.IsTrue( + // ReSharper disable once AccessToForEachVariableInClosure TestUtils.WaitForCondition(() => grid.GetServices() .GetService<ITestIgniteService>(name) == null, 5000)); } http://git-wip-us.apache.org/repos/asf/ignite/blob/94ecfe01/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs index 3d55f06..e3e2764 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs @@ -313,18 +313,17 @@ namespace Apache.Ignite.Core.Impl.Services { bool hasVal = r.ReadBool(); - if (hasVal) - { - var count = r.ReadInt(); + if (!hasVal) + return new T[0]; + + var count = r.ReadInt(); - var res = new List<T>(count); + var res = new List<T>(count); - for (var i = 0; i < count; i++) - res.Add(Marshaller.Ignite.HandleRegistry.Get<T>(r.ReadLong())); + for (var i = 0; i < count; i++) + res.Add(Marshaller.Ignite.HandleRegistry.Get<T>(r.ReadLong())); - return res; - } - return null; + return res; }); } http://git-wip-us.apache.org/repos/asf/ignite/blob/94ecfe01/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs index 89ed838..408b48f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs @@ -931,7 +931,12 @@ namespace Apache.Ignite.Core.Impl.Unmanaged { SafeCall(() => { - var svc = _handleRegistry.Get<IService>(svcPtr, true); + var svc = _handleRegistry.Get<IService>(svcPtr); + + // Ignite does not guarantee that Cancel is called after Execute exits + // So missing handle is a valid situation + if (svc == null) + return; using (var stream = IgniteManager.Memory.Get(memPtr).GetStream()) {
