optimize curator client parameters

This commit is contained in:
DigitalSonic
2021-06-21 10:49:20 +08:00
parent 584dcb6c69
commit f1e008b2bb
2 changed files with 6 additions and 6 deletions
@@ -26,7 +26,7 @@ import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.retry.RetryForever;
import java.io.IOException;
import java.io.StringReader;
@@ -88,9 +88,9 @@ public class ZookeeperNodeListener extends NodeListener {
if (client == null) {
client = CuratorFrameworkFactory.builder()
.canBeReadOnly(true)
.connectionTimeoutMs(3000)
.connectionTimeoutMs(5000)
.connectString(zkConnectString)
.retryPolicy(new ExponentialBackoffRetry(5000, 3, 30000))
.retryPolicy(new RetryForever(10000))
.sessionTimeoutMs(30000)
.build();
client.start();
@@ -20,7 +20,7 @@ import com.alibaba.druid.support.logging.LogFactory;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.nodes.GroupMember;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.retry.RetryForever;
import java.io.IOException;
import java.io.StringWriter;
@@ -49,9 +49,9 @@ public class ZookeeperNodeRegister {
public void init() {
if (client == null) {
client = CuratorFrameworkFactory.builder()
.connectionTimeoutMs(3000)
.connectionTimeoutMs(5000)
.connectString(zkConnectString)
.retryPolicy(new ExponentialBackoffRetry(5000, 3, 30000))
.retryPolicy(new RetryForever(10000))
.sessionTimeoutMs(30000)
.build();
client.start();