fix: Support close the Curator EnsembleTracker (#14281)
This commit is contained in:
parent
9fde4c9e60
commit
473ea36b04
|
|
@ -646,4 +646,6 @@ public interface CommonConstants {
|
||||||
String DUBBO_MANUAL_REGISTER_KEY = "dubbo.application.manual-register";
|
String DUBBO_MANUAL_REGISTER_KEY = "dubbo.application.manual-register";
|
||||||
|
|
||||||
String DUBBO2_COMPACT_ENABLE = "dubbo.compact.enable";
|
String DUBBO2_COMPACT_ENABLE = "dubbo.compact.enable";
|
||||||
|
|
||||||
|
String ZOOKEEPER_ENSEMBLE_TRACKER_KEY = "zookeeper.ensemble.tracker";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ public abstract class AbstractZookeeperClient<TargetDataListener, TargetChildLis
|
||||||
// may hang up to wait name resolution up to 10s
|
// may hang up to wait name resolution up to 10s
|
||||||
protected int DEFAULT_CONNECTION_TIMEOUT_MS = 30 * 1000;
|
protected int DEFAULT_CONNECTION_TIMEOUT_MS = 30 * 1000;
|
||||||
protected int DEFAULT_SESSION_TIMEOUT_MS = 60 * 1000;
|
protected int DEFAULT_SESSION_TIMEOUT_MS = 60 * 1000;
|
||||||
|
protected boolean DEFAULT_ENSEMBLE_TRACKER = true;
|
||||||
|
|
||||||
private final URL url;
|
private final URL url;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import org.apache.zookeeper.data.Stat;
|
||||||
|
|
||||||
import static org.apache.dubbo.common.constants.CommonConstants.SESSION_KEY;
|
import static org.apache.dubbo.common.constants.CommonConstants.SESSION_KEY;
|
||||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||||
|
import static org.apache.dubbo.common.constants.CommonConstants.ZOOKEEPER_ENSEMBLE_TRACKER_KEY;
|
||||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_CONNECT_REGISTRY;
|
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_CONNECT_REGISTRY;
|
||||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
|
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
|
||||||
|
|
||||||
|
|
@ -74,10 +75,12 @@ public class Curator5ZookeeperClient
|
||||||
try {
|
try {
|
||||||
int timeout = url.getParameter(TIMEOUT_KEY, DEFAULT_CONNECTION_TIMEOUT_MS);
|
int timeout = url.getParameter(TIMEOUT_KEY, DEFAULT_CONNECTION_TIMEOUT_MS);
|
||||||
int sessionExpireMs = url.getParameter(SESSION_KEY, DEFAULT_SESSION_TIMEOUT_MS);
|
int sessionExpireMs = url.getParameter(SESSION_KEY, DEFAULT_SESSION_TIMEOUT_MS);
|
||||||
|
boolean ensembleTracker = url.getParameter(ZOOKEEPER_ENSEMBLE_TRACKER_KEY, DEFAULT_ENSEMBLE_TRACKER);
|
||||||
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
|
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
|
||||||
.connectString(url.getBackupAddress())
|
.connectString(url.getBackupAddress())
|
||||||
.retryPolicy(new RetryNTimes(1, 1000))
|
.retryPolicy(new RetryNTimes(1, 1000))
|
||||||
.connectionTimeoutMs(timeout)
|
.connectionTimeoutMs(timeout)
|
||||||
|
.ensembleTracker(ensembleTracker)
|
||||||
.sessionTimeoutMs(sessionExpireMs);
|
.sessionTimeoutMs(sessionExpireMs);
|
||||||
String userInformation = url.getUserInformation();
|
String userInformation = url.getUserInformation();
|
||||||
if (userInformation != null && userInformation.length() > 0) {
|
if (userInformation != null && userInformation.length() > 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue