[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
This commit is contained in:
Ian Luo 2019-05-21 16:18:25 +08:00 committed by huazhongming
parent fcef1a1841
commit 956d28b11e
40 changed files with 203 additions and 215 deletions

View File

@ -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";
}

View File

@ -31,7 +31,7 @@ import java.util.Collections;
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;

View File

@ -27,7 +27,7 @@ import java.io.File;
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;

View File

@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicLong;
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;

View File

@ -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";
}

View File

@ -69,16 +69,16 @@ import static org.apache.dubbo.config.Constants.DUBBO_IP_TO_REGISTRY;
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;

View File

@ -67,10 +67,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.SEMICOLON_SPLIT_
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;

View File

@ -29,7 +29,7 @@ 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.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

View File

@ -75,7 +75,7 @@ import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_IP_TO_BIND
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;

View File

@ -47,7 +47,7 @@ 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.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;

View File

@ -38,7 +38,7 @@ import java.util.concurrent.CountDownLatch;
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

View File

@ -31,7 +31,6 @@ import java.util.HashMap;
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 @@ import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOU
//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;

View File

@ -24,12 +24,9 @@ import java.util.Map;
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();

View File

@ -35,11 +35,11 @@ import java.util.Map;
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;

View File

@ -19,4 +19,80 @@ package org.apache.dubbo.registry;
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";
}

View File

@ -58,7 +58,7 @@ import java.util.Optional;
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.GROUP_KEY;
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;

View File

@ -69,28 +69,28 @@ 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.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;

View File

@ -28,10 +28,10 @@ import org.apache.dubbo.registry.support.FailbackRegistry;
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

View File

@ -58,7 +58,7 @@ 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.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)

View File

@ -31,8 +31,8 @@ import java.util.Map;
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)

View File

@ -38,9 +38,9 @@ import java.util.concurrent.ConcurrentMap;
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)

View File

@ -30,8 +30,8 @@ import java.util.concurrent.CountDownLatch;
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 {

View File

@ -49,8 +49,8 @@ import java.util.stream.Collectors;
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

View File

@ -36,7 +36,7 @@ import java.util.concurrent.ScheduledFuture;
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

View File

@ -41,10 +41,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATT
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;

View File

@ -52,7 +52,7 @@ import java.util.concurrent.CountDownLatch;
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.CONSUMER_SIDE;
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;

View File

@ -41,7 +41,7 @@ import org.junit.jupiter.api.Test;
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;

View File

@ -41,10 +41,10 @@ import org.apache.dubbo.common.utils.UrlUtils;
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;

View File

@ -79,7 +79,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
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;

View File

@ -51,18 +51,18 @@ import java.util.concurrent.TimeUnit;
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

View File

@ -52,7 +52,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
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;

View File

@ -63,14 +63,14 @@ import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
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

View File

@ -46,10 +46,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
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;

View File

@ -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";
}

View File

@ -60,13 +60,13 @@ import java.util.concurrent.locks.ReentrantLock;
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 class JEtcdClient extends AbstractEtcdClient<JEtcdClient.EtcdWatcher> {
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"));

View File

@ -25,7 +25,6 @@ import org.apache.dubbo.common.utils.NamedThreadFactory;
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 java.util.function.Consumer;
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 class JEtcdClientWrapper {
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 class JEtcdClientWrapper {
public String[] endPoints(String backupAddress) {
String[] endpoints = backupAddress.split(COMMA_SEPARATOR);
List<String> 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 class JEtcdClientWrapper {
}
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);
}

View File

@ -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;
}

View File

@ -49,10 +49,10 @@ import java.util.concurrent.ConcurrentHashMap;
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<WatcherListener> implements EtcdClient {

View File

@ -64,7 +64,7 @@ import java.util.concurrent.TimeUnit;
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 {

View File

@ -49,7 +49,7 @@ import java.util.concurrent.TimeUnit;
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;