This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch 3.0 in repository https://gitbox.apache.org/repos/asf/dubbo.git
commit cd44607560a24c1440f48c1d3bebbd5e4bca76c3 Author: ken.lj <[email protected]> AuthorDate: Fri Jul 24 16:55:14 2020 +0800 unify registry_cluster key --- .../org/apache/dubbo/common/constants/RegistryConstants.java | 2 ++ .../dubbo/registry/client/DefaultRegistryClusterIdentifier.java | 9 +++------ .../apache/dubbo/registry/client/RegistryClusterIdentifier.java | 4 ++-- .../apache/dubbo/registry/client/ServiceDiscoveryRegistry.java | 5 +++-- .../client/metadata/store/RemoteMetadataServiceImpl.java | 3 ++- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java index ce83136..420a909 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java @@ -21,6 +21,8 @@ public interface RegistryConstants { String REGISTRY_KEY = "registry"; + String REGISTRY_CLUSTER = "REGISTRY_CLUSTER"; + String REGISTRY_PROTOCOL = "registry"; String DYNAMIC_KEY = "dynamic"; diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/DefaultRegistryClusterIdentifier.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/DefaultRegistryClusterIdentifier.java index b225c06..6c88265 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/DefaultRegistryClusterIdentifier.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/DefaultRegistryClusterIdentifier.java @@ -18,19 +18,16 @@ package org.apache.dubbo.registry.client; import org.apache.dubbo.common.URL; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_KEY; +import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_CLUSTER; public class DefaultRegistryClusterIdentifier implements RegistryClusterIdentifier { @Override public String providerKey(URL url) { - // url.getParameter("registry_cluster"); - // ServiceMetadata.get("registry_cluster"); - // return; - return url.getParameter(REGISTRY_KEY); + return url.getParameter(REGISTRY_CLUSTER); } @Override public String consumerKey(URL url) { - return url.getParameter(REGISTRY_KEY); + return url.getParameter(REGISTRY_CLUSTER); } } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/RegistryClusterIdentifier.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/RegistryClusterIdentifier.java index b48b233..76d141a 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/RegistryClusterIdentifier.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/RegistryClusterIdentifier.java @@ -17,7 +17,6 @@ package org.apache.dubbo.registry.client; import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.config.ConfigurationUtils; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.extension.SPI; @@ -30,6 +29,7 @@ public interface RegistryClusterIdentifier { static RegistryClusterIdentifier getExtension() { ExtensionLoader<RegistryClusterIdentifier> loader = ExtensionLoader.getExtensionLoader(RegistryClusterIdentifier.class); - return loader.getExtension(ConfigurationUtils.getProperty("dubbo.application.sd.type", "default")); +// return loader.getExtension(ConfigurationUtils.getProperty("dubbo.application.sd.type", "default")); + return loader.getExtension("default"); } } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java index 8e5a800..f3d41c5 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java @@ -62,6 +62,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE; import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDED_BY; +import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_CLUSTER; import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_TYPE; @@ -206,7 +207,7 @@ public class ServiceDiscoveryRegistry implements Registry { public void doRegister(URL url) { String registryCluster = serviceDiscovery.getUrl().getParameter(ID_KEY); if (registryCluster != null) { - url = url.addParameter(REGISTRY_KEY, registryCluster); + url = url.addParameter(REGISTRY_CLUSTER, registryCluster); } if (writableMetadataService.exportURL(url)) { if (logger.isInfoEnabled()) { @@ -230,7 +231,7 @@ public class ServiceDiscoveryRegistry implements Registry { public void doUnregister(URL url) { String registryCluster = serviceDiscovery.getUrl().getParameter(ID_KEY); if (registryCluster != null) { - url = url.addParameter(REGISTRY_KEY, registryCluster); + url = url.addParameter(REGISTRY_CLUSTER, registryCluster); } if (writableMetadataService.unexportURL(url)) { if (logger.isInfoEnabled()) { diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/RemoteMetadataServiceImpl.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/RemoteMetadataServiceImpl.java index 00aa92a..2d543e5 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/RemoteMetadataServiceImpl.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/RemoteMetadataServiceImpl.java @@ -44,6 +44,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE; import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY; import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; +import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_CLUSTER; import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_KEY; public class RemoteMetadataServiceImpl { @@ -79,7 +80,7 @@ public class RemoteMetadataServiceImpl { SubscriberMetadataIdentifier identifier = new SubscriberMetadataIdentifier(instance.getServiceName(), ServiceInstanceMetadataUtils.getExportedServicesRevision(instance)); - String registryCluster = instance.getExtendParams().get(REGISTRY_KEY); + String registryCluster = instance.getExtendParams().get(REGISTRY_CLUSTER); MetadataReport metadataReport = getMetadataReports().get(registryCluster); if (metadataReport == null) {
