Repository: ignite Updated Branches: refs/heads/ignite-1093-3 340c2b5fa -> bee5e9c0a
1093 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bee5e9c0 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bee5e9c0 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bee5e9c0 Branch: refs/heads/ignite-1093-3 Commit: bee5e9c0a7ae48970edf86b76deb2ccca9900343 Parents: 340c2b5 Author: Anton Vinogradov <[email protected]> Authored: Wed Nov 4 12:39:16 2015 +0300 Committer: Anton Vinogradov <[email protected]> Committed: Wed Nov 4 12:39:16 2015 +0300 ---------------------------------------------------------------------- .../GridCacheRebalancingSyncSelfTest.java | 20 +--- .../junits/common/GridCommonAbstractTest.java | 112 ++----------------- 2 files changed, 14 insertions(+), 118 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/bee5e9c0/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 2a64307..8c5cd40 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 @@ -266,9 +266,9 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { concurrentStartFinished = true; - awaitPartitionMapExchange(); + awaitPartitionMapExchange(true); - awaitPartitionEviction(); + checkSupplyContextMapIsEmpty(); t1.join(); t2.join(); @@ -435,9 +435,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { waitForRebalancing(3, 5, 1); waitForRebalancing(4, 5, 1); - awaitPartitionMapExchange(); - - awaitPartitionEviction(); + awaitPartitionMapExchange(true); checkSupplyContextMapIsEmpty(); @@ -461,9 +459,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { waitForRebalancing(3, 6); waitForRebalancing(4, 6); - awaitPartitionMapExchange(); - - awaitPartitionEviction(); + awaitPartitionMapExchange(true); checkSupplyContextMapIsEmpty(); @@ -473,9 +469,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { waitForRebalancing(3, 7); waitForRebalancing(4, 7); - awaitPartitionMapExchange(); - - awaitPartitionEviction(); + awaitPartitionMapExchange(true); checkSupplyContextMapIsEmpty(); @@ -484,9 +478,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { waitForRebalancing(3, 8); waitForRebalancing(4, 8); - awaitPartitionMapExchange(); - - awaitPartitionEviction(); + awaitPartitionMapExchange(true); checkSupplyContextMapIsEmpty(); http://git-wip-us.apache.org/repos/asf/ignite/blob/bee5e9c0/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 c3d0690..71f3ee3 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 @@ -413,117 +413,18 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { /** * @throws InterruptedException If interrupted. - * Should be run after awaitPartitionMapExchange. */ @SuppressWarnings("BusyWait") - protected void awaitPartitionEviction() throws InterruptedException { - for (Ignite g : G.allGrids()) { - IgniteKernal g0 = (IgniteKernal)g; - - for (IgniteCacheProxy<?, ?> c : g0.context().cache().jcaches()) { - CacheConfiguration cfg = c.context().config(); - - if (cfg.getCacheMode() == PARTITIONED && - cfg.getRebalanceMode() != NONE && - g.cluster().nodes().size() > 1) { - AffinityFunction aff = cfg.getAffinity(); - - GridDhtCacheAdapter<?, ?> dht = dht(c); - - GridDhtPartitionTopology top = dht.topology(); - - for (int p = 0; p < aff.partitions(); p++) { - long start = 0; - - for (int i = 0; ; i++) { - boolean match = false; - - AffinityTopologyVersion readyVer = dht.context().shared().exchange().readyAffinityVersion(); - - if (readyVer.topologyVersion() > 0 && c.context().started()) { - // Must map on updated version of topology. - Collection<ClusterNode> affNodes = - g0.affinity(cfg.getName()).mapPartitionToPrimaryAndBackups(p); - - int exp = affNodes.size(); - - GridDhtTopologyFuture topFut = top.topologyVersionFuture(); - - Collection<ClusterNode> owners = (topFut != null && topFut.isDone()) ? - top.nodes(p, AffinityTopologyVersion.NONE) : Collections.<ClusterNode>emptyList(); - - int actual = owners.size(); - - GridDhtLocalPartition loc = top.localPartition(p, readyVer, false); - - if (loc != null && loc.state() == GridDhtPartitionState.RENTING) { - LT.warn(log(), null, "Waiting for evictions [" + - "grid=" + g.name() + - ", cache=" + cfg.getName() + - ", cacheId=" + dht.context().cacheId() + - ", topVer=" + top.topologyVersion() + - ", topFut=" + topFut + - ", p=" + p + - ", affNodesCnt=" + exp + - ", ownersCnt=" + actual + - ", affNodes=" + affNodes + - ", owners=" + owners + - ", locNode=" + g.cluster().localNode() + ']'); - } - else - match = true; - } - else { - LT.warn(log(), null, "Waiting for evictions [" + - "grid=" + g.name() + - ", cache=" + cfg.getName() + - ", cacheId=" + dht.context().cacheId() + - ", topVer=" + top.topologyVersion() + - ", started=" + dht.context().started() + - ", p=" + p + - ", readVer=" + readyVer + - ", locNode=" + g.cluster().localNode() + ']'); - } - - if (!match) { - if (i == 0) - start = System.currentTimeMillis(); - - if (System.currentTimeMillis() - start > 30_000) { - U.dumpThreads(log); - - throw new IgniteException("Timeout of waiting for evictions [" + - "grid=" + g.name() + - ", cache=" + cfg.getName() + - ", cacheId=" + dht.context().cacheId() + - ", topVer=" + top.topologyVersion() + - ", p=" + p + - ", readVer=" + readyVer + - ", locNode=" + g.cluster().localNode() + ']'); - } - - Thread.sleep(200); // Busy wait. - - continue; - } - - if (i > 0) - log().warning("Finished waiting for topology map update [grid=" + g.name() + - ", p=" + p + ", duration=" + (System.currentTimeMillis() - start) + "ms]"); - - break; - } - } - } - } - } + protected void awaitPartitionMapExchange() throws InterruptedException { + awaitPartitionMapExchange(false); } /** + * @param waitEvicts If {@code true} will wait for evictions finished. * @throws InterruptedException If interrupted. */ @SuppressWarnings("BusyWait") - protected void awaitPartitionMapExchange() throws InterruptedException { + protected void awaitPartitionMapExchange(boolean waitEvicts) throws InterruptedException { for (Ignite g : G.allGrids()) { IgniteKernal g0 = (IgniteKernal)g; @@ -561,7 +462,10 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { int actual = owners.size(); - if (affNodes.size() != owners.size() || !affNodes.containsAll(owners)) { + GridDhtLocalPartition loc = top.localPartition(p, readyVer, false); + + if (affNodes.size() != owners.size() || !affNodes.containsAll(owners) || + (waitEvicts && loc != null && loc.state() == GridDhtPartitionState.RENTING)) { LT.warn(log(), null, "Waiting for topology map update [" + "grid=" + g.name() + ", cache=" + cfg.getName() +
