ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-1.5 Properly handle duplicated job responses in GridTaskWorker.onResponse.
Date Fri, 18 Dec 2015 07:11:24 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1537 1995b97a1 -> 0de549342


ignite-1.5 Properly handle duplicated job responses in GridTaskWorker.onResponse.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0de54934
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0de54934
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0de54934

Branch: refs/heads/ignite-1537
Commit: 0de5493422cbe2e3753015c78c2152507abe785f
Parents: 1995b97
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Dec 18 10:11:15 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Dec 18 10:11:15 2015 +0300

----------------------------------------------------------------------
 .../internal/cluster/ClusterGroupAdapter.java   | 10 +++++-
 .../internal/util/lang/GridNodePredicate.java   | 13 +++++---
 .../ignite/internal/ClusterGroupSelfTest.java   | 32 ++++++++++++++++++--
 3 files changed, 48 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0de54934/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 9039ed8..75168a1 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
@@ -626,7 +626,15 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable
{
 
     /** {@inheritDoc} */
     @Override public final ClusterGroup forRandom() {
-        return ids != null ? forNodeId(F.rand(ids)) : forNode(F.rand(nodes()));
+        if (!F.isEmpty(ids))
+            return forNodeId(F.rand(ids));
+
+        Collection<ClusterNode> nodes = nodes();
+
+        if (nodes.isEmpty())
+            return new ClusterGroupAdapter(ctx, null, Collections.<UUID>emptySet());
+
+        return forNode(F.rand(nodes));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/0de54934/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridNodePredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridNodePredicate.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridNodePredicate.java
index 4ce0b35..edec862 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridNodePredicate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridNodePredicate.java
@@ -100,13 +100,18 @@ public class GridNodePredicate implements IgnitePredicate<ClusterNode>,
Iterable
     public GridNodePredicate(@Nullable ClusterNode... nodes) {
         if (F.isEmpty(nodes))
             ids = Collections.emptySet();
-        else if (nodes.length == 1)
-            ids = Collections.singleton(nodes[0].id());
+        else if (nodes.length == 1) {
+            ClusterNode node = nodes[0];
+
+            ids = node != null ? Collections.singleton(node.id()) : Collections.<UUID>emptySet();
+        }
         else {
             ids = U.newHashSet(nodes.length);
 
-            for (ClusterNode n : nodes)
-                ids.add(n.id());
+            for (ClusterNode n : nodes) {
+                if (n != null)
+                    ids.add(n.id());
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0de54934/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 d916d78..18eb3b7 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
@@ -109,6 +109,10 @@ public class ClusterGroupSelfTest extends ClusterGroupAbstractTest {
         }
 
         assertEquals(oldest.node(), ignite.cluster().forNode(node).node());
+
+        ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val");
+
+        assertEquals(0, emptyGrp.forOldest().nodes().size());
     }
 
     /**
@@ -130,6 +134,10 @@ public class ClusterGroupSelfTest extends ClusterGroupAbstractTest {
         }
 
         assertEquals(youngest.node(), ignite.cluster().forNode(node).node());
+
+        ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val");
+
+        assertEquals(0, emptyGrp.forYoungest().nodes().size());
     }
 
     /**
@@ -187,8 +195,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();
 
@@ -241,6 +248,27 @@ public class ClusterGroupSelfTest extends ClusterGroupAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testEmptyGroup() throws Exception {
+        ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val");
+
+        assertEquals(0, emptyGrp.forOldest().nodes().size());
+        assertEquals(0, emptyGrp.forYoungest().nodes().size());
+        assertEquals(0, emptyGrp.forAttribute("nonExistent2", "val").nodes().size());
+        assertEquals(0, emptyGrp.forCacheNodes("cacheName").nodes().size());
+        assertEquals(0, emptyGrp.forClientNodes("cacheName").nodes().size());
+        assertEquals(0, emptyGrp.forClients().nodes().size());
+        assertEquals(0, emptyGrp.forDaemons().nodes().size());
+        assertEquals(0, emptyGrp.forDataNodes("cacheName").nodes().size());
+        assertEquals(0, emptyGrp.forRandom().nodes().size());
+        assertEquals(0, emptyGrp.forRemotes().nodes().size());
+        assertEquals(0, emptyGrp.forServers().nodes().size());
+        assertEquals(0, emptyGrp.forHost(ignite.cluster().localNode()).nodes().size());
+        assertEquals(0, emptyGrp.forHost("127.0.0.1").nodes().size());
+    }
+
+    /**
      * @param cnt Count.
      * @param even Even.
      */


Mime
View raw message