fix: Support disable Curator EnsembleTracker in ServiceDiscovery (#14285)

This commit is contained in:
aofall 2024-06-05 11:39:27 +08:00 committed by GitHub
parent 48ad387ace
commit a534350541
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -43,6 +43,7 @@ import org.apache.zookeeper.data.ACL;
import static org.apache.curator.x.discovery.ServiceInstance.builder; import static org.apache.curator.x.discovery.ServiceInstance.builder;
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR; import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
import static org.apache.dubbo.common.constants.CommonConstants.ZOOKEEPER_ENSEMBLE_TRACKER_KEY;
import static org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.DEFAULT_GROUP; import static org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.DEFAULT_GROUP;
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkParams.BASE_SLEEP_TIME; import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkParams.BASE_SLEEP_TIME;
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkParams.BLOCK_UNTIL_CONNECTED_UNIT; import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkParams.BLOCK_UNTIL_CONNECTED_UNIT;
@ -69,8 +70,10 @@ public abstract class CuratorFrameworkUtils {
public static CuratorFramework buildCuratorFramework(URL connectionURL, ZookeeperServiceDiscovery serviceDiscovery) public static CuratorFramework buildCuratorFramework(URL connectionURL, ZookeeperServiceDiscovery serviceDiscovery)
throws Exception { throws Exception {
boolean ensembleTracker = connectionURL.getParameter(ZOOKEEPER_ENSEMBLE_TRACKER_KEY, true);
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
.connectString(connectionURL.getBackupAddress()) .connectString(connectionURL.getBackupAddress())
.ensembleTracker(ensembleTracker)
.retryPolicy(buildRetryPolicy(connectionURL)); .retryPolicy(buildRetryPolicy(connectionURL));
String userInformation = connectionURL.getUserInformation(); String userInformation = connectionURL.getUserInformation();
if (StringUtils.isNotEmpty(userInformation)) { if (StringUtils.isNotEmpty(userInformation)) {