Attempt to fix awaitPartitionMapExchange: wait for last exchange completion to 
avoid races with cache destroy.


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

Branch: refs/heads/ignite-4535
Commit: d38348432a2b8b66999c6410ec4f5c1ef050191d
Parents: 36e7e19
Author: sboikov <sboi...@gridgain.com>
Authored: Wed Apr 19 12:46:31 2017 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Wed Apr 19 12:46:31 2017 +0300

----------------------------------------------------------------------
 .../junits/common/GridCommonAbstractTest.java   | 34 ++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d3834843/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 81f5caf..cef35e5 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
@@ -544,6 +544,27 @@ public abstract class GridCommonAbstractTest extends 
GridAbstractTest {
 
         Set<String> names = new HashSet<>();
 
+        Ignite crd = null;
+
+        for (Ignite g : G.allGrids()) {
+            ClusterNode node = g.cluster().localNode();
+
+            if (crd == null || node.order() < 
crd.cluster().localNode().order()) {
+                crd = g;
+
+                if (node.order() == 1)
+                    break;
+            }
+        }
+
+        if (crd == null)
+            return;
+
+        AffinityTopologyVersion waitTopVer = 
((IgniteKernal)crd).context().discovery().topologyVersionEx();
+
+        if (waitTopVer.topologyVersion() <= 0)
+            waitTopVer = new AffinityTopologyVersion(1, 0);
+
         for (Ignite g : G.allGrids()) {
             if (nodes != null && !nodes.contains(g.cluster().localNode()))
                 continue;
@@ -560,6 +581,19 @@ public abstract class GridCommonAbstractTest extends 
GridAbstractTest {
             else
                 startTime = g0.context().discovery().gridStartTime();
 
+            IgniteInternalFuture<?> exchFut =
+                
g0.context().cache().context().exchange().affinityReadyFuture(waitTopVer);
+
+            if (exchFut != null && !exchFut.isDone()) {
+                try {
+                    exchFut.get(timeout);
+                }
+                catch (IgniteCheckedException e) {
+                    log.error("Failed to wait for exchange [topVer=" + 
waitTopVer +
+                        ", node=" + g0.name() + ']', e);
+                }
+            }
+
             for (IgniteCacheProxy<?, ?> c : g0.context().cache().jcaches()) {
                 CacheConfiguration cfg = c.context().config();
 

Reply via email to