You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/12/12 03:24:04 UTC

[dubbo] branch 2.6.x updated: dubbo zookeeper registry too slow (#5037)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch 2.6.x
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/2.6.x by this push:
     new 07bcafb  dubbo zookeeper registry too slow (#5037)
07bcafb is described below

commit 07bcafb3aed6801a12946e6547b2400ae85f0760
Author: 祁晓波 <qi...@gmail.com>
AuthorDate: Thu Dec 12 11:23:52 2019 +0800

    dubbo zookeeper registry too slow (#5037)
    
    same as 4828
---
 .../zookeeper/curator/CuratorZookeeperClient.java  |  2 +-
 .../zookeeper/support/AbstractZookeeperClient.java | 23 ++++++++++++++++++++++
 .../zkclient/ZkclientZookeeperClient.java          |  2 +-
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
index 8f3df7e..6ef258d 100644
--- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
+++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
@@ -93,7 +93,7 @@ public class CuratorZookeeperClient extends AbstractZookeeperClient<CuratorWatch
     }
 
     @Override
-    public void delete(String path) {
+    protected void deletePath(String path) {
         try {
             client.delete().forPath(path);
         } catch (NoNodeException e) {
diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/support/AbstractZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/support/AbstractZookeeperClient.java
index 685effd..0e078e1 100644
--- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/support/AbstractZookeeperClient.java
+++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/support/AbstractZookeeperClient.java
@@ -19,6 +19,7 @@ package com.alibaba.dubbo.remoting.zookeeper.support;
 import com.alibaba.dubbo.common.URL;
 import com.alibaba.dubbo.common.logger.Logger;
 import com.alibaba.dubbo.common.logger.LoggerFactory;
+import com.alibaba.dubbo.common.utils.ConcurrentHashSet;
 import com.alibaba.dubbo.remoting.zookeeper.ChildListener;
 import com.alibaba.dubbo.remoting.zookeeper.StateListener;
 import com.alibaba.dubbo.remoting.zookeeper.ZookeeperClient;
@@ -41,6 +42,8 @@ public abstract class AbstractZookeeperClient<TargetChildListener> implements Zo
 
     private volatile boolean closed = false;
 
+    private final Set<String>  persistentExistNodePath = new ConcurrentHashSet<String>();
+
     public AbstractZookeeperClient(URL url) {
         this.url = url;
     }
@@ -50,10 +53,23 @@ public abstract class AbstractZookeeperClient<TargetChildListener> implements Zo
         return url;
     }
 
+
+    @Override
+    public void delete(String path){
+        //never mind if ephemeral
+        persistentExistNodePath.remove(path);
+        deletePath(path);
+    }
+
+
     @Override
     public void create(String path, boolean ephemeral) {
         if (!ephemeral) {
+            if(persistentExistNodePath.contains(path)){
+                return;
+            }
             if (checkExists(path)) {
+                persistentExistNodePath.add(path);
                 return;
             }
         }
@@ -65,6 +81,8 @@ public abstract class AbstractZookeeperClient<TargetChildListener> implements Zo
             createEphemeral(path);
         } else {
             createPersistent(path);
+            persistentExistNodePath.add(path);
+
         }
     }
 
@@ -141,4 +159,9 @@ public abstract class AbstractZookeeperClient<TargetChildListener> implements Zo
 
     protected abstract void removeTargetChildListener(String path, TargetChildListener listener);
 
+    /**
+     * we invoke the zookeeper client to delete the node
+     * @param path the node path
+     */
+    protected abstract void deletePath(String path);
 }
diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java
index 82900f8..9157ae3 100644
--- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java
+++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/com/alibaba/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java
@@ -76,7 +76,7 @@ public class ZkclientZookeeperClient extends AbstractZookeeperClient<IZkChildLis
     }
 
     @Override
-    public void delete(String path) {
+    protected void deletePath(String path) {
         try {
             client.delete(path);
         } catch (ZkNoNodeException e) {