From 956d28b11ecda2b4aa3c76481c95f06fc3833210 Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Tue, 21 May 2019 16:18:25 +0800 Subject: [PATCH] [DUBBO-3137]: move constants from RegistryConstants back to dubbo-registry-api (#4101) * [DUBBO-3137]: move constants from RegistryConstants back to dubbo-registry-api * fix imports --- .../apache/dubbo/rpc/cluster/Constants.java | 12 +++ .../cluster/directory/AbstractDirectory.java | 2 +- .../router/file/FileRouterFactory.java | 2 +- .../support/AbstractClusterInvokerTest.java | 2 +- .../common/constants/RegistryConstants.java | 90 ------------------- .../dubbo/config/AbstractInterfaceConfig.java | 6 +- .../apache/dubbo/config/ReferenceConfig.java | 4 +- .../apache/dubbo/config/RegistryConfig.java | 2 +- .../apache/dubbo/config/ServiceConfig.java | 2 +- .../dubbo/config/ServiceConfigTest.java | 2 +- .../etcd/EtcdDynamicConfigurationTest.java | 2 +- .../nacos/NacosDynamicConfigurationTest.java | 2 +- .../AbstractMetadataReportFactory.java | 7 +- .../store/nacos/NacosMetadataReportTest.java | 2 +- .../org/apache/dubbo/registry/Constants.java | 76 ++++++++++++++++ .../integration/RegistryDirectory.java | 6 +- .../integration/RegistryProtocol.java | 18 ++-- .../registry/retry/AbstractRetryTask.java | 8 +- .../registry/support/AbstractRegistry.java | 2 +- .../support/AbstractRegistryFactory.java | 4 +- .../registry/support/FailbackRegistry.java | 6 +- .../support/FailbackRegistryTest.java | 4 +- .../dubbo/registry/consul/ConsulRegistry.java | 4 +- .../dubbo/registry/dubbo/DubboRegistry.java | 2 +- .../registry/dubbo/DubboRegistryFactory.java | 6 +- .../registry/dubbo/RegistryDirectoryTest.java | 4 +- .../registry/dubbo/RegistryProtocolTest.java | 2 +- .../dubbo/registry/etcd/EtcdRegistry.java | 2 +- .../dubbo/registry/etcd/EtcdRegistryTest.java | 2 +- .../registry/multicast/MulticastRegistry.java | 16 ++-- .../dubbo/registry/nacos/NacosRegistry.java | 2 +- .../dubbo/registry/redis/RedisRegistry.java | 12 +-- .../dubbo/registry/sofa/SofaRegistry.java | 8 +- .../apache/dubbo/remoting/etcd/Constants.java | 24 +++++ .../remoting/etcd/jetcd/JEtcdClient.java | 8 +- .../etcd/jetcd/JEtcdClientWrapper.java | 21 ++--- .../dubbo/remoting/etcd/option/Constants.java | 32 ------- .../etcd/support/AbstractEtcdClient.java | 8 +- .../remoting/etcd/jetcd/JEtcdClientTest.java | 2 +- .../etcd/jetcd/JEtcdClientWrapperTest.java | 2 +- 40 files changed, 203 insertions(+), 215 deletions(-) delete mode 100644 dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/option/Constants.java diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/Constants.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/Constants.java index 8849c267145..9303a9a5a9d 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/Constants.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/Constants.java @@ -100,4 +100,16 @@ public interface Constants { String OVERRIDE_PROVIDERS_KEY = "providerAddresses"; String TAG_KEY = "dubbo.tag"; + /** + * key for router type, for e.g., "script"/"file", corresponding to ScriptRouterFactory.NAME, FileRouterFactory.NAME + */ + String ROUTER_KEY = "router"; + /** + * The key name for reference URL in register center + */ + String REFER_KEY = "refer"; + /** + * The key name for export URL in register center + */ + String EXPORT_KEY = "export"; } diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java index b25c5980c24..4e304e954ea 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java @@ -31,7 +31,7 @@ import java.util.List; import java.util.Map; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY; import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_PROTOCOL; diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/file/FileRouterFactory.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/file/FileRouterFactory.java index 13e929c6121..95d81009d7d 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/file/FileRouterFactory.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/file/FileRouterFactory.java @@ -27,7 +27,7 @@ import java.io.FileReader; import java.io.IOException; -import static org.apache.dubbo.common.constants.RegistryConstants.ROUTER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.ROUTER_KEY; import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY; import static org.apache.dubbo.rpc.cluster.Constants.RUNTIME_KEY; import static org.apache.dubbo.rpc.cluster.Constants.TYPE_KEY; diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvokerTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvokerTest.java index c31038d238e..1ec574d022a 100644 --- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvokerTest.java +++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvokerTest.java @@ -49,7 +49,7 @@ import static org.apache.dubbo.rpc.cluster.Constants.CLUSTER_AVAILABLE_CHECK_KEY; import static org.apache.dubbo.rpc.cluster.Constants.INVOCATION_NEED_MOCK; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY; import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; 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 ff5c2126908..647ac81c7b9 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 @@ -18,26 +18,13 @@ package org.apache.dubbo.common.constants; public interface RegistryConstants { - String REGISTER_KEY = "register"; - - String SUBSCRIBE_KEY = "subscribe"; String REGISTRY_KEY = "registry"; - String DEFAULT_REGISTRY = "dubbo"; - String REGISTRY_PROTOCOL = "registry"; String DYNAMIC_KEY = "dynamic"; - String REGISTER = "register"; - - String UNREGISTER = "unregister"; - - String SUBSCRIBE = "subscribe"; - - String UNSUBSCRIBE = "unsubscribe"; - String CATEGORY_KEY = "category"; String PROVIDERS_CATEGORY = "providers"; @@ -56,90 +43,13 @@ public interface RegistryConstants { String APP_DYNAMIC_CONFIGURATORS_CATEGORY = "appdynamicconfigurators"; - String CONFIGURATORS_SUFFIX = ".configurators"; - String ROUTERS_SUFFIX = ".routers"; - String TRACE_PROTOCOL = "trace"; - String EMPTY_PROTOCOL = "empty"; - String ADMIN_PROTOCOL = "admin"; - - String PROVIDER_PROTOCOL = "provider"; - - String CONSUMER_PROTOCOL = "consumer"; - String ROUTE_PROTOCOL = "route"; - String SCRIPT_PROTOCOL = "script"; - - String CONDITION_PROTOCOL = "condition"; - - /** - * simple the registry for provider. - * - * @since 2.7.0 - */ - String SIMPLIFIED_KEY = "simplified"; - - /** - * After simplify the registry, should add some paramter individually for provider. - * - * @since 2.7.0 - */ - String EXTRA_KEYS_KEY = "extra-keys"; - String OVERRIDE_PROTOCOL = "override"; String COMPATIBLE_CONFIG_KEY = "compatible_config"; - - /** - * To decide whether register center saves file synchronously, the default value is asynchronously - */ - String REGISTRY_FILESAVE_SYNC_KEY = "save.file"; - - /** - * Period of registry center's retry interval - */ - String REGISTRY_RETRY_PERIOD_KEY = "retry.period"; - - /** - * Most retry times - */ - String REGISTRY_RETRY_TIMES_KEY = "retry.times"; - - /** - * Default value for the period of retry interval in milliseconds: 5000 - */ - int DEFAULT_REGISTRY_RETRY_PERIOD = 5 * 1000; - - /** - * Default value for the times of retry: 3 - */ - int DEFAULT_REGISTRY_RETRY_TIMES = 3; - - /** - * Reconnection period in milliseconds for register center - */ - String REGISTRY_RECONNECT_PERIOD_KEY = "reconnect.period"; - - int DEFAULT_REGISTRY_RECONNECT_PERIOD = 3 * 1000; - - String SESSION_TIMEOUT_KEY = "session"; - - int DEFAULT_SESSION_TIMEOUT = 60 * 1000; - /** - * key for router type, for e.g., "script"/"file", corresponding to ScriptRouterFactory.NAME, FileRouterFactory.NAME - */ - String ROUTER_KEY = "router"; - - /** - * The key name for export URL in register center - */ - String EXPORT_KEY = "export"; - /** - * The key name for reference URL in register center - */ - String REFER_KEY = "refer"; } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java index d708b1f0d5a..90577cd786d 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java @@ -69,16 +69,16 @@ import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL; import static org.apache.dubbo.config.Constants.LAYER_KEY; import static org.apache.dubbo.config.Constants.LISTENER_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY; import static org.apache.dubbo.registry.Constants.REGISTER_IP_KEY; import static org.apache.dubbo.config.Constants.REGISTRIES_SUFFIX; import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY; import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_SECONDS_KEY; import static org.apache.dubbo.monitor.Constants.LOGSTAT_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTER_KEY; +import static org.apache.dubbo.registry.Constants.REGISTER_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.SUBSCRIBE_KEY; +import static org.apache.dubbo.registry.Constants.SUBSCRIBE_KEY; import static org.apache.dubbo.common.constants.RpcConstants.DUBBO_VERSION_KEY; import static org.apache.dubbo.rpc.Constants.INVOKER_LISTENER_KEY; import static org.apache.dubbo.rpc.Constants.LOCAL_KEY; diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java index 45f24cf0657..3b8eb93add7 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java @@ -67,10 +67,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY; import static org.apache.dubbo.common.constants.ConfigConstants.CLUSTER_KEY; import static org.apache.dubbo.config.Constants.DUBBO_IP_TO_REGISTRY; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY; import static org.apache.dubbo.registry.Constants.REGISTER_IP_KEY; import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL; import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_PROTOCOL; import static org.apache.dubbo.rpc.Constants.LOCAL_PROTOCOL; import static org.apache.dubbo.common.utils.NetUtils.isInvalidLocalHost; diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java index 291bbfdb0b4..94d0f2cbe9e 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java @@ -29,7 +29,7 @@ import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY; import static org.apache.dubbo.common.constants.ConfigConstants.USERNAME_KEY; import static org.apache.dubbo.config.Constants.ZOOKEEPER_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.EXTRA_KEYS_KEY; +import static org.apache.dubbo.registry.Constants.EXTRA_KEYS_KEY; /** * RegistryConfig diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java index d485be70246..f95e15e0e55 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java @@ -75,7 +75,7 @@ import static org.apache.dubbo.config.Constants.DUBBO_IP_TO_REGISTRY; import static org.apache.dubbo.config.Constants.DUBBO_PORT_TO_BIND; import static org.apache.dubbo.config.Constants.DUBBO_PORT_TO_REGISTRY; -import static org.apache.dubbo.common.constants.RegistryConstants.EXPORT_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.EXPORT_KEY; import static org.apache.dubbo.config.Constants.MULTICAST; import static org.apache.dubbo.config.Constants.PROTOCOLS_SUFFIX; import static org.apache.dubbo.rpc.Constants.SCOPE_KEY; diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java index 7c4b5b49024..147648b67fb 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java @@ -47,7 +47,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY; import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER; import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.EXPORT_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.EXPORT_KEY; import static org.apache.dubbo.config.Constants.SHUTDOWN_TIMEOUT_KEY; import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY; import static org.apache.dubbo.remoting.Constants.BIND_IP_KEY; diff --git a/dubbo-configcenter/dubbo-configcenter-etcd/src/test/java/org/apache/dubbo/configcenter/support/etcd/EtcdDynamicConfigurationTest.java b/dubbo-configcenter/dubbo-configcenter-etcd/src/test/java/org/apache/dubbo/configcenter/support/etcd/EtcdDynamicConfigurationTest.java index 6e5a3dc3f96..d56f3c4649c 100644 --- a/dubbo-configcenter/dubbo-configcenter-etcd/src/test/java/org/apache/dubbo/configcenter/support/etcd/EtcdDynamicConfigurationTest.java +++ b/dubbo-configcenter/dubbo-configcenter-etcd/src/test/java/org/apache/dubbo/configcenter/support/etcd/EtcdDynamicConfigurationTest.java @@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY; +import static org.apache.dubbo.remoting.etcd.Constants.SESSION_TIMEOUT_KEY; /** * Unit test for etcd config center support diff --git a/dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java b/dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java index ea9ac24a522..ff785b974a6 100644 --- a/dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java +++ b/dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java @@ -31,7 +31,6 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; -import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY; /** * Unit test for nacos config center support @@ -39,6 +38,7 @@ //FIXME: waiting for embedded Nacos suport, then we can open the switch. @Disabled("https://github.com/alibaba/nacos/issues/1188") public class NacosDynamicConfigurationTest { + private static final String SESSION_TIMEOUT_KEY = "session"; private static NacosDynamicConfiguration config; diff --git a/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/support/AbstractMetadataReportFactory.java b/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/support/AbstractMetadataReportFactory.java index 37f761c4a87..fd4895c584c 100644 --- a/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/support/AbstractMetadataReportFactory.java +++ b/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/support/AbstractMetadataReportFactory.java @@ -24,12 +24,9 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantLock; -import static org.apache.dubbo.common.constants.RegistryConstants.EXPORT_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; - -/** - */ public abstract class AbstractMetadataReportFactory implements MetadataReportFactory { + private static final String EXPORT_KEY = "export"; + private static final String REFER_KEY = "refer"; // The lock for the acquisition process of the registry private static final ReentrantLock LOCK = new ReentrantLock(); diff --git a/dubbo-metadata-report/dubbo-metadata-report-nacos/src/test/java/org/apache/dubbo/metadata/store/nacos/NacosMetadataReportTest.java b/dubbo-metadata-report/dubbo-metadata-report-nacos/src/test/java/org/apache/dubbo/metadata/store/nacos/NacosMetadataReportTest.java index 6f48dbd1ad0..07d6f8b839a 100644 --- a/dubbo-metadata-report/dubbo-metadata-report-nacos/src/test/java/org/apache/dubbo/metadata/store/nacos/NacosMetadataReportTest.java +++ b/dubbo-metadata-report/dubbo-metadata-report-nacos/src/test/java/org/apache/dubbo/metadata/store/nacos/NacosMetadataReportTest.java @@ -35,11 +35,11 @@ import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE; import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE; -import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY; //FIXME: waiting for embedded Nacos suport, then we can open the switch. @Disabled("https://github.com/alibaba/nacos/issues/1188") public class NacosMetadataReportTest { + private static final String SESSION_TIMEOUT_KEY = "session"; private static final String TEST_SERVICE = "org.apache.dubbo.metadata.store.nacos.NacosMetadata4TstService"; private NacosMetadataReport nacosMetadataReport; private NacosMetadataReportFactory nacosMetadataReportFactory; diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/Constants.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/Constants.java index c1bfb3fe43d..dbfec2e0ab1 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/Constants.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/Constants.java @@ -19,4 +19,80 @@ public interface Constants { String REGISTER_IP_KEY = "register.ip"; + + String REGISTER_KEY = "register"; + + String SUBSCRIBE_KEY = "subscribe"; + + String DEFAULT_REGISTRY = "dubbo"; + + String REGISTER = "register"; + + String UNREGISTER = "unregister"; + + String SUBSCRIBE = "subscribe"; + + String UNSUBSCRIBE = "unsubscribe"; + + String CONFIGURATORS_SUFFIX = ".configurators"; + + String ADMIN_PROTOCOL = "admin"; + + String PROVIDER_PROTOCOL = "provider"; + + String CONSUMER_PROTOCOL = "consumer"; + + String SCRIPT_PROTOCOL = "script"; + + String CONDITION_PROTOCOL = "condition"; + String TRACE_PROTOCOL = "trace"; + /** + * simple the registry for provider. + * + * @since 2.7.0 + */ + String SIMPLIFIED_KEY = "simplified"; + + /** + * After simplify the registry, should add some paramter individually for provider. + * + * @since 2.7.0 + */ + String EXTRA_KEYS_KEY = "extra-keys"; + + /** + * To decide whether register center saves file synchronously, the default value is asynchronously + */ + String REGISTRY_FILESAVE_SYNC_KEY = "save.file"; + + /** + * Reconnection period in milliseconds for register center + */ + String REGISTRY_RECONNECT_PERIOD_KEY = "reconnect.period"; + + int DEFAULT_SESSION_TIMEOUT = 60 * 1000; + + /** + * Default value for the times of retry: 3 + */ + int DEFAULT_REGISTRY_RETRY_TIMES = 3; + + int DEFAULT_REGISTRY_RECONNECT_PERIOD = 3 * 1000; + + /** + * Default value for the period of retry interval in milliseconds: 5000 + */ + int DEFAULT_REGISTRY_RETRY_PERIOD = 5 * 1000; + + /** + * Most retry times + */ + String REGISTRY_RETRY_TIMES_KEY = "retry.times"; + + /** + * Period of registry center's retry interval + */ + String REGISTRY_RETRY_PERIOD_KEY = "retry.period"; + + String SESSION_TIMEOUT_KEY = "session"; } diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java index 2ee10d72db9..6dd235a885c 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java @@ -58,7 +58,7 @@ import java.util.Set; import java.util.stream.Collectors; -import static org.apache.dubbo.common.constants.RegistryConstants.ROUTER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.ROUTER_KEY; import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE; import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY; import static org.apache.dubbo.common.constants.CommonConstants.DISABLED_KEY; @@ -67,13 +67,13 @@ import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY; import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY; import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.APP_DYNAMIC_CONFIGURATORS_CATEGORY; import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.COMPATIBLE_CONFIG_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY; -import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_SUFFIX; +import static org.apache.dubbo.registry.Constants.CONFIGURATORS_SUFFIX; import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_CATEGORY; import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_CONFIGURATORS_CATEGORY; import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL; diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java index 0c94708f6fb..f55fad4558b 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java @@ -69,28 +69,28 @@ import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; import static org.apache.dubbo.common.constants.ConfigConstants.ACCEPT_FOREIGN_IP; import static org.apache.dubbo.common.constants.ConfigConstants.CLUSTER_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.EXPORT_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.EXPORT_KEY; import static org.apache.dubbo.common.constants.ConfigConstants.QOS_ENABLE; import static org.apache.dubbo.common.constants.ConfigConstants.QOS_PORT; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY; import static org.apache.dubbo.registry.Constants.REGISTER_IP_KEY; import static org.apache.dubbo.common.constants.FilterConstants.VALIDATION_KEY; import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY; -import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_SUFFIX; +import static org.apache.dubbo.registry.Constants.CONFIGURATORS_SUFFIX; import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMERS_CATEGORY; -import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_REGISTRY; -import static org.apache.dubbo.common.constants.RegistryConstants.EXTRA_KEYS_KEY; +import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.DEFAULT_REGISTRY; +import static org.apache.dubbo.registry.Constants.EXTRA_KEYS_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.OVERRIDE_PROTOCOL; import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDERS_CATEGORY; -import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDER_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTER_KEY; +import static org.apache.dubbo.registry.Constants.PROVIDER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.REGISTER_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_PROTOCOL; import static org.apache.dubbo.common.constants.RegistryConstants.ROUTERS_CATEGORY; -import static org.apache.dubbo.common.constants.RegistryConstants.SIMPLIFIED_KEY; +import static org.apache.dubbo.registry.Constants.SIMPLIFIED_KEY; import static org.apache.dubbo.remoting.Constants.BIND_IP_KEY; import static org.apache.dubbo.remoting.Constants.BIND_PORT_KEY; import static org.apache.dubbo.remoting.Constants.CHECK_KEY; diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/retry/AbstractRetryTask.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/retry/AbstractRetryTask.java index f367d17873d..4c1f75e1e57 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/retry/AbstractRetryTask.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/retry/AbstractRetryTask.java @@ -28,10 +28,10 @@ import java.util.concurrent.TimeUnit; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_REGISTRY_RETRY_PERIOD; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_REGISTRY_RETRY_TIMES; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_RETRY_PERIOD_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_RETRY_TIMES_KEY; +import static org.apache.dubbo.registry.Constants.DEFAULT_REGISTRY_RETRY_PERIOD; +import static org.apache.dubbo.registry.Constants.DEFAULT_REGISTRY_RETRY_TIMES; +import static org.apache.dubbo.registry.Constants.REGISTRY_RETRY_PERIOD_KEY; +import static org.apache.dubbo.registry.Constants.REGISTRY_RETRY_TIMES_KEY; /** * AbstractRetryTask diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java index 27a6b1a6c70..aec82d5e854 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistry.java @@ -58,7 +58,7 @@ import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_CATEGORY; import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_FILESAVE_SYNC_KEY; +import static org.apache.dubbo.registry.Constants.REGISTRY_FILESAVE_SYNC_KEY; /** * AbstractRegistry. (SPI, Prototype, ThreadSafe) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java index 3b540c3b36b..06915098da1 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java @@ -31,8 +31,8 @@ import java.util.concurrent.locks.ReentrantLock; import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.EXPORT_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.EXPORT_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY; /** * AbstractRegistryFactory. (SPI, Singleton, ThreadSafe) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java index 903d4775301..f4c21b7b201 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java @@ -38,9 +38,9 @@ import java.util.concurrent.TimeUnit; import static org.apache.dubbo.common.constants.CommonConstants.FILE_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_REGISTRY_RETRY_PERIOD; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_RETRY_PERIOD_KEY; +import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.DEFAULT_REGISTRY_RETRY_PERIOD; +import static org.apache.dubbo.registry.Constants.REGISTRY_RETRY_PERIOD_KEY; /** * FailbackRegistry. (SPI, Prototype, ThreadSafe) diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java index e6ceb6b2c5c..3e4843328a6 100644 --- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java +++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java @@ -30,8 +30,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_RETRY_PERIOD_KEY; +import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.REGISTRY_RETRY_PERIOD_KEY; import static org.junit.jupiter.api.Assertions.assertEquals; public class FailbackRegistryTest { diff --git a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java index e79dac7a2a4..e7cf986cc45 100644 --- a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java +++ b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java @@ -49,8 +49,8 @@ import static java.util.concurrent.Executors.newCachedThreadPool; import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE; -import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.PROVIDER_PROTOCOL; /** * registry center implementation for consul diff --git a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java index d6a5d69f9ca..ef9238ee04e 100644 --- a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java +++ b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_RECONNECT_PERIOD_KEY; +import static org.apache.dubbo.registry.Constants.REGISTRY_RECONNECT_PERIOD_KEY; /** * DubboRegistry diff --git a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistryFactory.java b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistryFactory.java index 8f3d6827724..82a80a74ee2 100644 --- a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistryFactory.java @@ -41,10 +41,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY; import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.EXPORT_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.EXPORT_KEY; import static org.apache.dubbo.rpc.Constants.LAZY_CONNECT_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL; +import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY; +import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL; import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY; import static org.apache.dubbo.remoting.Constants.CONNECT_TIMEOUT_KEY; import static org.apache.dubbo.remoting.Constants.RECONNECT_KEY; diff --git a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java index e04ca82cbd3..6a2b4e6a2e8 100644 --- a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java +++ b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java @@ -52,7 +52,7 @@ import static org.apache.dubbo.rpc.cluster.Constants.INVOCATION_NEED_MOCK; import static org.apache.dubbo.rpc.cluster.Constants.LOADBALANCE_KEY; import static org.apache.dubbo.rpc.cluster.Constants.MOCK_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.ROUTER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.ROUTER_KEY; import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY; import static org.apache.dubbo.rpc.cluster.Constants.TYPE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE; @@ -61,7 +61,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.DISABLED_KEY; import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY; import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.REFER_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY; import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL; diff --git a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryProtocolTest.java b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryProtocolTest.java index 4aff5607de8..ee4e043fd95 100644 --- a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryProtocolTest.java +++ b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryProtocolTest.java @@ -41,7 +41,7 @@ import java.util.ArrayList; import java.util.List; -import static org.apache.dubbo.common.constants.RegistryConstants.EXPORT_KEY; +import static org.apache.dubbo.rpc.cluster.Constants.EXPORT_KEY; import static org.apache.dubbo.registry.integration.RegistryProtocol.DEFAULT_REGISTER_PROVIDER_KEYS; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdRegistry.java b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdRegistry.java index cffc58e6c0f..44a347c73db 100644 --- a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdRegistry.java +++ b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdRegistry.java @@ -41,10 +41,10 @@ import org.apache.dubbo.registry.NotifyListener; import org.apache.dubbo.registry.support.FailbackRegistry; import org.apache.dubbo.remoting.etcd.ChildListener; +import org.apache.dubbo.remoting.etcd.Constants; import org.apache.dubbo.remoting.etcd.EtcdClient; import org.apache.dubbo.remoting.etcd.EtcdTransporter; import org.apache.dubbo.remoting.etcd.StateListener; -import org.apache.dubbo.remoting.etcd.option.Constants; import org.apache.dubbo.remoting.etcd.option.OptionUtil; import org.apache.dubbo.rpc.RpcException; diff --git a/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java b/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java index 859cfd04c2e..15427903b81 100644 --- a/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java +++ b/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java @@ -79,7 +79,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY; import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.ADMIN_PROTOCOL; +import static org.apache.dubbo.registry.Constants.ADMIN_PROTOCOL; import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY; import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMERS_CATEGORY; diff --git a/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java b/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java index 3f4eb269bc6..27aded1dea4 100644 --- a/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java +++ b/dubbo-registry/dubbo-registry-multicast/src/main/java/org/apache/dubbo/registry/multicast/MulticastRegistry.java @@ -51,18 +51,18 @@ import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE; import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT; import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_SESSION_TIMEOUT; +import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.DEFAULT_SESSION_TIMEOUT; import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL; import static org.apache.dubbo.common.constants.RegistryConstants.OVERRIDE_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTER; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTER_KEY; +import static org.apache.dubbo.registry.Constants.REGISTER; +import static org.apache.dubbo.registry.Constants.REGISTER_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.ROUTE_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.SUBSCRIBE; -import static org.apache.dubbo.common.constants.RegistryConstants.UNREGISTER; -import static org.apache.dubbo.common.constants.RegistryConstants.UNSUBSCRIBE; +import static org.apache.dubbo.registry.Constants.SESSION_TIMEOUT_KEY; +import static org.apache.dubbo.registry.Constants.SUBSCRIBE; +import static org.apache.dubbo.registry.Constants.UNREGISTER; +import static org.apache.dubbo.registry.Constants.UNSUBSCRIBE; /** * MulticastRegistry diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java index 1af3ec2059c..ff53d64421e 100644 --- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java +++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java @@ -52,7 +52,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY; import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY; import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.ADMIN_PROTOCOL; +import static org.apache.dubbo.registry.Constants.ADMIN_PROTOCOL; import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY; import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMERS_CATEGORY; diff --git a/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java b/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java index 50a542fac3a..dc5d5a14c78 100644 --- a/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java +++ b/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java @@ -63,14 +63,14 @@ import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_CATEGORY; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_REGISTRY_RECONNECT_PERIOD; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_SESSION_TIMEOUT; +import static org.apache.dubbo.registry.Constants.DEFAULT_REGISTRY_RECONNECT_PERIOD; +import static org.apache.dubbo.registry.Constants.DEFAULT_SESSION_TIMEOUT; import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTER; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_RECONNECT_PERIOD_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.UNREGISTER; +import static org.apache.dubbo.registry.Constants.REGISTER; +import static org.apache.dubbo.registry.Constants.REGISTRY_RECONNECT_PERIOD_KEY; +import static org.apache.dubbo.registry.Constants.SESSION_TIMEOUT_KEY; +import static org.apache.dubbo.registry.Constants.UNREGISTER; /** * RedisRegistry diff --git a/dubbo-registry/dubbo-registry-sofa/src/main/java/org/apache/dubbo/registry/sofa/SofaRegistry.java b/dubbo-registry/dubbo-registry-sofa/src/main/java/org/apache/dubbo/registry/sofa/SofaRegistry.java index c708688e6a7..4c784b34b2f 100644 --- a/dubbo-registry/dubbo-registry-sofa/src/main/java/org/apache/dubbo/registry/sofa/SofaRegistry.java +++ b/dubbo-registry/dubbo-registry-sofa/src/main/java/org/apache/dubbo/registry/sofa/SofaRegistry.java @@ -46,10 +46,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.DUBBO; import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY; import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDER_PROTOCOL; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTER_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.SUBSCRIBE_KEY; +import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.PROVIDER_PROTOCOL; +import static org.apache.dubbo.registry.Constants.REGISTER_KEY; +import static org.apache.dubbo.registry.Constants.SUBSCRIBE_KEY; import static org.apache.dubbo.registry.sofa.SofaRegistryConstants.ADDRESS_WAIT_TIME_KEY; import static org.apache.dubbo.registry.sofa.SofaRegistryConstants.DEFAULT_GROUP; import static org.apache.dubbo.registry.sofa.SofaRegistryConstants.LOCAL_DATA_CENTER; diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java index b022678122e..3450bb5b36f 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java @@ -27,5 +27,29 @@ public interface Constants { String DEFAULT_ETCD3_NOTIFY_QUEUES_KEY = "etcd3.notify.queues"; int DEFAULT_GRPC_QUEUES = 300_0000; + + String RETRY_PERIOD_KEY = "retry.period"; + + int DEFAULT_RETRY_PERIOD = 5 * 1000; + + int DEFAULT_SESSION_TIMEOUT = 60 * 1000; + + String HTTP_SUBFIX_KEY = "://"; + + String HTTP_KEY = "http://"; + + int DEFAULT_KEEPALIVE_TIMEOUT = DEFAULT_SESSION_TIMEOUT / 2; + + String SESSION_TIMEOUT_KEY = "session"; + + int DEFAULT_RECONNECT_PERIOD = 3 * 1000; + + String ROUTERS_CATEGORY = "routers"; + + String PROVIDERS_CATEGORY = "providers"; + + String CONSUMERS_CATEGORY = "consumers"; + + String CONFIGURATORS_CATEGORY = "configurators"; } diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java index 7e584cc1ed8..d0ec61969da 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClient.java @@ -60,13 +60,13 @@ import static java.util.stream.Collectors.toList; import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_REGISTRY_RETRY_PERIOD; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_SESSION_TIMEOUT; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_RETRY_PERIOD_KEY; import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_ETCD3_NOTIFY_QUEUES_KEY; import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_ETCD3_NOTIFY_THREADS; import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_GRPC_QUEUES; +import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_RETRY_PERIOD; +import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_SESSION_TIMEOUT; import static org.apache.dubbo.remoting.etcd.Constants.ETCD3_NOTIFY_MAXTHREADS_KEYS; +import static org.apache.dubbo.remoting.etcd.Constants.RETRY_PERIOD_KEY; import static org.apache.dubbo.remoting.etcd.jetcd.JEtcdClientWrapper.UTF_8; /** @@ -93,7 +93,7 @@ public JEtcdClient(URL url) { JEtcdClient.this.stateChanged(StateListener.DISCONNECTED); } }); - delayPeriod = getUrl().getParameter(REGISTRY_RETRY_PERIOD_KEY, DEFAULT_REGISTRY_RETRY_PERIOD); + delayPeriod = getUrl().getParameter(RETRY_PERIOD_KEY, DEFAULT_RETRY_PERIOD); reconnectSchedule = Executors.newScheduledThreadPool(1, new NamedThreadFactory("etcd3-watch-auto-reconnect")); diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java index 58e0443422d..7ef6777b131 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java @@ -25,7 +25,6 @@ import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.remoting.etcd.RetryPolicy; import org.apache.dubbo.remoting.etcd.StateListener; -import org.apache.dubbo.remoting.etcd.option.Constants; import io.etcd.jetcd.ByteSequence; import io.etcd.jetcd.Client; @@ -68,11 +67,13 @@ import static java.util.stream.Collectors.toList; import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SEPARATOR; import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_REGISTRY_RECONNECT_PERIOD; -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_REGISTRY_RETRY_PERIOD; -import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_RETRY_PERIOD_KEY; -import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY; -import static org.apache.dubbo.remoting.etcd.option.Constants.DEFAULT_KEEPALIVE_TIMEOUT; +import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_KEEPALIVE_TIMEOUT; +import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_RECONNECT_PERIOD; +import static org.apache.dubbo.remoting.etcd.Constants.DEFAULT_RETRY_PERIOD; +import static org.apache.dubbo.remoting.etcd.Constants.HTTP_KEY; +import static org.apache.dubbo.remoting.etcd.Constants.HTTP_SUBFIX_KEY; +import static org.apache.dubbo.remoting.etcd.Constants.RETRY_PERIOD_KEY; +import static org.apache.dubbo.remoting.etcd.Constants.SESSION_TIMEOUT_KEY; public class JEtcdClientWrapper { @@ -127,7 +128,7 @@ public JEtcdClientWrapper(URL url) { this.retryPolicy = new RetryNTimes(1, 1000, TimeUnit.MILLISECONDS); this.failed = new IllegalStateException("Etcd3 registry is not connected yet, url:" + url); - int retryPeriod = url.getParameter(REGISTRY_RETRY_PERIOD_KEY, DEFAULT_REGISTRY_RETRY_PERIOD); + int retryPeriod = url.getParameter(RETRY_PERIOD_KEY, DEFAULT_RETRY_PERIOD); this.retryFuture = retryExecutor.scheduleWithFixedDelay(() -> { try { @@ -488,9 +489,9 @@ public void delete(String path) { public String[] endPoints(String backupAddress) { String[] endpoints = backupAddress.split(COMMA_SEPARATOR); List addresses = Arrays.stream(endpoints) - .map(address -> address.contains(Constants.HTTP_SUBFIX_KEY) + .map(address -> address.contains(HTTP_SUBFIX_KEY) ? address - : Constants.HTTP_KEY + address) + : HTTP_KEY + address) .collect(toList()); Collections.shuffle(addresses); return addresses.toArray(new String[0]); @@ -536,7 +537,7 @@ public void start() { } connectState = connected; } - }, DEFAULT_REGISTRY_RECONNECT_PERIOD, DEFAULT_REGISTRY_RECONNECT_PERIOD, TimeUnit.MILLISECONDS); + }, DEFAULT_RECONNECT_PERIOD, DEFAULT_RECONNECT_PERIOD, TimeUnit.MILLISECONDS); } catch (Throwable t) { logger.error("monitor reconnect status failed.", t); } diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/option/Constants.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/option/Constants.java deleted file mode 100644 index 50af9a6057f..00000000000 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/option/Constants.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.remoting.etcd.option; - -import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_SESSION_TIMEOUT; - -/** - * Etcd registry constants. - */ -public interface Constants { - - String HTTP_SUBFIX_KEY = "://"; - - String HTTP_KEY = "http://"; - - int DEFAULT_KEEPALIVE_TIMEOUT = DEFAULT_SESSION_TIMEOUT / 2; - -} diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/support/AbstractEtcdClient.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/support/AbstractEtcdClient.java index 1f764c60099..362b2689a6c 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/support/AbstractEtcdClient.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/support/AbstractEtcdClient.java @@ -49,10 +49,10 @@ import java.util.concurrent.ConcurrentMap; import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR; -import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY; -import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMERS_CATEGORY; -import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDERS_CATEGORY; -import static org.apache.dubbo.common.constants.RegistryConstants.ROUTERS_CATEGORY; +import static org.apache.dubbo.remoting.etcd.Constants.CONFIGURATORS_CATEGORY; +import static org.apache.dubbo.remoting.etcd.Constants.CONSUMERS_CATEGORY; +import static org.apache.dubbo.remoting.etcd.Constants.PROVIDERS_CATEGORY; +import static org.apache.dubbo.remoting.etcd.Constants.ROUTERS_CATEGORY; public abstract class AbstractEtcdClient implements EtcdClient { diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientTest.java b/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientTest.java index 743d3fe03e1..6dcf812987a 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientTest.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientTest.java @@ -64,7 +64,7 @@ import java.util.concurrent.atomic.AtomicLong; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY; +import static org.apache.dubbo.remoting.etcd.Constants.SESSION_TIMEOUT_KEY; @Disabled public class JEtcdClientTest { diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapperTest.java b/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapperTest.java index f76c362a6d5..337b6decea1 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapperTest.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/test/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapperTest.java @@ -49,7 +49,7 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.locks.LockSupport; -import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY; +import static org.apache.dubbo.remoting.etcd.Constants.SESSION_TIMEOUT_KEY; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.spy;