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

jerrick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new 9f21b9f  add timeout config to zookeeper client (#2217)
9f21b9f is described below

commit 9f21b9f8461cd8422ecd590df6854b045162dd1b
Author: Huang YunKun <[email protected]>
AuthorDate: Thu Aug 9 11:13:59 2018 +0800

    add timeout config to zookeeper client (#2217)
---
 .../dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java      | 4 +++-
 .../dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java    | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
 
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
index 5accb85..830eb31 100644
--- 
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
+++ 
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
@@ -16,6 +16,7 @@
  */
 package org.apache.dubbo.remoting.zookeeper.curator;
 
+import org.apache.dubbo.common.Constants;
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.utils.StringUtils;
 import org.apache.dubbo.remoting.zookeeper.ChildListener;
@@ -43,10 +44,11 @@ public class CuratorZookeeperClient extends 
AbstractZookeeperClient<CuratorWatch
     public CuratorZookeeperClient(URL url) {
         super(url);
         try {
+            int timeout = url.getParameter(Constants.TIMEOUT_KEY, 5000);
             CuratorFrameworkFactory.Builder builder = 
CuratorFrameworkFactory.builder()
                     .connectString(url.getBackupAddress())
                     .retryPolicy(new RetryNTimes(1, 1000))
-                    .connectionTimeoutMs(5000);
+                    .connectionTimeoutMs(timeout);
             String authority = url.getAuthority();
             if (authority != null && authority.length() > 0) {
                 builder = builder.authorization("digest", 
authority.getBytes());
diff --git 
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java
 
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java
index 8f0335e..4f7faeb 100644
--- 
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java
+++ 
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/zkclient/ZkclientZookeeperClient.java
@@ -16,6 +16,7 @@
  */
 package org.apache.dubbo.remoting.zookeeper.zkclient;
 
+import org.apache.dubbo.common.Constants;
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.remoting.zookeeper.ChildListener;
 import org.apache.dubbo.remoting.zookeeper.StateListener;
@@ -37,7 +38,8 @@ public class ZkclientZookeeperClient extends 
AbstractZookeeperClient<IZkChildLis
 
     public ZkclientZookeeperClient(URL url) {
         super(url);
-        client = new ZkClientWrapper(url.getBackupAddress(), 30000);
+        long timeout = url.getParameter(Constants.TIMEOUT_KEY, 30000L);
+        client = new ZkClientWrapper(url.getBackupAddress(), timeout);
         client.addListener(new IZkStateListener() {
             @Override
             public void handleStateChanged(KeeperState state) throws Exception 
{

Reply via email to