ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: zk
Date Fri, 29 Dec 2017 10:12:33 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-zk 4c63e4238 -> 276152a99


zk


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

Branch: refs/heads/ignite-zk
Commit: 276152a9981a2cc0850230e96c1935e2c5841f16
Parents: 4c63e42
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Dec 29 13:12:23 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Dec 29 13:12:23 2017 +0300

----------------------------------------------------------------------
 .../zk/internal/ZookeeperDiscoveryImpl.java     | 12 ++++-----
 .../zk/internal/ZookeeperDiscoverySpiTest.java  | 26 +++++++++++++++++---
 2 files changed, 29 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/276152a9/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
index 8f717c4..ffade09 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
@@ -1485,6 +1485,12 @@ public class ZookeeperDiscoveryImpl {
             handleProcessedEvents("crd");
         }
         else {
+            String locAlivePath = rtState.locNodeZkPath.substring(rtState.locNodeZkPath.lastIndexOf('/')
+ 1);
+
+            deleteJoiningNodeData(locNode.id(),
+                ZkIgnitePaths.aliveNodePrefixId(locAlivePath),
+                rtState.joinDataPartCnt);
+
             DiscoverySpiNodeAuthenticator nodeAuth = spi.getAuthenticator();
 
             if (nodeAuth != null) {
@@ -2110,12 +2116,6 @@ public class ZookeeperDiscoveryImpl {
 
         rtState.top.addNode(locNode);
 
-        String locAlivePath = rtState.locNodeZkPath.substring(rtState.locNodeZkPath.lastIndexOf('/')
+ 1);
-
-        deleteJoiningNodeData(locNode.id(),
-            ZkIgnitePaths.aliveNodePrefixId(locAlivePath),
-            rtState.joinDataPartCnt);
-
         final List<ClusterNode> topSnapshot = Collections.singletonList((ClusterNode)locNode);
 
         lsnr.onDiscovery(EventType.EVT_NODE_JOINED,

http://git-wip-us.apache.org/repos/asf/ignite/blob/276152a9/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiTest.java
index e671f98..314e3ab 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiTest.java
@@ -105,6 +105,7 @@ import org.apache.ignite.spi.discovery.DiscoverySpiNodeAuthenticator;
 import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZKUtil;
 import org.apache.zookeeper.ZkTestClientCnxnSocketNIO;
 import org.apache.zookeeper.ZooKeeper;
@@ -1901,7 +1902,7 @@ public class ZookeeperDiscoverySpiTest extends GridCommonAbstractTest
{
         final String aliveDir = basePath + ZkIgnitePaths.ALIVE_NODES_DIR + "/";
 
         try {
-            List<String> znodes = ZKUtil.listSubTreeBFS(zkClient.zk(), IGNITE_ZK_ROOT);
+            List<String> znodes = listSubTree(zkClient.zk(), IGNITE_ZK_ROOT);
 
             boolean foundAlive = false;
 
@@ -1915,10 +1916,10 @@ public class ZookeeperDiscoverySpiTest extends GridCommonAbstractTest
{
 
             assertTrue(foundAlive); // Sanity check to make sure we check correct directory.
 
-            assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            assertTrue("Failed to wait for unused znodes cleanup", GridTestUtils.waitForCondition(new
GridAbsPredicate() {
                 @Override public boolean apply() {
                     try {
-                        List<String> znodes = ZKUtil.listSubTreeBFS(zkClient.zk(),
IGNITE_ZK_ROOT);
+                        List<String> znodes = listSubTree(zkClient.zk(), IGNITE_ZK_ROOT);
 
                         for (String znode : znodes) {
                             if (znode.startsWith(aliveDir) || znode.length() < basePath.length())
@@ -3798,6 +3799,25 @@ public class ZookeeperDiscoverySpiTest extends GridCommonAbstractTest
{
     }
 
     /**
+     * @param zk ZooKeeper client.
+     * @param root Root path.
+     * @return All children znodes for given path.
+     * @throws Exception If failed/
+     */
+    private List<String> listSubTree(ZooKeeper zk, String root) throws Exception {
+        for (int i = 0; i < 30; i++) {
+            try {
+                return ZKUtil.listSubTreeBFS(zk, root);
+            }
+            catch (KeeperException.NoNodeException e) {
+                info("NoNodeException when get znodes, will retry: " + e);
+            }
+        }
+
+        throw new Exception("Failed to get znodes: " + root);
+    }
+
+    /**
      * @param log Logger.
      * @param latch Latch.
      * @throws Exception If failed.


Mime
View raw message