You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/03/13 09:46:45 UTC

[31/50] [abbrv] ignite git commit: waitForRebalancing minor fix and relocation.

waitForRebalancing minor fix and relocation.


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

Branch: refs/heads/ignite-4705-2
Commit: e960eb70c0d6a4980883328150e2acf0233de6aa
Parents: f794715
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue Mar 7 15:46:24 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Mar 7 15:46:24 2017 +0300

----------------------------------------------------------------------
 .../GridCacheRebalancingSyncSelfTest.java       | 69 +-----------------
 .../junits/common/GridCommonAbstractTest.java   | 77 ++++++++++++++++++++
 2 files changed, 81 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e960eb70/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
index 3dfcd85..7e3ff5c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
@@ -237,8 +237,8 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
 
         int waitMinorVer = ignite.configuration().isLateAffinityAssignment() ? 1 : 0;
 
-        waitForRebalancing(0, new AffinityTopologyVersion(2, waitMinorVer));
-        waitForRebalancing(1, new AffinityTopologyVersion(2, waitMinorVer));
+        waitForRebalancing(0, 2, waitMinorVer);
+        waitForRebalancing(1, 2, waitMinorVer);
 
         awaitPartitionMapExchange(true, true, null);
 
@@ -258,8 +258,8 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
 
         startGrid(2);
 
-        waitForRebalancing(1, new AffinityTopologyVersion(4, waitMinorVer));
-        waitForRebalancing(2, new AffinityTopologyVersion(4, waitMinorVer));
+        waitForRebalancing(1, 4, waitMinorVer);
+        waitForRebalancing(2, 4, waitMinorVer);
 
         awaitPartitionMapExchange(true, true, null);
 
@@ -352,67 +352,6 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
     }
 
     /**
-     * @param id Node id.
-     * @param major Major ver.
-     * @param minor Minor ver.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected void waitForRebalancing(int id, int major, int minor) throws IgniteCheckedException {
-        waitForRebalancing(id, new AffinityTopologyVersion(major, minor));
-    }
-
-    /**
-     * @param id Node id.
-     * @param major Major ver.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected void waitForRebalancing(int id, int major) throws IgniteCheckedException {
-        waitForRebalancing(id, new AffinityTopologyVersion(major));
-    }
-
-    /**
-     * @param id Node id.
-     * @param top Topology version.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected void waitForRebalancing(int id, AffinityTopologyVersion top) throws IgniteCheckedException {
-        boolean finished = false;
-
-        long stopTime = System.currentTimeMillis() + 60_000;
-
-        while (!finished && (System.currentTimeMillis() < stopTime)) {
-            finished = true;
-
-            for (GridCacheAdapter c : grid(id).context().cache().internalCaches()) {
-                GridDhtPartitionDemander.RebalanceFuture fut = (GridDhtPartitionDemander.RebalanceFuture)c.preloader().rebalanceFuture();
-                if (fut.topologyVersion() == null || fut.topologyVersion().compareTo(top) < 0) {
-                    finished = false;
-
-                    log.info("Unexpected future version, will retry [futVer=" + fut.topologyVersion() +
-                        ", expVer=" + top + ']');
-
-                    U.sleep(1000);
-
-                    break;
-                }
-                else {
-                    finished = fut.get();
-
-                    if (!finished) {
-                        log.warning("Rebalancing finished with missed partitions: " + fut.topologyVersion());
-
-                        U.sleep(100);
-                    }
-                    else
-                        break;
-                }
-            }
-        }
-
-        assertTrue(finished);
-    }
-
-    /**
      * @throws Exception If failed.
      */
     @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")

http://git-wip-us.apache.org/repos/asf/ignite/blob/e960eb70/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 549c486..3bdf0bd 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -58,6 +58,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.events.Event;
 import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
@@ -71,6 +72,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartit
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
 import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
 import org.apache.ignite.internal.processors.cache.local.GridLocalCache;
@@ -610,6 +612,81 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
     }
 
     /**
+     * @param id Node id.
+     * @param major Major ver.
+     * @param minor Minor ver.
+     * @throws IgniteCheckedException If failed.
+     */
+    protected void waitForRebalancing(int id, int major, int minor) throws IgniteCheckedException {
+        waitForRebalancing(grid(id), new AffinityTopologyVersion(major, minor));
+    }
+
+    /**
+     * @param id Node id.
+     * @param major Major ver.
+     * @throws IgniteCheckedException If failed.
+     */
+    protected void waitForRebalancing(int id, int major) throws IgniteCheckedException {
+        waitForRebalancing(grid(id), new AffinityTopologyVersion(major));
+    }
+
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    protected void waitForRebalancing() throws IgniteCheckedException {
+        for (Ignite ignite : G.allGrids())
+            waitForRebalancing((IgniteEx)ignite, null);
+    }
+
+    /**
+     * @param ignite Node.
+     * @param top Topology version.
+     * @throws IgniteCheckedException If failed.
+     */
+    protected void waitForRebalancing(IgniteEx ignite, AffinityTopologyVersion top) throws IgniteCheckedException {
+        if (ignite.configuration().isClientMode())
+            return;
+
+        boolean finished = false;
+
+        long stopTime = System.currentTimeMillis() + 60_000;
+
+        while (!finished && (System.currentTimeMillis() < stopTime)) {
+            finished = true;
+
+            if (top == null)
+                top = ignite.context().discovery().topologyVersionEx();
+
+            for (GridCacheAdapter c : ignite.context().cache().internalCaches()) {
+                GridDhtPartitionDemander.RebalanceFuture fut =
+                    (GridDhtPartitionDemander.RebalanceFuture)c.preloader().rebalanceFuture();
+
+                if (fut.topologyVersion() == null || fut.topologyVersion().compareTo(top) < 0) {
+                    finished = false;
+
+                    log.info("Unexpected future version, will retry [futVer=" + fut.topologyVersion() +
+                        ", expVer=" + top + ']');
+
+                    U.sleep(100);
+
+                    break;
+                }
+                else if (!fut.get()) {
+                    finished = false;
+
+                    log.warning("Rebalancing finished with missed partitions.");
+
+                    U.sleep(100);
+
+                    break;
+                }
+            }
+        }
+
+        assertTrue(finished);
+    }
+
+    /**
      * @param ignite Node.
      */
     public void dumpCacheDebugInfo(Ignite ignite) {