Skip to content

Commit

Permalink
optimize: support the default timeout for zookeeper register (apache#…
Browse files Browse the repository at this point in the history
  • Loading branch information
funky-eyes authored Apr 24, 2020
1 parent 141891e commit 496aaa6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public class ZookeeperRegisterServiceImpl implements RegistryService<IZkChildLis
private static final String AUTH_PASSWORD = "password";
private static final String SESSION_TIME_OUT_KEY = "sessionTimeout";
private static final String CONNECT_TIME_OUT_KEY = "connectTimeout";
private static final int DEFAULT_SESSION_TIMEOUT = 6000;
private static final int DEFAULT_CONNECT_TIMEOUT = 2000;
private static final String FILE_CONFIG_KEY_PREFIX = FILE_ROOT_REGISTRY + FILE_CONFIG_SPLIT_CHAR + REGISTRY_TYPE
+ FILE_CONFIG_SPLIT_CHAR;
private static final String ROOT_PATH = ZK_PATH_SPLIT_CHAR + FILE_ROOT_REGISTRY + ZK_PATH_SPLIT_CHAR + REGISTRY_TYPE
Expand Down Expand Up @@ -208,8 +210,8 @@ private ZkClient getClientInstance() {
synchronized (ZookeeperRegisterServiceImpl.class) {
if (null == zkClient) {
zkClient = buildZkClient(FILE_CONFIG.getConfig(FILE_CONFIG_KEY_PREFIX + SERVER_ADDR_KEY),
FILE_CONFIG.getInt(FILE_CONFIG_KEY_PREFIX + SESSION_TIME_OUT_KEY),
FILE_CONFIG.getInt(FILE_CONFIG_KEY_PREFIX + CONNECT_TIME_OUT_KEY),
FILE_CONFIG.getInt(FILE_CONFIG_KEY_PREFIX + SESSION_TIME_OUT_KEY, DEFAULT_SESSION_TIMEOUT),
FILE_CONFIG.getInt(FILE_CONFIG_KEY_PREFIX + CONNECT_TIME_OUT_KEY, DEFAULT_CONNECT_TIMEOUT),
FILE_CONFIG.getConfig(FILE_CONFIG_KEY_PREFIX + AUTH_USERNAME),
FILE_CONFIG.getConfig(FILE_CONFIG_KEY_PREFIX + AUTH_PASSWORD));
}
Expand Down

0 comments on commit 496aaa6

Please sign in to comment.