Repository: ignite Updated Branches: refs/heads/master dee6426c7 -> 51a25fa84
ignite-2911 Fixed ClusterGroup.forDaemons. This closes #657. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/51a25fa8 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/51a25fa8 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/51a25fa8 Branch: refs/heads/master Commit: 51a25fa8496ff6e084fd1ddca5eb5fed9b8f4d27 Parents: dee6426 Author: sboikov <sboi...@gridgain.com> Authored: Thu Jun 9 16:19:47 2016 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Thu Jun 9 16:19:47 2016 +0300 ---------------------------------------------------------------------- .../internal/cluster/ClusterGroupAdapter.java | 18 ++++++------ .../ignite/internal/ClusterGroupSelfTest.java | 30 ++++++++++++++++++-- 2 files changed, 37 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/51a25fa8/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java index c664f1e..e4b45f0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java @@ -109,8 +109,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable { */ protected ClusterGroupAdapter(@Nullable GridKernalContext ctx, @Nullable UUID subjId, - @Nullable IgnitePredicate<ClusterNode> p) - { + @Nullable IgnitePredicate<ClusterNode> p) { if (ctx != null) setKernalContext(ctx); @@ -127,8 +126,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable { */ protected ClusterGroupAdapter(@Nullable GridKernalContext ctx, @Nullable UUID subjId, - Set<UUID> ids) - { + Set<UUID> ids) { if (ctx != null) setKernalContext(ctx); @@ -149,8 +147,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable { private ClusterGroupAdapter(@Nullable GridKernalContext ctx, @Nullable UUID subjId, @Nullable IgnitePredicate<ClusterNode> p, - Set<UUID> ids) - { + Set<UUID> ids) { if (ctx != null) setKernalContext(ctx); @@ -311,7 +308,12 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable { } } else { - Collection<ClusterNode> all = ctx.discovery().allNodes(); + Collection<ClusterNode> all; + + if (p instanceof DaemonFilter) + all = F.concat(false, ctx.discovery().daemonNodes(), ctx.discovery().allNodes()); + else + all = ctx.discovery().allNodes(); return p != null ? F.view(all, p) : all; } @@ -1068,4 +1070,4 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable { "', p='" + p.getClass().getName() + "']"; } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/51a25fa8/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java index 18eb3b7..ebc1097 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java @@ -143,6 +143,31 @@ public class ClusterGroupSelfTest extends ClusterGroupAbstractTest { /** * @throws Exception If failed. */ + public void testForDaemons() throws Exception { + assertEquals(4, ignite.cluster().nodes().size()); + + ClusterGroup daemons = ignite.cluster().forDaemons(); + ClusterGroup srvs = ignite.cluster().forServers(); + + assertEquals(0, daemons.nodes().size()); + assertEquals(2, srvs.nodes().size()); + + Ignition.setDaemon(true); + + try (Ignite g = startGrid(NODES_CNT)) { + Ignition.setDaemon(false); + + try (Ignite g1 = startGrid(NODES_CNT + 1)) { + assertEquals(1, ignite.cluster().forDaemons().nodes().size()); + assertEquals(3, srvs.nodes().size()); + assertEquals(1, daemons.nodes().size()); + } + } + } + + /** + * @throws Exception If failed. + */ public void testNewNodes() throws Exception { ClusterGroup youngest = ignite.cluster().forYoungest(); ClusterGroup oldest = ignite.cluster().forOldest(); @@ -195,8 +220,7 @@ public class ClusterGroupSelfTest extends ClusterGroupAbstractTest { assertEquals(grid(gridMaxOrder(clusterSize, false)).localNode().id(), oddYoungest.node().id()); assertEquals(grid(2).localNode().id(), oddOldest.node().id()); - try (Ignite g4 = startGrid(NODES_CNT); Ignite g5 = startGrid(NODES_CNT + 1)) - { + try (Ignite g4 = startGrid(NODES_CNT); Ignite g5 = startGrid(NODES_CNT + 1)) { clusterSize = g4.cluster().nodes().size(); assertEquals(grid(gridMaxOrder(clusterSize, true)).localNode().id(), evenYoungest.node().id()); @@ -279,4 +303,4 @@ public class ClusterGroupSelfTest extends ClusterGroupAbstractTest { return even ? cnt - 1 : cnt - 2; } -} \ No newline at end of file +}