You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2016/06/16 12:04:12 UTC
ignite git commit: IGNITE-3182 .NET: Fix compute jobs executing on
client nodes
Repository: ignite
Updated Branches:
refs/heads/master 2d69ed630 -> 277480c29
IGNITE-3182 .NET: Fix compute jobs executing on client nodes
This closes #748
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/277480c2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/277480c2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/277480c2
Branch: refs/heads/master
Commit: 277480c293bc27335f9e6618c4c362a6f326c00d
Parents: 2d69ed6
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Jun 16 15:03:59 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Jun 16 15:03:59 2016 +0300
----------------------------------------------------------------------
.../platform/cluster/PlatformClusterGroup.java | 7 ++
.../cpp/jni/include/ignite/jni/exports.h | 1 +
.../platforms/cpp/jni/include/ignite/jni/java.h | 2 +
modules/platforms/cpp/jni/project/vs/module.def | 2 +
modules/platforms/cpp/jni/src/exports.cpp | 4 ++
modules/platforms/cpp/jni/src/java.cpp | 12 ++++
.../Compute/AbstractTaskTest.cs | 9 +++
.../Compute/BinarizableTaskTest.cs | 13 ++--
.../Compute/ComputeApiTest.cs | 70 +++++++++-----------
.../Compute/FailoverTaskSelfTest.cs | 2 +-
.../Compute/IgniteExceptionTaskSelfTest.cs | 18 ++---
.../Compute/ResourceTaskTest.cs | 8 +--
.../Compute/TaskAdapterTest.cs | 16 +++--
.../Compute/TaskResultTest.cs | 10 +--
.../Apache.Ignite.Core.Tests/EventsTest.cs | 4 +-
.../Services/ServicesTest.cs | 19 +++---
.../Apache.Ignite.Core.Tests/TestRunner.cs | 6 +-
.../Apache.Ignite.Core/Cluster/IClusterGroup.cs | 6 ++
.../Impl/Cluster/ClusterGroupImpl.cs | 6 ++
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 10 ++-
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 6 ++
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 3 +
.../Impl/Unmanaged/UnmanagedUtils.cs | 7 ++
23 files changed, 154 insertions(+), 87 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
index d80079c..9a49c2e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
@@ -304,6 +304,13 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
}
/**
+ * @return New projection.
+ */
+ public PlatformClusterGroup forServers() {
+ return new PlatformClusterGroup(platformCtx, (ClusterGroupEx)prj.forServers());
+ }
+
+ /**
* @return Projection.
*/
public ClusterGroupEx projection() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/cpp/jni/include/ignite/jni/exports.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/include/ignite/jni/exports.h b/modules/platforms/cpp/jni/include/ignite/jni/exports.h
index bcfc213..bf278e2 100644
--- a/modules/platforms/cpp/jni/include/ignite/jni/exports.h
+++ b/modules/platforms/cpp/jni/include/ignite/jni/exports.h
@@ -114,6 +114,7 @@ extern "C" {
void* IGNITE_CALL IgniteProjectionForRandom(gcj::JniContext* ctx, void* obj);
void* IGNITE_CALL IgniteProjectionForOldest(gcj::JniContext* ctx, void* obj);
void* IGNITE_CALL IgniteProjectionForYoungest(gcj::JniContext* ctx, void* obj);
+ void* IGNITE_CALL IgniteProjectionForServers(gcj::JniContext* ctx, void* obj);
void IGNITE_CALL IgniteProjectionResetMetrics(gcj::JniContext* ctx, void* obj);
void* IGNITE_CALL IgniteProjectionOutOpRet(gcj::JniContext* ctx, void* obj, int type, long long memPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/cpp/jni/include/ignite/jni/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/include/ignite/jni/java.h b/modules/platforms/cpp/jni/include/ignite/jni/java.h
index 8be8a32..3d45ec0 100644
--- a/modules/platforms/cpp/jni/include/ignite/jni/java.h
+++ b/modules/platforms/cpp/jni/include/ignite/jni/java.h
@@ -248,6 +248,7 @@ namespace ignite
jmethodID m_PlatformClusterGroup_forRandom;
jmethodID m_PlatformClusterGroup_forOldest;
jmethodID m_PlatformClusterGroup_forYoungest;
+ jmethodID m_PlatformClusterGroup_forServers;
jmethodID m_PlatformClusterGroup_resetMetrics;
jclass c_PlatformCompute;
@@ -594,6 +595,7 @@ namespace ignite
jobject ProjectionForRandom(jobject obj);
jobject ProjectionForOldest(jobject obj);
jobject ProjectionForYoungest(jobject obj);
+ jobject ProjectionForServers(jobject obj);
void ProjectionResetMetrics(jobject obj);
jobject ProjectionOutOpRet(jobject obj, int type, long long memPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/cpp/jni/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/project/vs/module.def b/modules/platforms/cpp/jni/project/vs/module.def
index dc4af3d..cfe658c 100644
--- a/modules/platforms/cpp/jni/project/vs/module.def
+++ b/modules/platforms/cpp/jni/project/vs/module.def
@@ -133,3 +133,5 @@ IgniteAtomicReferenceClose @130
IgniteProcessorCreateNearCache @131
IgniteProcessorGetOrCreateNearCache @132
IgniteProcessorGetCacheNames @133
+IgniteProjectionForServers @134
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/cpp/jni/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/src/exports.cpp b/modules/platforms/cpp/jni/src/exports.cpp
index 89878d4..6c4760c 100644
--- a/modules/platforms/cpp/jni/src/exports.cpp
+++ b/modules/platforms/cpp/jni/src/exports.cpp
@@ -343,6 +343,10 @@ extern "C" {
return ctx->ProjectionForYoungest(static_cast<jobject>(obj));
}
+ void* IGNITE_CALL IgniteProjectionForServers(gcj::JniContext* ctx, void* obj) {
+ return ctx->ProjectionForServers(static_cast<jobject>(obj));
+ }
+
void IGNITE_CALL IgniteProjectionResetMetrics(gcj::JniContext* ctx, void* obj) {
ctx->ProjectionResetMetrics(static_cast<jobject>(obj));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/cpp/jni/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/src/java.cpp b/modules/platforms/cpp/jni/src/java.cpp
index 282b874..66be0ca 100644
--- a/modules/platforms/cpp/jni/src/java.cpp
+++ b/modules/platforms/cpp/jni/src/java.cpp
@@ -233,6 +233,7 @@ namespace ignite
JniMethod M_PLATFORM_CLUSTER_GRP_FOR_RANDOM = JniMethod("forRandom", "()Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
JniMethod M_PLATFORM_CLUSTER_GRP_FOR_OLDEST = JniMethod("forOldest", "()Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
JniMethod M_PLATFORM_CLUSTER_GRP_FOR_YOUNGEST = JniMethod("forYoungest", "()Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
+ JniMethod M_PLATFORM_CLUSTER_GRP_FOR_SERVERS = JniMethod("forServers", "()Lorg/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup;", false);
JniMethod M_PLATFORM_CLUSTER_GRP_RESET_METRICS = JniMethod("resetMetrics", "()V", false);
const char* C_PLATFORM_MESSAGING = "org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging";
@@ -615,6 +616,7 @@ namespace ignite
m_PlatformClusterGroup_forRandom = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_RANDOM);
m_PlatformClusterGroup_forOldest = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_OLDEST);
m_PlatformClusterGroup_forYoungest = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_YOUNGEST);
+ m_PlatformClusterGroup_forServers = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_FOR_SERVERS);
m_PlatformClusterGroup_resetMetrics = FindMethod(env, c_PlatformClusterGroup, M_PLATFORM_CLUSTER_GRP_RESET_METRICS);
c_PlatformCompute = FindClass(env, C_PLATFORM_COMPUTE);
@@ -1955,6 +1957,16 @@ namespace ignite
return LocalToGlobal(env, newPrj);
}
+ jobject JniContext::ProjectionForServers(jobject obj) {
+ JNIEnv* env = Attach();
+
+ jobject newPrj = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformClusterGroup_forServers);
+
+ ExceptionCheck(env);
+
+ return LocalToGlobal(env, newPrj);
+ }
+
void JniContext::ProjectionResetMetrics(jobject obj) {
JNIEnv* env = Attach();
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
index e3d0d96..d31ad43 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
using System;
using System.Collections.Generic;
+ using System.Linq;
using System.Threading;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Tests.Process;
@@ -213,5 +214,13 @@ namespace Apache.Ignite.Core.Tests.Compute
{
// No-op.
}
+
+ /// <summary>
+ /// Gets the server count.
+ /// </summary>
+ protected int GetServerCount()
+ {
+ return Grid1.GetCluster().GetNodes().Count(x => !x.IsClient);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
index 5c1ee34..8aa28de 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
@@ -100,7 +100,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/** <inheritDoc /> */
override public IDictionary<IComputeJob<BinarizableWrapper>, IClusterNode> Map(IList<IClusterNode> subgrid, BinarizableWrapper arg)
{
- Assert.AreEqual(3, subgrid.Count);
+ Assert.AreEqual(2, subgrid.Count);
Assert.NotNull(_grid);
var taskArg = arg;
@@ -114,15 +114,12 @@ namespace Apache.Ignite.Core.Tests.Compute
foreach (IClusterNode node in subgrid)
{
- if (!Grid3Name.Equals(node.GetAttribute<string>("org.apache.ignite.ignite.name"))) // Grid3 does not have cache.
+ var job = new BinarizableJob
{
- var job = new BinarizableJob
- {
- Arg = new BinarizableWrapper {Item = ToBinary(_grid, new BinarizableJobArgument(200))}
- };
+ Arg = new BinarizableWrapper {Item = ToBinary(_grid, new BinarizableJobArgument(200))}
+ };
- jobs.Add(job, node);
- }
+ jobs.Add(job, node);
}
Assert.AreEqual(2, jobs.Count);
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/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 2c5b31e..d431aed 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -560,6 +560,26 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
+ /// Tests ForServers projection.
+ /// </summary>
+ [Test]
+ public void TestForServers()
+ {
+ var cluster = _grid1.GetCluster();
+
+ var servers = cluster.ForServers().GetNodes();
+ Assert.AreEqual(2, servers.Count);
+ Assert.IsTrue(servers.All(x => !x.IsClient));
+
+ var serverAndClient =
+ cluster.ForNodeIds(new[] { _grid2, _grid3 }.Select(x => x.GetCluster().GetLocalNode().Id));
+ Assert.AreEqual(1, serverAndClient.ForServers().GetNodes().Count);
+
+ var client = cluster.ForNodeIds(new[] { _grid3 }.Select(x => x.GetCluster().GetLocalNode().Id));
+ Assert.AreEqual(0, client.ForServers().GetNodes().Count);
+ }
+
+ /// <summary>
/// Test for attribute projection.
/// </summary>
[Test]
@@ -957,47 +977,25 @@ namespace Apache.Ignite.Core.Tests.Compute
/// Test running broadcast task.
/// </summary>
[Test]
- public void TestBroadcastTask()
- {
- var res = _grid1.GetCompute().ExecuteJavaTask<ICollection>(BroadcastTask, null).OfType<Guid>().ToList();
-
- 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 filteredRes = prj.GetCompute().ExecuteJavaTask<ICollection>(BroadcastTask, null).OfType<Guid>().ToList();
-
- 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()
+ public void TestBroadcastTask([Values(false, true)] bool isAsync)
{
- var gridCompute = _grid1.GetCompute();
+ var execTask =
+ isAsync
+ ? (Func<ICompute, List<Guid>>) (
+ c => c.ExecuteJavaTaskAsync<ICollection>(BroadcastTask, null).Result.OfType<Guid>().ToList())
+ : c => c.ExecuteJavaTask<ICollection>(BroadcastTask, null).OfType<Guid>().ToList();
- var res = gridCompute.ExecuteJavaTaskAsync<ICollection>(BroadcastTask, null).Result.OfType<Guid>().ToList();
+ var res = execTask(_grid1.GetCompute());
- Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(2, 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();
- var filteredRes = compute.ExecuteJavaTaskAsync<IList>(BroadcastTask, null).Result;
+ var filteredRes = execTask(prj.GetCompute());
Assert.AreEqual(2, filteredRes.Count);
Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
@@ -1014,7 +1012,7 @@ namespace Apache.Ignite.Core.Tests.Compute
_grid1.GetCompute().Broadcast(new ComputeAction());
- Assert.AreEqual(_grid1.GetCluster().GetNodes().Count, ComputeAction.InvokeCount);
+ Assert.AreEqual(2, ComputeAction.InvokeCount);
}
/// <summary>
@@ -1125,10 +1123,9 @@ namespace Apache.Ignite.Core.Tests.Compute
var res = _grid1.GetCompute().WithNoFailover().ExecuteJavaTask<ICollection>(BroadcastTask, null)
.OfType<Guid>().ToList();
- Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(2, 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>
@@ -1140,10 +1137,9 @@ namespace Apache.Ignite.Core.Tests.Compute
var res = _grid1.GetCompute().WithTimeout(1000).ExecuteJavaTask<ICollection>(BroadcastTask, null)
.OfType<Guid>().ToList();
- Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(2, 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>
@@ -1155,7 +1151,7 @@ namespace Apache.Ignite.Core.Tests.Compute
int res = _grid1.GetCompute().Execute<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>(
typeof(NetSimpleTask), new NetSimpleJobArgument(1)).Res;
- Assert.AreEqual(_grid1.GetCompute().ClusterGroup.GetNodes().Count, res);
+ Assert.AreEqual(2, res);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
index 34a1573..45af888 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
@@ -124,7 +124,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/** <inheritDoc /> */
override public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, Tuple<bool, bool> arg)
{
- Assert.AreEqual(3, subgrid.Count);
+ Assert.AreEqual(2, subgrid.Count);
Tuple<bool, bool> t = arg;
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
index 55d04cd..0c983fd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
@@ -103,7 +103,7 @@ namespace Apache.Ignite.Core.Tests.Compute
int res = Execute();
- Assert.AreEqual(2, res);
+ Assert.AreEqual(1, res);
Assert.AreEqual(1, JobErrs.Count);
Assert.IsNotNull(JobErrs.First() as GoodException);
@@ -120,7 +120,7 @@ namespace Apache.Ignite.Core.Tests.Compute
int res = Execute();
- Assert.AreEqual(2, res);
+ Assert.AreEqual(1, res);
Assert.AreEqual(1, JobErrs.Count);
Assert.IsNotNull(JobErrs.First() as BadException); // Local job exception is not marshalled.
@@ -136,7 +136,7 @@ namespace Apache.Ignite.Core.Tests.Compute
int res = Execute();
- Assert.AreEqual(3, res); // Local job result is not marshalled.
+ Assert.AreEqual(2, res); // Local job result is not marshalled.
Assert.AreEqual(0, JobErrs.Count);
}
@@ -153,13 +153,11 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(1, res);
- Assert.AreEqual(2, JobErrs.Count);
+ Assert.AreEqual(1, JobErrs.Count);
Assert.IsNotNull(JobErrs.ElementAt(0) as GoodException);
- Assert.IsNotNull(JobErrs.ElementAt(1) as GoodException);
Assert.AreEqual(ErrorMode.RmtJobErr, ((GoodException) JobErrs.ElementAt(0)).Mode);
- Assert.AreEqual(ErrorMode.RmtJobErr, ((GoodException) JobErrs.ElementAt(1)).Mode);
}
/// <summary>
@@ -174,10 +172,9 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(1, res);
- Assert.AreEqual(2, JobErrs.Count);
+ Assert.AreEqual(1, JobErrs.Count);
Assert.IsNotNull(JobErrs.ElementAt(0) as IgniteException);
- Assert.IsNotNull(JobErrs.ElementAt(1) as IgniteException);
}
/// <summary>
@@ -192,10 +189,9 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(1, res);
- Assert.AreEqual(2, JobErrs.Count);
+ Assert.AreEqual(1, JobErrs.Count);
Assert.IsNotNull(JobErrs.ElementAt(0) as IgniteException);
- Assert.IsNotNull(JobErrs.ElementAt(1) as IgniteException);
}
/// <summary>
@@ -298,7 +294,7 @@ namespace Apache.Ignite.Core.Tests.Compute
int res = Execute();
- Assert.AreEqual(3, res);
+ Assert.AreEqual(2, res);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
index da72c7b..522341a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
@@ -50,7 +50,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
int res = Grid1.GetCompute().Execute(new InjectionTask(), 0);
- Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res);
+ Assert.AreEqual(GetServerCount(), res);
}
/// <summary>
@@ -61,7 +61,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
var res = Grid1.GetCompute().Broadcast(new InjectionClosure(), 1);
- Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res.Sum());
+ Assert.AreEqual(GetServerCount(), res.Sum());
}
/// <summary>
@@ -72,7 +72,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
int res = Grid1.GetCompute().Apply(new InjectionClosure(), new List<int> { 1, 1, 1 }, new InjectionReducer());
- Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res);
+ Assert.AreEqual(3, res);
}
/// <summary>
@@ -83,7 +83,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
int res = Grid1.GetCompute().Execute(new NoResultCacheTask(), 0);
- Assert.AreEqual(Grid1.GetCluster().GetNodes().Count, res);
+ Assert.AreEqual(GetServerCount(), res);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
index 8418306..7789ac4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
@@ -15,10 +15,13 @@
* limitations under the License.
*/
+#pragma warning disable 649
+#pragma warning disable 169
namespace Apache.Ignite.Core.Tests.Compute
{
using System;
using System.Collections.Generic;
+ using System.Linq;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Resource;
@@ -50,7 +53,7 @@ namespace Apache.Ignite.Core.Tests.Compute
HashSet<Guid> allNodes = new HashSet<Guid>();
- for (int i = 0; i < 20 && allNodes.Count < 3; i++)
+ for (int i = 0; i < 20 && allNodes.Count < GetServerCount(); i++)
{
HashSet<Guid> res = Grid1.GetCompute().Execute(new TestSplitTask(), 1);
@@ -59,7 +62,7 @@ namespace Apache.Ignite.Core.Tests.Compute
allNodes.UnionWith(res);
}
- Assert.AreEqual(3, allNodes.Count);
+ Assert.AreEqual(GetServerCount(), allNodes.Count);
HashSet<Guid> res2 = Grid1.GetCompute().Execute<int, Guid, HashSet<Guid>>(typeof(TestSplitTask), 3);
@@ -67,7 +70,7 @@ namespace Apache.Ignite.Core.Tests.Compute
Grid1.GetCompute().Execute(new TestSplitTask(), 100);
- Assert.AreEqual(3, allNodes.Count);
+ Assert.AreEqual(GetServerCount(), allNodes.Count);
}
/// <summary>
@@ -109,10 +112,13 @@ namespace Apache.Ignite.Core.Tests.Compute
/// </summary>
public class TestSplitTask : ComputeTaskSplitAdapter<int, Guid, HashSet<Guid>>
{
+ [InstanceResource]
+ private readonly IIgnite _ignite;
+
/** <inheritDoc /> */
override protected ICollection<IComputeJob<Guid>> Split(int gridSize, int arg)
{
- Assert.AreEqual(3, gridSize);
+ Assert.AreEqual(_ignite.GetCluster().GetNodes().Count(x => !x.IsClient), gridSize);
int jobsNum = arg;
@@ -241,7 +247,7 @@ namespace Apache.Ignite.Core.Tests.Compute
public class BinarizableJob : ComputeJobAdapter<bool>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private IIgnite _grid;
public BinarizableJob(params object[] args) : base(args)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
index 4bf1e21..26286de 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
@@ -169,7 +169,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
ICollection<int> res = Grid1.GetCompute().Broadcast(new BinarizableOutFunc());
- Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(2, res.Count);
foreach (int r in res)
Assert.AreEqual(10, r);
@@ -180,7 +180,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
ICollection<int> res = Grid1.GetCompute().Broadcast(new SerializableOutFunc());
- Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(2, res.Count);
foreach (int r in res)
Assert.AreEqual(10, r);
@@ -191,7 +191,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
ICollection<int> res = Grid1.GetCompute().Broadcast(new BinarizableFunc(), 10);
- Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(2, res.Count);
foreach (int r in res)
Assert.AreEqual(11, r);
@@ -202,7 +202,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
ICollection<int> res = Grid1.GetCompute().Broadcast(new SerializableFunc(), 10);
- Assert.AreEqual(3, res.Count);
+ Assert.AreEqual(2, res.Count);
foreach (int r in res)
Assert.AreEqual(11, r);
@@ -282,7 +282,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
_gridName = null;
- Assert.AreEqual(3, subgrid.Count);
+ Assert.AreEqual(2, subgrid.Count);
bool local = arg.Item1;
T res = arg.Item2;
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
index 6f51f4a..c2ccd1a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -255,7 +255,7 @@ namespace Apache.Ignite.Core.Tests
EventType = EventType.JobExecutionAll,
EventObjectType = typeof (JobEvent),
GenerateEvent = g => GenerateTaskEvent(g),
- EventCount = 9
+ EventCount = 7
};
yield return new EventTestCase
@@ -447,7 +447,7 @@ namespace Apache.Ignite.Core.Tests
var qryResult = remoteQuery.Except(oldEvents).Cast<JobEvent>().ToList();
- Assert.AreEqual(_grids.Length, qryResult.Count);
+ Assert.AreEqual(_grids.Length - 1, qryResult.Count);
Assert.IsTrue(qryResult.All(x => x.Type == EventType.JobStarted));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/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 3269651..e114f5a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
@@ -155,7 +155,7 @@ namespace Apache.Ignite.Core.Tests.Services
Assert.AreEqual(1, Grid1.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
Assert.AreEqual(1, Grid2.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
- Assert.AreEqual(1, Grid3.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
+ Assert.AreEqual(0, Grid3.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
}
/// <summary>
@@ -204,7 +204,7 @@ namespace Apache.Ignite.Core.Tests.Services
Services.DeployMultiple(SvcName, svc, Grids.Length * 5, 5);
- foreach (var grid in Grids)
+ foreach (var grid in Grids.Where(x => !x.GetConfiguration().ClientMode))
CheckServiceStarted(grid, 5);
}
@@ -250,15 +250,14 @@ namespace Apache.Ignite.Core.Tests.Services
? new TestIgniteServiceBinarizable {TestProperty = 17}
: new TestIgniteServiceSerializable {TestProperty = 17};
- Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id, Grid3.GetCluster().GetLocalNode().Id).GetServices()
- .DeployNodeSingleton(SvcName,
- svc);
+ Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id, Grid1.GetCluster().GetLocalNode().Id)
+ .GetServices().DeployNodeSingleton(SvcName, svc);
- // Make sure there is no local instance on grid1
- Assert.IsNull(Services.GetService<ITestIgniteService>(SvcName));
+ // Make sure there is no local instance on grid3
+ Assert.IsNull(Grid3.GetServices().GetService<ITestIgniteService>(SvcName));
// Get proxy
- var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
+ var prx = Grid3.GetServices().GetServiceProxy<ITestIgniteService>(SvcName);
// Check proxy properties
Assert.IsNotNull(prx);
@@ -282,7 +281,7 @@ namespace Apache.Ignite.Core.Tests.Services
Assert.AreEqual(2, invokedIds.Count);
// Check sticky = true: all calls should be to the same node
- prx = Services.GetServiceProxy<ITestIgniteService>(SvcName, true);
+ prx = Grid3.GetServices().GetServiceProxy<ITestIgniteService>(SvcName, true);
invokedIds = Enumerable.Range(1, 100).Select(x => prx.NodeId).Distinct().ToList();
Assert.AreEqual(1, invokedIds.Count);
@@ -469,7 +468,7 @@ namespace Apache.Ignite.Core.Tests.Services
{
var svc = new TestIgniteServiceSerializable { ThrowCancel = true };
- Services.DeployMultiple(SvcName, svc, Grids.Length, 1);
+ Services.DeployMultiple(SvcName, svc, 2, 1);
CheckServiceStarted(Grid1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
index 74ea846..505d972 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
@@ -21,7 +21,9 @@ namespace Apache.Ignite.Core.Tests
using System.Diagnostics;
using System.Reflection;
using Apache.Ignite.Core.Tests.Cache.Query;
+ using Apache.Ignite.Core.Tests.Compute;
using Apache.Ignite.Core.Tests.Memory;
+ using Apache.Ignite.Core.Tests.Services;
using NUnit.ConsoleRunner;
public static class TestRunner
@@ -32,9 +34,9 @@ namespace Apache.Ignite.Core.Tests
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
Debug.AutoFlush = true;
- TestOne(typeof(CacheLinqTest), "TestExcept");
+ //TestOne(typeof(CacheLinqTest), "TestExcept");
- //TestAll(typeof (CacheQueriesCodeConfigurationTest));
+ TestAll(typeof (TaskAdapterTest));
//TestAllInAssembly();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
index 4c2df73..bb9adbf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cluster/IClusterGroup.cs
@@ -180,6 +180,12 @@ namespace Apache.Ignite.Core.Cluster
IClusterGroup ForDotNet();
/// <summary>
+ /// Creates a cluster group of nodes started in server mode (<see cref="IgniteConfiguration.ClientMode"/>).
+ /// </summary>
+ /// <returns>Cluster group of nodes started in server mode.</returns>
+ IClusterGroup ForServers();
+
+ /// <summary>
/// Gets read-only collections of nodes in this projection.
/// </summary>
/// <returns>All nodes in this projection.</returns>
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index e6c0005..95497f3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -312,6 +312,12 @@ namespace Apache.Ignite.Core.Impl.Cluster
}
/** <inheritDoc /> */
+ public IClusterGroup ForServers()
+ {
+ return GetClusterGroup(UU.ProjectionForServers(Target));
+ }
+
+ /** <inheritDoc /> */
public IClusterGroup ForDotNet()
{
return ForAttribute(AttrPlatform, Platform);
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 0706966..5e2a5d7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -201,7 +201,7 @@ namespace Apache.Ignite.Core.Impl
/** <inheritdoc /> */
public ICompute GetCompute()
{
- return _prj.GetCompute();
+ return _prj.ForServers().GetCompute();
}
/** <inheritdoc /> */
@@ -305,6 +305,12 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public IClusterGroup ForServers()
+ {
+ return _prj.ForServers();
+ }
+
+ /** <inheritdoc /> */
public ICollection<IClusterNode> GetNodes()
{
return _prj.GetNodes();
@@ -536,7 +542,7 @@ namespace Apache.Ignite.Core.Impl
/** <inheritdoc /> */
public IServices GetServices()
{
- return _prj.GetServices();
+ return _prj.ForServers().GetServices();
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
index 0ad056a..957018e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -190,6 +190,12 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public IClusterGroup ForServers()
+ {
+ return _ignite.GetCluster().ForServers();
+ }
+
+ /** <inheritdoc /> */
public ICollection<IClusterNode> GetNodes()
{
return _ignite.GetCluster().GetNodes();
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
index bb26382..4619080 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
@@ -273,6 +273,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionForYoungest")]
public static extern void* ProjectionForYoungest(void* ctx, void* obj);
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionForServers")]
+ public static extern void* ProjectionForServers(void* ctx, void* obj);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProjectionResetMetrics")]
public static extern void ProjectionResetMetrics(void* ctx, void* obj);
http://git-wip-us.apache.org/repos/asf/ignite/blob/277480c2/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index a0abfaa..924259c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -693,6 +693,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
return target.ChangeTarget(res);
}
+ internal static IUnmanagedTarget ProjectionForServers(IUnmanagedTarget target)
+ {
+ void* res = JNI.ProjectionForServers(target.Context, target.Target);
+
+ return target.ChangeTarget(res);
+ }
+
internal static void ProjectionResetMetrics(IUnmanagedTarget target)
{
JNI.ProjectionResetMetrics(target.Context, target.Target);