diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java index 03c0dc9173d..75ebc8a7682 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java @@ -31,15 +31,22 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import static org.apache.dubbo.common.Constants.HASH_ARGUMENTS; -import static org.apache.dubbo.common.Constants.HASH_NODES; - /** * ConsistentHashLoadBalance */ public class ConsistentHashLoadBalance extends AbstractLoadBalance { public static final String NAME = "consistenthash"; + /** + * Hash nodes name + */ + public static final String HASH_NODES = "hash.nodes"; + + /** + * Hash arguments name + */ + public static final String HASH_ARGUMENTS = "hash.arguments"; + private final ConcurrentMap> selectors = new ConcurrentHashMap>(); @SuppressWarnings("unchecked") diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java index 31d5fc73e31..42c9f39748f 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java @@ -25,305 +25,256 @@ */ public class Constants { + // BEGIN common public static final String DUBBO = "dubbo"; public static final String PROVIDER = "provider"; public static final String CONSUMER = "consumer"; - public static final String REGISTER = "register"; - - public static final String UNREGISTER = "unregister"; - - public static final String SUBSCRIBE = "subscribe"; - - public static final String UNSUBSCRIBE = "unsubscribe"; + public static final String APPLICATION_KEY = "application"; - public static final String CATEGORY_KEY = "category"; + public static final String REMOTE_APPLICATION_KEY = "remote.application"; - public static final String PROVIDERS_CATEGORY = "providers"; + public static final String ENABLED_KEY = "enabled"; - public static final String CONSUMERS_CATEGORY = "consumers"; + public static final String DISABLED_KEY = "disabled"; - public static final String ROUTERS_CATEGORY = "routers"; + public static final String DUBBO_PROPERTIES_KEY = "dubbo.properties.file"; - public static final String DYNAMIC_ROUTERS_CATEGORY = "dynamicrouters"; + public static final String DEFAULT_DUBBO_PROPERTIES = "dubbo.properties"; - public static final String CONFIGURATORS_CATEGORY = "configurators"; + public static final String ANY_VALUE = "*"; - public static final String DYNAMIC_CONFIGURATORS_CATEGORY = "dynamicconfigurators"; - public static final String APP_DYNAMIC_CONFIGURATORS_CATEGORY = "appdynamicconfigurators"; + public static final String COMMA_SEPARATOR = ","; - public static final String CONFIGURATORS_SUFFIX = ".configurators"; + public static final Pattern COMMA_SPLIT_PATTERN = Pattern.compile("\\s*[,]+\\s*"); - public static final String ROUTERS_SUFFIX = ".routers"; + public final static String PATH_SEPARATOR = "/"; - public static final String CONFIG_CLUSTER_KEY = "config.cluster"; - public static final String CONFIG_NAMESPACE_KEY = "config.namespace"; - public static final String CONFIG_GROUP_KEY = "config.group"; - public static final String CONFIG_CHECK_KEY = "config.check"; - public static final String CONFIG_CONFIGFILE_KEY = "config.config-file"; - public static final String CONFIG_ENABLE_KEY = "config.highest-priority"; - public static final String CONFIG_TIMEOUT_KEY = "config.timeout"; - public static final String CONFIG_APPNAME_KEY = "config.app-name"; + public final static String PROTOCOL_SEPARATOR = "://"; - public static final String DEFAULT_CATEGORY = PROVIDERS_CATEGORY; + public static final String REGISTRY_SEPARATOR = "|"; - public static final String ENABLED_KEY = "enabled"; + public static final Pattern REGISTRY_SPLIT_PATTERN = Pattern.compile("\\s*[|;]+\\s*"); - public static final String DISABLED_KEY = "disabled"; + public static final String SEMICOLON_SEPARATOR = ";"; - public static final String VALIDATION_KEY = "validation"; + public static final Pattern SEMICOLON_SPLIT_PATTERN = Pattern.compile("\\s*[;]+\\s*"); - public static final String CACHE_KEY = "cache"; + public static final String DEFAULT_PROXY = "javassist"; - public static final String DYNAMIC_KEY = "dynamic"; + public static final String DEFAULT_DIRECTORY = "dubbo"; - public static final String STATUS_KEY = "status"; + public static final String PROTOCOL_KEY = "protocol"; - public static final String CONTEXTPATH_KEY = "contextpath"; + public static final String DEFAULT_PROTOCOL = "dubbo"; - public static final String LISTENER_KEY = "listener"; + public static final String DEFAULT_THREAD_NAME = "Dubbo"; - public static final String LAYER_KEY = "layer"; + public static final int DEFAULT_CORE_THREADS = 0; - public static final String DUBBO_PROPERTIES_KEY = "dubbo.properties.file"; + public static final int DEFAULT_THREADS = 200; - public static final String DEFAULT_DUBBO_PROPERTIES = "dubbo.properties"; + public static final String THREADPOOL_KEY = "threadpool"; - public static final String SENT_KEY = "sent"; + public static final String THREAD_NAME_KEY = "threadname"; - public static final boolean DEFAULT_SENT = false; + public static final String CORE_THREADS_KEY = "corethreads"; - public static final String REGISTRY_PROTOCOL = "registry"; + public static final String THREADS_KEY = "threads"; - public static final String $INVOKE = "$invoke"; + public static final String QUEUES_KEY = "queues"; - public static final String $ECHO = "$echo"; + public static final String ALIVE_KEY = "alive"; - public static final int DEFAULT_IO_THREADS = Math.min(Runtime.getRuntime().availableProcessors() + 1, 32); + public static final String DEFAULT_THREADPOOL = "limited"; - public static final String DEFAULT_PROXY = "javassist"; + public static final String DEFAULT_CLIENT_THREADPOOL = "cached"; - /** - * 8M - */ - public static final int DEFAULT_PAYLOAD = 8 * 1024 * 1024; + public static final String IO_THREADS_KEY = "iothreads"; - public static final String DEFAULT_CLUSTER = "failover"; + public static final int DEFAULT_QUEUES = 0; - public static final String DEFAULT_DIRECTORY = "dubbo"; + public static final int DEFAULT_ALIVE = 60 * 1000; - public static final String DEFAULT_LOADBALANCE = "random"; + public static final String TIMEOUT_KEY = "timeout"; - public static final String DEFAULT_PROTOCOL = "dubbo"; + public static final int DEFAULT_TIMEOUT = 1000; - public static final String DEFAULT_EXCHANGER = "header"; + public static final String REMOVE_VALUE_PREFIX = "-"; - public static final String DEFAULT_TRANSPORTER = "netty"; + public static final String PROPERTIES_CHAR_SEPERATOR = "-"; + + public static final String GROUP_CHAR_SEPERATOR = ":"; - public static final String DEFAULT_REMOTING_SERVER = "netty"; + public static final String HIDE_KEY_PREFIX = "."; + + public static final String DEFAULT_KEY_PREFIX = "default."; - public static final String DEFAULT_REMOTING_CLIENT = "netty"; + public static final String DEFAULT_KEY = "default"; - public static final String DEFAULT_REMOTING_CODEC = "dubbo"; - public static final String DEFAULT_REMOTING_SERIALIZATION = "hessian2"; + /** + * Default timeout value in milliseconds for server shutdown + */ + public static final int DEFAULT_SERVER_SHUTDOWN_TIMEOUT = 10000; - public static final String DEFAULT_HTTP_SERVER = "servlet"; + public static final String SIDE_KEY = "side"; - public static final String DEFAULT_HTTP_CLIENT = "jdk"; + public static final String PROVIDER_SIDE = "provider"; - public static final String DEFAULT_HTTP_SERIALIZATION = "json"; + public static final String CONSUMER_SIDE = "consumer"; - public static final String DEFAULT_CHARSET = "UTF-8"; + public static final String ANYHOST_KEY = "anyhost"; - public static final int DEFAULT_WEIGHT = 100; + public static final String ANYHOST_VALUE = "0.0.0.0"; - public static final int DEFAULT_FORKS = 2; + public static final String LOCALHOST_KEY = "localhost"; - public static final String DEFAULT_THREAD_NAME = "Dubbo"; + public static final String LOCALHOST_VALUE = "127.0.0.1"; - public static final int DEFAULT_CORE_THREADS = 0; + public static final String METHODS_KEY = "methods"; - public static final int DEFAULT_THREADS = 200; + public static final String METHOD_KEY = "method"; - public static final boolean DEFAULT_KEEP_ALIVE = true; + public static final String PID_KEY = "pid"; - public static final int DEFAULT_QUEUES = 0; + public static final String TIMESTAMP_KEY = "timestamp"; - public static final int DEFAULT_ALIVE = 60 * 1000; + public static final String GROUP_KEY = "group"; - /** - * By default, a consumer JVM instance and a provider JVM instance share a long TCP connection (except when connections are set), - * which can set the number of long TCP connections shared to avoid the bottleneck of sharing a single long TCP connection. - */ - public static final String DEFAULT_SHARE_CONNECTIONS = "1"; + public static final String PATH_KEY = "path"; - public static final String SHARE_CONNECTIONS_KEY = "shareconnections"; + public static final String INTERFACE_KEY = "interface"; - public static final int DEFAULT_ACCEPTS = 0; + public static final String FILE_KEY = "file"; - public static final int DEFAULT_IDLE_TIMEOUT = 600 * 1000; + public static final String DUMP_DIRECTORY = "dump.directory"; - public static final int DEFAULT_HEARTBEAT = 60 * 1000; + public static final String CLASSIFIER_KEY = "classifier"; - public static final int DEFAULT_TIMEOUT = 1000; + public static final String VERSION_KEY = "version"; - public static final int DEFAULT_CONNECT_TIMEOUT = 3000; + public static final String REVISION_KEY = "revision"; /** - * public static final int DEFAULT_REGISTRY_CONNECT_TIMEOUT = 5000; + * package version in the manifest */ - public static final int DEFAULT_RETRIES = 2; + public static final String RELEASE_KEY = "release"; - public static final int DEFAULT_FAILBACK_TASKS = 100; + public static final int MAX_PROXY_COUNT = 65535; + // END common - public static final int DEFAULT_FAILBACK_TIMES = 3; + // BEGIN dubbo-remoting-api + public static final String PAYLOAD_KEY = "payload"; + /** + * 8M + */ + public static final int DEFAULT_PAYLOAD = 8 * 1024 * 1024; - public static final int MAX_PROXY_COUNT = 65535; + public static final String BUFFER_KEY = "buffer"; /** * default buffer size is 8k. */ public static final int DEFAULT_BUFFER_SIZE = 8 * 1024; - public static final Integer DEFAULT_METADATA_REPORT_RETRY_TIMES = 100; - public static final Integer DEFAULT_METADATA_REPORT_RETRY_PERIOD = 3000; - public static final Boolean DEFAULT_METADATA_REPORT_CYCLE_REPORT = true; - public static final int MAX_BUFFER_SIZE = 16 * 1024; public static final int MIN_BUFFER_SIZE = 1 * 1024; - public static final String REMOVE_VALUE_PREFIX = "-"; + public static final String CONNECT_TIMEOUT_KEY = "connect.timeout"; - public static final String PROPERTIES_CHAR_SEPERATOR = "-"; + public static final int DEFAULT_CONNECT_TIMEOUT = 3000; - public static final String GROUP_CHAR_SEPERATOR = ":"; + public static final String HEARTBEAT_KEY = "heartbeat"; - public static final String HIDE_KEY_PREFIX = "."; + public static final int DEFAULT_HEARTBEAT = 60 * 1000; - public static final String DEFAULT_KEY_PREFIX = "default."; + public static final String IDLE_TIMEOUT_KEY = "idle.timeout"; - public static final String DEFAULT_KEY = "default"; + public static final int DEFAULT_IDLE_TIMEOUT = 600 * 1000; - public static final String LOADBALANCE_KEY = "loadbalance"; + public static final String ACCEPTS_KEY = "accepts"; - /** - * key for router type, for e.g., "script"/"file", corresponding to ScriptRouterFactory.NAME, FileRouterFactory.NAME - */ - public static final String ROUTER_KEY = "router"; + public static final int DEFAULT_ACCEPTS = 0; - public static final String CLUSTER_KEY = "cluster"; + public static final String SERIALIZATION_KEY = "serialization"; - public static final String REGISTRY_KEY = "registry"; + public static final String DEFAULT_REMOTING_SERIALIZATION = "hessian2"; - public static final String METADATA_REPORT_KEY = "metadata"; + public static final String CODEC_KEY = "codec"; - public static final String MONITOR_KEY = "monitor"; + public static final String DEFAULT_REMOTING_CODEC = "dubbo"; - public static final String SIDE_KEY = "side"; + public static final String SERVER_KEY = "server"; - public static final String PROVIDER_SIDE = "provider"; + public static final String DEFAULT_REMOTING_SERVER = "netty"; - public static final String CONSUMER_SIDE = "consumer"; + public static final String CLIENT_KEY = "client"; - public static final String DEFAULT_REGISTRY = "dubbo"; + public static final String DEFAULT_REMOTING_CLIENT = "netty"; - public static final String BACKUP_KEY = "backup"; + public static final String TRANSPORTER_KEY = "transporter"; - public static final String DIRECTORY_KEY = "directory"; + public static final String DEFAULT_TRANSPORTER = "netty"; - public static final String DEPRECATED_KEY = "deprecated"; + public static final String EXCHANGER_KEY = "exchanger"; - public static final String ANYHOST_KEY = "anyhost"; + public static final String DEFAULT_EXCHANGER = "header"; - public static final String ANYHOST_VALUE = "0.0.0.0"; + public static final String DISPACTHER_KEY = "dispacther"; - public static final String LOCALHOST_KEY = "localhost"; + public static final int DEFAULT_IO_THREADS = Math.min(Runtime.getRuntime().availableProcessors() + 1, 32); - public static final String LOCALHOST_VALUE = "127.0.0.1"; + public static final String BIND_IP_KEY = "bind.ip"; - public static final String APPLICATION_KEY = "application"; + public static final String BIND_PORT_KEY = "bind.port"; - public static final String REMOTE_APPLICATION_KEY = "remote.application"; + public static final String SENT_KEY = "sent"; - public static final String LOCAL_KEY = "local"; + public static final boolean DEFAULT_SENT = false; - public static final String STUB_KEY = "stub"; + public static final String DISPATCHER_KEY = "dispatcher"; - public static final String MOCK_KEY = "mock"; + public static final String CHANNEL_HANDLER_KEY = "channel.handler"; - public static final String PROTOCOL_KEY = "protocol"; + public static final String DEFAULT_CHANNEL_HANDLER = "default"; - public static final String LOGSTAT_PROTOCOL = "logstat"; + public static final String SERVICE_DESCIPTOR_KEY = "serviceDescriptor"; - public static final String DUBBO_PROTOCOL = DUBBO; + public static final String CONNECT_QUEUE_CAPACITY = "connect.queue.capacity"; - public static final String ZOOKEEPER_PROTOCOL = "zookeeper"; + public static final String CONNECT_QUEUE_WARNING_SIZE = "connect.queue.warning.size"; - public static final String PROXY_KEY = "proxy"; + public static final int DEFAULT_CONNECT_QUEUE_WARNING_SIZE = 1000; - public static final String WEIGHT_KEY = "weight"; + public static final String CHANNEL_ATTRIBUTE_READONLY_KEY = "channel.readonly"; - public static final String FORKS_KEY = "forks"; + public static final String CHANNEL_READONLYEVENT_SENT_KEY = "channel.readonly.sent"; - public static final String DEFAULT_THREADPOOL = "limited"; + public static final String CHANNEL_SEND_READONLYEVENT_KEY = "channel.readonly.send"; - public static final String DEFAULT_CLIENT_THREADPOOL = "cached"; + public static final String EXECUTOR_SERVICE_COMPONENT_KEY = ExecutorService.class.getName(); - public static final String THREADPOOL_KEY = "threadpool"; + public static final String CHARSET_KEY = "charset"; - public static final String THREAD_NAME_KEY = "threadname"; + public static final String DEFAULT_CHARSET = "UTF-8"; - public static final String IO_THREADS_KEY = "iothreads"; + public static final String BACKUP_KEY = "backup"; - public static final String CORE_THREADS_KEY = "corethreads"; + /** + * Every heartbeat duration / HEATBEAT_CHECK_TICK, check if a heartbeat should be sent. Every heartbeat timeout + * duration / HEATBEAT_CHECK_TICK, check if a connection should be closed on server side, and if reconnect on + * client side + */ + public static final int HEARTBEAT_CHECK_TICK = 3; - public static final String THREADS_KEY = "threads"; - - public static final String QUEUES_KEY = "queues"; - - public static final String ALIVE_KEY = "alive"; - - public static final String EXECUTES_KEY = "executes"; - - public static final String BUFFER_KEY = "buffer"; - - public static final String PAYLOAD_KEY = "payload"; - - public static final String REFERENCE_FILTER_KEY = "reference.filter"; - - public static final String INVOKER_LISTENER_KEY = "invoker.listener"; - - public static final String SERVICE_FILTER_KEY = "service.filter"; - - public static final String EXPORTER_LISTENER_KEY = "exporter.listener"; - - public static final String ACCESS_LOG_KEY = "accesslog"; - - public static final String ACTIVES_KEY = "actives"; - - public static final String CONNECTIONS_KEY = "connections"; - - public static final String ACCEPTS_KEY = "accepts"; - - public static final String IDLE_TIMEOUT_KEY = "idle.timeout"; - - public static final String HEARTBEAT_KEY = "heartbeat"; - - /** - * Every heartbeat duration / HEATBEAT_CHECK_TICK, check if a heartbeat should be sent. Every heartbeat timeout - * duration / HEATBEAT_CHECK_TICK, check if a connection should be closed on server side, and if reconnect on - * client side - */ - public static final int HEARTBEAT_CHECK_TICK = 3; - - /** - * the least heartbeat during is 1000 ms. - */ - public static final long LEAST_HEARTBEAT_DURATION = 1000; + /** + * the least heartbeat during is 1000 ms. + */ + public static final long LEAST_HEARTBEAT_DURATION = 1000; /** * ticks per wheel. @@ -332,272 +283,304 @@ public class Constants { public static final String HEARTBEAT_TIMEOUT_KEY = "heartbeat.timeout"; - public static final String CONNECT_TIMEOUT_KEY = "connect.timeout"; + public static final String RECONNECT_KEY = "reconnect"; - public static final String TIMEOUT_KEY = "timeout"; + public static final int DEFAULT_RECONNECT_PERIOD = 2000; - public static final String RETRIES_KEY = "retries"; + public static final String SEND_RECONNECT_KEY = "send.reconnect"; - public static final String FAIL_BACK_TASKS_KEY = "failbacktasks"; + public static final String CHECK_KEY = "check"; public static final String PROMPT_KEY = "prompt"; public static final String DEFAULT_PROMPT = "dubbo>"; + // END dubbo-remoting-api - public static final String CODEC_KEY = "codec"; - - public static final String SERIALIZATION_KEY = "serialization"; - - public static final String EXTENSION_KEY = "extension"; - - public static final String KEEP_ALIVE_KEY = "keepalive"; - - public static final String OPTIMIZER_KEY = "optimizer"; + // BEGIN dubbo-rpc-hessian + public static final String HESSIAN2_REQUEST_KEY = "hessian2.request"; - public static final String EXCHANGER_KEY = "exchanger"; + public static final boolean DEFAULT_HESSIAN2_REQUEST = false; - public static final String DISPACTHER_KEY = "dispacther"; + public static final String HESSIAN_OVERLOAD_METHOD_KEY = "hessian.overload.method"; - public static final String TRANSPORTER_KEY = "transporter"; + public static final boolean DEFAULT_HESSIAN_OVERLOAD_METHOD = false; - public static final String SERVER_KEY = "server"; + public static final String DEFAULT_HTTP_CLIENT = "jdk"; - public static final String CLIENT_KEY = "client"; + public static final String DEFAULT_HTTP_SERVER = "servlet"; - public static final String ID_KEY = "id"; + public static final String DEFAULT_HTTP_SERIALIZATION = "json"; + // END dubbo-rpc-hessian - public static final String ASYNC_KEY = "async"; + // BEGIN dubbo-rpc-dubbo + public static final String SHARE_CONNECTIONS_KEY = "shareconnections"; - public static final String FUTURE_GENERATED_KEY = "future_generated"; - public static final String FUTURE_RETURNTYPE_KEY = "future_returntype"; + /** + * By default, a consumer JVM instance and a provider JVM instance share a long TCP connection (except when connections are set), + * which can set the number of long TCP connections shared to avoid the bottleneck of sharing a single long TCP connection. + */ + public static final String DEFAULT_SHARE_CONNECTIONS = "1"; - public static final String ASYNC_SUFFIX = "Async"; + public static final String INPUT_KEY = "input"; - public static final String RETURN_KEY = "return"; + public static final String OUTPUT_KEY = "output"; - public static final String TOKEN_KEY = "token"; + public static final String DECODE_IN_IO_THREAD_KEY = "decode.in.io"; - public static final String METHOD_KEY = "method"; + public static final boolean DEFAULT_DECODE_IN_IO_THREAD = true; - public static final String METHODS_KEY = "methods"; + /** + * callback inst id + */ + public static final String CALLBACK_SERVICE_KEY = "callback.service.instid"; - public static final String CHARSET_KEY = "charset"; + /** + * The limit of callback service instances for one interface on every client + */ + public static final String CALLBACK_INSTANCES_LIMIT_KEY = "callbacks"; - public static final String RECONNECT_KEY = "reconnect"; + /** + * The default limit number for callback service instances + * + * @see #CALLBACK_INSTANCES_LIMIT_KEY + */ + public static final int DEFAULT_CALLBACK_INSTANCES = 1; - public static final String SEND_RECONNECT_KEY = "send.reconnect"; + public static final String CALLBACK_SERVICE_PROXY_KEY = "callback.service.proxy"; - public static final int DEFAULT_RECONNECT_PERIOD = 2000; + public static final String IS_CALLBACK_SERVICE = "is_callback_service"; - public static final String SHUTDOWN_TIMEOUT_KEY = "shutdown.timeout"; + /** + * Invokers in channel's callback + */ + public static final String CHANNEL_CALLBACK_KEY = "channel.callback.invokers.key"; - public static final int DEFAULT_SHUTDOWN_TIMEOUT = 1000 * 60 * 15; + /** + * The initial state for lazy connection + */ + public static final String LAZY_CONNECT_INITIAL_STATE_KEY = "connect.lazy.initial.state"; - public static final String PID_KEY = "pid"; + /** + * The default value of lazy connection's initial state: true + * + * @see #LAZY_CONNECT_INITIAL_STATE_KEY + */ + public static final boolean DEFAULT_LAZY_CONNECT_INITIAL_STATE = true; - public static final String TIMESTAMP_KEY = "timestamp"; + public static final String OPTIMIZER_KEY = "optimizer"; + // END dubbo-rpc-dubbo - public static final String REMOTE_TIMESTAMP_KEY = "remote.timestamp"; - public static final String WARMUP_KEY = "warmup"; + // BEGIN dubbo-rpc-api + public static final String DUBBO_VERSION_KEY = "dubbo"; - public static final int DEFAULT_WARMUP = 10 * 60 * 1000; + public static final String LOCAL_KEY = "local"; - public static final String CHECK_KEY = "check"; + public static final String STUB_KEY = "stub"; - public static final String REGISTER_KEY = "register"; + public static final String MOCK_KEY = "mock"; - public static final String SUBSCRIBE_KEY = "subscribe"; + public static final String DEPRECATED_KEY = "deprecated"; - public static final String GROUP_KEY = "group"; + public static final String $INVOKE = "$invoke"; - public static final String PATH_KEY = "path"; + public static final String $ECHO = "$echo"; - public static final String INTERFACE_KEY = "interface"; + public static final String RETURN_PREFIX = "return "; - public static final String INTERFACES = "interfaces"; + public static final String THROW_PREFIX = "throw"; - public static final String GENERIC_KEY = "generic"; + public static final String FAIL_PREFIX = "fail:"; - public static final String FILE_KEY = "file"; + public static final String FORCE_PREFIX = "force:"; - public static final String DUMP_DIRECTORY = "dump.directory"; + public static final String MERGER_KEY = "merger"; - public static final String WAIT_KEY = "wait"; + public static final String IS_SERVER_KEY = "isserver"; - public static final String CLASSIFIER_KEY = "classifier"; + public static final String FORCE_USE_TAG = "dubbo.force.tag"; - public static final String VERSION_KEY = "version"; + public static final String GENERIC_SERIALIZATION_NATIVE_JAVA = "nativejava"; - public static final String REVISION_KEY = "revision"; + public static final String GENERIC_SERIALIZATION_DEFAULT = "true"; - public static final String DUBBO_VERSION_KEY = "dubbo"; + public static final String GENERIC_SERIALIZATION_BEAN = "bean"; - public static final String HESSIAN_VERSION_KEY = "hessian.version"; + public static final String GENERIC_SERIALIZATION_PROTOBUF = "protobuf-json"; - public static final String DISPATCHER_KEY = "dispatcher"; + public static final String TPS_LIMIT_RATE_KEY = "tps"; - public static final String CHANNEL_HANDLER_KEY = "channel.handler"; + public static final String TPS_LIMIT_INTERVAL_KEY = "tps.interval"; - public static final String DEFAULT_CHANNEL_HANDLER = "default"; + public static final long DEFAULT_TPS_LIMIT_INTERVAL = 60 * 1000; - public static final String SERVICE_DESCIPTOR_KEY = "serviceDescriptor"; + public static final String AUTO_ATTACH_INVOCATIONID_KEY = "invocationid.autoattach"; - public static final String ANY_VALUE = "*"; + public static final String STUB_EVENT_KEY = "dubbo.stub.event"; - public static final String COMMA_SEPARATOR = ","; + public static final boolean DEFAULT_STUB_EVENT = false; - public static final Pattern COMMA_SPLIT_PATTERN = Pattern - .compile("\\s*[,]+\\s*"); + public static final String STUB_EVENT_METHODS_KEY = "dubbo.stub.event.methods"; - public final static String PATH_SEPARATOR = "/"; + public static final String PROXY_KEY = "proxy"; - public final static String PROTOCOL_SEPARATOR = "://"; + public static final String EXECUTES_KEY = "executes"; - public static final String REGISTRY_SEPARATOR = "|"; + public static final String REFERENCE_FILTER_KEY = "reference.filter"; - public static final Pattern REGISTRY_SPLIT_PATTERN = Pattern - .compile("\\s*[|;]+\\s*"); + public static final String INVOKER_LISTENER_KEY = "invoker.listener"; - public static final String SEMICOLON_SEPARATOR = ";"; + public static final String SERVICE_FILTER_KEY = "service.filter"; - public static final Pattern SEMICOLON_SPLIT_PATTERN = Pattern - .compile("\\s*[;]+\\s*"); + public static final String EXPORTER_LISTENER_KEY = "exporter.listener"; - public static final String CONNECT_QUEUE_CAPACITY = "connect.queue.capacity"; + public static final String ACCESS_LOG_KEY = "accesslog"; - public static final String CONNECT_QUEUE_WARNING_SIZE = "connect.queue.warning.size"; + public static final String ACTIVES_KEY = "actives"; - public static final int DEFAULT_CONNECT_QUEUE_WARNING_SIZE = 1000; + public static final String CONNECTIONS_KEY = "connections"; - public static final String CHANNEL_ATTRIBUTE_READONLY_KEY = "channel.readonly"; + public static final String ID_KEY = "id"; - public static final String CHANNEL_READONLYEVENT_SENT_KEY = "channel.readonly.sent"; + public static final String ASYNC_KEY = "async"; - public static final String CHANNEL_SEND_READONLYEVENT_KEY = "channel.readonly.send"; + public static final String FUTURE_GENERATED_KEY = "future_generated"; - public static final String COUNT_PROTOCOL = "count"; + public static final String FUTURE_RETURNTYPE_KEY = "future_returntype"; - public static final String TRACE_PROTOCOL = "trace"; + public static final String RETURN_KEY = "return"; - public static final String EMPTY_PROTOCOL = "empty"; + public static final String TOKEN_KEY = "token"; - public static final String ADMIN_PROTOCOL = "admin"; + public static final String INTERFACES = "interfaces"; - public static final String PROVIDER_PROTOCOL = "provider"; + public static final String GENERIC_KEY = "generic"; - public static final String CONSUMER_PROTOCOL = "consumer"; + public static final String LOCAL_PROTOCOL = "injvm"; + // END dubbo-rpc-api - public static final String ROUTE_PROTOCOL = "route"; - public static final String SCRIPT_PROTOCOL = "script"; + // BEGIN dubbo-rpc-rest + public static final String KEEP_ALIVE_KEY = "keepalive"; - public static final String CONDITION_PROTOCOL = "condition"; + public static final boolean DEFAULT_KEEP_ALIVE = true; - public static final String MOCK_PROTOCOL = "mock"; + public static final String EXTENSION_KEY = "extension"; + // END dubbo-rpc-rest - public static final String RETURN_PREFIX = "return "; - public static final String THROW_PREFIX = "throw"; + // BEGIN dubbo-config-api + public static final String CLUSTER_KEY = "cluster"; - public static final String FAIL_PREFIX = "fail:"; + public static final String STATUS_KEY = "status"; - public static final String FORCE_PREFIX = "force:"; + public static final String CONTEXTPATH_KEY = "contextpath"; - public static final String FORCE_KEY = "force"; + public static final String LISTENER_KEY = "listener"; - public static final String MERGER_KEY = "merger"; + public static final String LAYER_KEY = "layer"; /** - * simple the registry for provider. - * - * @since 2.7.0 + * General */ - public static final String SIMPLIFIED_KEY = "simplified"; - /** - * After simplify the registry, should add some paramter individually for provider. - * - * @since 2.7.0 + * Application name; */ - public static final String EXTRA_KEYS_KEY = "extra-keys"; + public static final String NAME = "name"; /** - * To decide whether to exclude unavailable invoker from the cluster + * Application owner name; */ - public static final String CLUSTER_AVAILABLE_CHECK_KEY = "cluster.availablecheck"; + public static final String OWNER = "owner"; /** - * The default value of cluster.availablecheck - * - * @see #CLUSTER_AVAILABLE_CHECK_KEY + * Running application organization name. */ - public static final boolean DEFAULT_CLUSTER_AVAILABLE_CHECK = true; + public static final String ORGANIZATION = "organization"; /** - * To decide whether to enable sticky strategy for cluster + * Application architecture name. */ - public static final String CLUSTER_STICKY_KEY = "sticky"; + public static final String ARCHITECTURE = "architecture"; /** - * The default value of sticky - * - * @see #CLUSTER_STICKY_KEY + * Environment name */ - public static final boolean DEFAULT_CLUSTER_STICKY = false; + public static final String ENVIRONMENT = "environment"; /** - * To decide whether to make connection when the client is created + * Test environment key. */ - public static final String LAZY_CONNECT_KEY = "lazy"; + public static final String TEST_ENVIRONMENT = "test"; /** - * The initial state for lazy connection + * Development environment key. */ - public static final String LAZY_CONNECT_INITIAL_STATE_KEY = "connect.lazy.initial.state"; + public static final String DEVELOPMENT_ENVIRONMENT = "develop"; /** - * The default value of lazy connection's initial state: true - * - * @see #LAZY_CONNECT_INITIAL_STATE_KEY + * Production environment key. */ - public static final boolean DEFAULT_LAZY_CONNECT_INITIAL_STATE = true; + public static final String PRODUCTION_ENVIRONMENT = "product"; - /** - * To decide whether register center saves file synchronously, the default value is asynchronously - */ - public static final String REGISTRY_FILESAVE_SYNC_KEY = "save.file"; + public static final String CONFIG_CLUSTER_KEY = "config.cluster"; + public static final String CONFIG_NAMESPACE_KEY = "config.namespace"; + public static final String CONFIG_GROUP_KEY = "config.group"; + public static final String CONFIG_CHECK_KEY = "config.check"; - /** - * Period of registry center's retry interval - */ - public static final String REGISTRY_RETRY_PERIOD_KEY = "retry.period"; + public static final String CONFIG_CONFIGFILE_KEY = "config.config-file"; + public static final String CONFIG_ENABLE_KEY = "config.highest-priority"; + public static final String CONFIG_TIMEOUT_KEY = "config.timeout"; + public static final String CONFIG_APPNAME_KEY = "config.app-name"; - /** - * Most retry times - */ - public static final String REGISTRY_RETRY_TIMES_KEY = "retry.times"; + public static final String USERNAME_KEY = "username"; - /** - * Default value for the period of retry interval in milliseconds: 5000 - */ - public static final int DEFAULT_REGISTRY_RETRY_PERIOD = 5 * 1000; + public static final String PASSWORD_KEY = "password"; - /** - * Default value for the times of retry: 3 - */ - public static final int DEFAULT_REGISTRY_RETRY_TIMES = 3; + public static final String HOST_KEY = "host"; - /** - * Reconnection period in milliseconds for register center - */ - public static final String REGISTRY_RECONNECT_PERIOD_KEY = "reconnect.period"; + public static final String PORT_KEY = "port"; - public static final int DEFAULT_REGISTRY_RECONNECT_PERIOD = 3 * 1000; + public static final String MULTICAST = "multicast"; - public static final String SESSION_TIMEOUT_KEY = "session"; + public static final String REGISTER_IP_KEY = "register.ip"; - public static final int DEFAULT_SESSION_TIMEOUT = 60 * 1000; + public static final String DUBBO_IP_TO_REGISTRY = "DUBBO_IP_TO_REGISTRY"; + + public static final String DUBBO_PORT_TO_REGISTRY = "DUBBO_PORT_TO_REGISTRY"; + + public static final String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND"; + + public static final String DUBBO_PORT_TO_BIND = "DUBBO_PORT_TO_BIND"; + + public static final String SCOPE_KEY = "scope"; + + public static final String SCOPE_LOCAL = "local"; + + public static final String SCOPE_REMOTE = "remote"; + + public static final String SCOPE_NONE = "none"; + + public static final String ON_CONNECT_KEY = "onconnect"; + + public static final String ON_DISCONNECT_KEY = "ondisconnect"; + + public static final String ON_INVOKE_METHOD_KEY = "oninvoke.method"; + + public static final String ON_RETURN_METHOD_KEY = "onreturn.method"; + + public static final String ON_THROW_METHOD_KEY = "onthrow.method"; + + public static final String ON_INVOKE_INSTANCE_KEY = "oninvoke.instance"; + + public static final String ON_RETURN_INSTANCE_KEY = "onreturn.instance"; + + public static final String ON_THROW_INSTANCE_KEY = "onthrow.instance"; + + @Deprecated + public static final String SHUTDOWN_WAIT_SECONDS_KEY = "dubbo.service.shutdown.wait.seconds"; + + public static final String SHUTDOWN_WAIT_KEY = "dubbo.service.shutdown.wait"; /** * The key name for export URL in register center @@ -610,263 +593,248 @@ public class Constants { public static final String REFER_KEY = "refer"; /** - * callback inst id + * To decide whether to make connection when the client is created */ - public static final String CALLBACK_SERVICE_KEY = "callback.service.instid"; + public static final String LAZY_CONNECT_KEY = "lazy"; - /** - * The limit of callback service instances for one interface on every client - */ - public static final String CALLBACK_INSTANCES_LIMIT_KEY = "callbacks"; + public static final String DUBBO_PROTOCOL = DUBBO; - /** - * The default limit number for callback service instances - * - * @see #CALLBACK_INSTANCES_LIMIT_KEY - */ - public static final int DEFAULT_CALLBACK_INSTANCES = 1; + public static final String ZOOKEEPER_PROTOCOL = "zookeeper"; - public static final String CALLBACK_SERVICE_PROXY_KEY = "callback.service.proxy"; + // FIXME: is this still useful? + public static final String SHUTDOWN_TIMEOUT_KEY = "shutdown.timeout"; - public static final String IS_CALLBACK_SERVICE = "is_callback_service"; + public static final int DEFAULT_SHUTDOWN_TIMEOUT = 1000 * 60 * 15; - /** - * Invokers in channel's callback - */ - public static final String CHANNEL_CALLBACK_KEY = "channel.callback.invokers.key"; + public static final String PROTOCOLS_SUFFIX = "dubbo.protocols."; - @Deprecated - public static final String SHUTDOWN_WAIT_SECONDS_KEY = "dubbo.service.shutdown.wait.seconds"; + public static final String PROTOCOL_SUFFIX = "dubbo.protocol."; - public static final String SHUTDOWN_WAIT_KEY = "dubbo.service.shutdown.wait"; + public static final String REGISTRIES_SUFFIX = "dubbo.registries."; - public static final String IS_SERVER_KEY = "isserver"; + public static final String TELNET = "telnet"; - /** - * Default timeout value in milliseconds for server shutdown - */ - public static final int DEFAULT_SERVER_SHUTDOWN_TIMEOUT = 10000; + public static final String QOS_ENABLE = "qos.enable"; - public static final String ON_CONNECT_KEY = "onconnect"; + public static final String QOS_PORT = "qos.port"; + + public static final String ACCEPT_FOREIGN_IP = "qos.accept.foreign.ip"; + // END dubbo-congfig-api + + // BEGIN dubbo-cluster + /** + * key for router type, for e.g., "script"/"file", corresponding to ScriptRouterFactory.NAME, FileRouterFactory.NAME + */ + public static final String ROUTER_KEY = "router"; - public static final String ON_DISCONNECT_KEY = "ondisconnect"; + public static final String LOADBALANCE_KEY = "loadbalance"; - public static final String ON_INVOKE_METHOD_KEY = "oninvoke.method"; + public static final String DEFAULT_LOADBALANCE = "random"; - public static final String ON_RETURN_METHOD_KEY = "onreturn.method"; + public static final String FAIL_BACK_TASKS_KEY = "failbacktasks"; - public static final String ON_THROW_METHOD_KEY = "onthrow.method"; + public static final int DEFAULT_FAILBACK_TASKS = 100; - public static final String ON_INVOKE_INSTANCE_KEY = "oninvoke.instance"; + public static final String RETRIES_KEY = "retries"; - public static final String ON_RETURN_INSTANCE_KEY = "onreturn.instance"; + public static final int DEFAULT_RETRIES = 2; - public static final String ON_THROW_INSTANCE_KEY = "onthrow.instance"; + public static final int DEFAULT_FAILBACK_TIMES = 3; - public static final String OVERRIDE_PROTOCOL = "override"; + public static final String FORKS_KEY = "forks"; - public static final String CONFIG_PROTOCOL = "config"; + public static final int DEFAULT_FORKS = 2; - public static final String PRIORITY_KEY = "priority"; + public static final String WEIGHT_KEY = "weight"; - public static final String RULE_KEY = "rule"; + public static final int DEFAULT_WEIGHT = 100; - public static final String TYPE_KEY = "type"; + public static final String MOCK_PROTOCOL = "mock"; - public static final String RUNTIME_KEY = "runtime"; + public static final String FORCE_KEY = "force"; /** - * when ROUTER_KEY's value is set to ROUTER_TYPE_CLEAR, RegistryDirectory will clean all current routers + * To decide whether to exclude unavailable invoker from the cluster */ - public static final String ROUTER_TYPE_CLEAR = "clean"; + public static final String CLUSTER_AVAILABLE_CHECK_KEY = "cluster.availablecheck"; - public static final String DEFAULT_SCRIPT_TYPE_KEY = "javascript"; + /** + * The default value of cluster.availablecheck + * + * @see #CLUSTER_AVAILABLE_CHECK_KEY + */ + public static final boolean DEFAULT_CLUSTER_AVAILABLE_CHECK = true; - public static final String STUB_EVENT_KEY = "dubbo.stub.event"; + /** + * To decide whether to enable sticky strategy for cluster + */ + public static final String CLUSTER_STICKY_KEY = "sticky"; - public static final boolean DEFAULT_STUB_EVENT = false; + /** + * The default value of sticky + * + * @see #CLUSTER_STICKY_KEY + */ + public static final boolean DEFAULT_CLUSTER_STICKY = false; - public static final String STUB_EVENT_METHODS_KEY = "dubbo.stub.event.methods"; + public static final String ADDRESS_KEY = "address"; /** * When this attribute appears in invocation's attachment, mock invoker will be used */ public static final String INVOCATION_NEED_MOCK = "invocation.need.mock"; - public static final String LOCAL_PROTOCOL = "injvm"; - - public static final String AUTO_ATTACH_INVOCATIONID_KEY = "invocationid.autoattach"; - - public static final String SCOPE_KEY = "scope"; - - public static final String SCOPE_LOCAL = "local"; - - public static final String SCOPE_REMOTE = "remote"; - - public static final String SCOPE_NONE = "none"; + /** + * when ROUTER_KEY's value is set to ROUTER_TYPE_CLEAR, RegistryDirectory will clean all current routers + */ + public static final String ROUTER_TYPE_CLEAR = "clean"; - public static final String RELIABLE_PROTOCOL = "napoli"; + public static final String DEFAULT_SCRIPT_TYPE_KEY = "javascript"; - public static final String TPS_LIMIT_RATE_KEY = "tps"; + public static final String PRIORITY_KEY = "priority"; - public static final String TPS_LIMIT_INTERVAL_KEY = "tps.interval"; + public static final String RULE_KEY = "rule"; - public static final long DEFAULT_TPS_LIMIT_INTERVAL = 60 * 1000; + public static final String TYPE_KEY = "type"; - public static final String DECODE_IN_IO_THREAD_KEY = "decode.in.io"; + public static final String RUNTIME_KEY = "runtime"; - public static final boolean DEFAULT_DECODE_IN_IO_THREAD = true; + public static final String TAG_KEY = "dubbo.tag"; - public static final String INPUT_KEY = "input"; + public static final String REMOTE_TIMESTAMP_KEY = "remote.timestamp"; - public static final String OUTPUT_KEY = "output"; + public static final String WARMUP_KEY = "warmup"; - public static final String EXECUTOR_SERVICE_COMPONENT_KEY = ExecutorService.class.getName(); + public static final int DEFAULT_WARMUP = 10 * 60 * 1000; - public static final String GENERIC_SERIALIZATION_NATIVE_JAVA = "nativejava"; + public static final String CONFIG_VERSION_KEY = "configVersion"; - public static final String GENERIC_SERIALIZATION_DEFAULT = "true"; + public static final String OVERRIDE_PROVIDERS_KEY = "providerAddresses"; + // END dubbo-cluster - public static final String GENERIC_SERIALIZATION_BEAN = "bean"; + // BEGIN dubbo-registry-api + public static final String REGISTER_KEY = "register"; - public static final String GENERIC_SERIALIZATION_PROTOBUF = "protobuf-json"; + public static final String SUBSCRIBE_KEY = "subscribe"; - public static final String DUBBO_IP_TO_REGISTRY = "DUBBO_IP_TO_REGISTRY"; + public static final String REGISTRY_KEY = "registry"; - public static final String DUBBO_PORT_TO_REGISTRY = "DUBBO_PORT_TO_REGISTRY"; + public static final String DEFAULT_REGISTRY = "dubbo"; - public static final String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND"; + public static final String REGISTRY_PROTOCOL = "registry"; - public static final String DUBBO_PORT_TO_BIND = "DUBBO_PORT_TO_BIND"; + public static final String DYNAMIC_KEY = "dynamic"; - public static final String BIND_IP_KEY = "bind.ip"; + public static final String REGISTER = "register"; - public static final String BIND_PORT_KEY = "bind.port"; + public static final String UNREGISTER = "unregister"; - public static final String REGISTER_IP_KEY = "register.ip"; + public static final String SUBSCRIBE = "subscribe"; - public static final String QOS_ENABLE = "qos.enable"; + public static final String UNSUBSCRIBE = "unsubscribe"; - public static final String QOS_PORT = "qos.port"; + public static final String CATEGORY_KEY = "category"; - public static final String ACCEPT_FOREIGN_IP = "qos.accept.foreign.ip"; + public static final String PROVIDERS_CATEGORY = "providers"; - public static final String HESSIAN2_REQUEST_KEY = "hessian2.request"; + public static final String CONSUMERS_CATEGORY = "consumers"; - public static final boolean DEFAULT_HESSIAN2_REQUEST = false; + public static final String ROUTERS_CATEGORY = "routers"; - public static final String HESSIAN_OVERLOAD_METHOD_KEY = "hessian.overload.method"; + public static final String DYNAMIC_ROUTERS_CATEGORY = "dynamicrouters"; - public static final boolean DEFAULT_HESSIAN_OVERLOAD_METHOD = false; + public static final String DEFAULT_CATEGORY = PROVIDERS_CATEGORY; - public static final String MULTICAST = "multicast"; + public static final String CONFIGURATORS_CATEGORY = "configurators"; - public static final String TAG_KEY = "dubbo.tag"; + public static final String DYNAMIC_CONFIGURATORS_CATEGORY = "dynamicconfigurators"; - public static final String FORCE_USE_TAG = "dubbo.force.tag"; + public static final String APP_DYNAMIC_CONFIGURATORS_CATEGORY = "appdynamicconfigurators"; - public static final String HOST_KEY = "host"; + public static final String CONFIGURATORS_SUFFIX = ".configurators"; - public static final String PORT_KEY = "port"; + public static final String ROUTERS_SUFFIX = ".routers"; - public static final String USERNAME_KEY = "username"; + public static final String TRACE_PROTOCOL = "trace"; - public static final String PASSWORD_KEY = "password"; + public static final String EMPTY_PROTOCOL = "empty"; - public static final String ADDRESS_KEY = "address"; + public static final String ADMIN_PROTOCOL = "admin"; - public static final String RETRY_TIMES_KEY = "retry.times"; + public static final String PROVIDER_PROTOCOL = "provider"; - public static final String RETRY_PERIOD_KEY = "retry.period"; + public static final String CONSUMER_PROTOCOL = "consumer"; - public static final String SYNC_REPORT_KEY = "sync.report"; + public static final String ROUTE_PROTOCOL = "route"; - public static final String CYCLE_REPORT_KEY = "cycle.report"; + public static final String SCRIPT_PROTOCOL = "script"; - public static final String CONFIG_VERSION_KEY = "configVersion"; + public static final String CONDITION_PROTOCOL = "condition"; - public static final String COMPATIBLE_CONFIG_KEY = "compatible_config"; /** - * package version in the manifest + * simple the registry for provider. + * + * @since 2.7.0 */ - public static final String RELEASE_KEY = "release"; - - public static final String OVERRIDE_PROVIDERS_KEY = "providerAddresses"; + public static final String SIMPLIFIED_KEY = "simplified"; - public static final String PROTOCOLS_SUFFIX = "dubbo.protocols."; + /** + * After simplify the registry, should add some paramter individually for provider. + * + * @since 2.7.0 + */ + public static final String EXTRA_KEYS_KEY = "extra-keys"; - public static final String PROTOCOL_SUFFIX = "dubbo.protocol."; + public static final String OVERRIDE_PROTOCOL = "override"; - public static final String REGISTRIES_SUFFIX = "dubbo.registries."; + public static final String COMPATIBLE_CONFIG_KEY = "compatible_config"; public static final String[] DEFAULT_REGISTER_PROVIDER_KEYS = {APPLICATION_KEY, CODEC_KEY, EXCHANGER_KEY, SERIALIZATION_KEY, CLUSTER_KEY, CONNECTIONS_KEY, DEPRECATED_KEY, GROUP_KEY, LOADBALANCE_KEY, MOCK_KEY, PATH_KEY, TIMEOUT_KEY, TOKEN_KEY, VERSION_KEY, WARMUP_KEY, WEIGHT_KEY, TIMESTAMP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY}; public static final String[] DEFAULT_REGISTER_CONSUMER_KEYS = {APPLICATION_KEY, VERSION_KEY, GROUP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY}; - public static final String TELNET = "telnet"; - - /** - * Hash nodes name - */ - public static final String HASH_NODES = "hash.nodes"; - - /** - * Hash arguments name - */ - public static final String HASH_ARGUMENTS = "hash.arguments"; - - /** - * Application name; - */ - public static final String NAME = "name"; - - /** - * Application owner name; - */ - public static final String OWNER = "owner"; - /** - * Running application organization name. + * To decide whether register center saves file synchronously, the default value is asynchronously */ - public static final String ORGANIZATION = "organization"; + public static final String REGISTRY_FILESAVE_SYNC_KEY = "save.file"; /** - * Application architecture name. + * Period of registry center's retry interval */ - public static final String ARCHITECTURE = "architecture"; + public static final String REGISTRY_RETRY_PERIOD_KEY = "retry.period"; /** - * Environment name + * Most retry times */ - public static final String ENVIRONMENT = "environment"; + public static final String REGISTRY_RETRY_TIMES_KEY = "retry.times"; /** - * Test environment key. + * Default value for the period of retry interval in milliseconds: 5000 */ - public static final String TEST_ENVIRONMENT = "test"; + public static final int DEFAULT_REGISTRY_RETRY_PERIOD = 5 * 1000; /** - * Development environment key. + * Default value for the times of retry: 3 */ - public static final String DEVELOPMENT_ENVIRONMENT = "develop"; + public static final int DEFAULT_REGISTRY_RETRY_TIMES = 3; /** - * Production environment key. + * Reconnection period in milliseconds for register center */ - public static final String PRODUCTION_ENVIRONMENT = "product"; - - public static final String ETCD3_NOTIFY_MAXTHREADS_KEYS = "etcd3.notify.maxthreads"; + public static final String REGISTRY_RECONNECT_PERIOD_KEY = "reconnect.period"; - public static final int DEFAULT_ETCD3_NOTIFY_THREADS = DEFAULT_IO_THREADS; + public static final int DEFAULT_REGISTRY_RECONNECT_PERIOD = 3 * 1000; - public static final String DEFAULT_ETCD3_NOTIFY_QUEUES_KEY = "etcd3.notify.queues"; + public static final String SESSION_TIMEOUT_KEY = "session"; - public static final int DEFAULT_GRPC_QUEUES = 300_0000; + public static final int DEFAULT_SESSION_TIMEOUT = 60 * 1000; + // END dubbo-registry-api - /** - * metrics - */ + // BEGIN dubbo-monitor-api + public static final String MONITOR_KEY = "monitor"; + public static final String LOGSTAT_PROTOCOL = "logstat"; + public static final String COUNT_PROTOCOL = "count"; public static final String DUBBO_PROVIDER = "dubbo.provider"; public static final String DUBBO_CONSUMER = "dubbo.consumer"; public static final String DUBBO_PROVIDER_METHOD = "dubbo.provider.method"; @@ -877,20 +845,52 @@ public class Constants { public static final String METRICS_KEY = "metrics"; public static final String METRICS_PORT = "metrics.port"; public static final String METRICS_PROTOCOL = "metrics.protocol"; + // END dubbo-monitor-api + + // BEGIN dubbo-metadata-report-api + public static final String METADATA_REPORT_KEY = "metadata"; + + public static final String RETRY_TIMES_KEY = "retry.times"; + public static final Integer DEFAULT_METADATA_REPORT_RETRY_TIMES = 100; + + public static final String RETRY_PERIOD_KEY = "retry.period"; + + public static final Integer DEFAULT_METADATA_REPORT_RETRY_PERIOD = 3000; + + public static final String SYNC_REPORT_KEY = "sync.report"; + + public static final String CYCLE_REPORT_KEY = "cycle.report"; + + public static final Boolean DEFAULT_METADATA_REPORT_CYCLE_REPORT = true; + // END dubbo-metadata-report-api + + // BEGIN dubbo-filter-cache + public static final String CACHE_KEY = "cache"; + // END dubbo-filter-cache + + + // BEGIN dubbo-filter-validation + public static final String VALIDATION_KEY = "validation"; + // END dubbo-filter-validation + + public static final String DEFAULT_CLUSTER = "failover"; /** - * Serizlization ContentTypeId + * public static final int DEFAULT_REGISTRY_CONNECT_TIMEOUT = 5000; */ - public static final byte HESSIAN2_SERIALIZATION_ID = 2; - public static final byte JAVA_SERIALIZATION_ID = 3; - public static final byte COMPACTED_JAVA_SERIALIZATION_ID = 4; - public static final byte FASTJSON_SERIALIZATION_ID = 6; - public static final byte NATIVE_JAVA_SERIALIZATION_ID = 7; - public static final byte KRYO_SERIALIZATION_ID = 8; - public static final byte FST_SERIALIZATION_ID = 9; - public static final byte PROTOSTUFF_SERIALIZATION_ID = 10; - public static final byte AVRO_SERIALIZATION_ID = 11; - public static final byte GSON_SERIALIZATION_ID = 16; + public static final String DIRECTORY_KEY = "directory"; + + public static final String ASYNC_SUFFIX = "Async"; + + public static final String WAIT_KEY = "wait"; + + public static final String HESSIAN_VERSION_KEY = "hessian.version"; + + + public static final String CONFIG_PROTOCOL = "config"; + + + public static final String RELIABLE_PROTOCOL = "napoli"; } 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 a514728b62f..6c5870bd47e 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 @@ -64,7 +64,6 @@ import static org.apache.dubbo.common.Constants.CONFIGURATORS_SUFFIX; import static org.apache.dubbo.common.Constants.CONSUMERS_CATEGORY; import static org.apache.dubbo.common.Constants.CONSUMER_PROTOCOL; -import static org.apache.dubbo.common.Constants.DEFAULT_DIRECTORY; import static org.apache.dubbo.common.Constants.DEFAULT_REGISTER_CONSUMER_KEYS; import static org.apache.dubbo.common.Constants.DEFAULT_REGISTER_PROVIDER_KEYS; import static org.apache.dubbo.common.Constants.DEFAULT_REGISTRY; @@ -276,7 +275,7 @@ private Registry getRegistry(final Invoker originInvoker) { private URL getRegistryUrl(Invoker originInvoker) { URL registryUrl = originInvoker.getUrl(); if (REGISTRY_PROTOCOL.equals(registryUrl.getProtocol())) { - String protocol = registryUrl.getParameter(REGISTRY_KEY, DEFAULT_DIRECTORY); + String protocol = registryUrl.getParameter(REGISTRY_KEY, DEFAULT_REGISTRY); registryUrl = registryUrl.setProtocol(protocol).removeParameter(REGISTRY_KEY); } return registryUrl; diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.java index 9125f8479ac..ca48dcaf1e0 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.java @@ -31,6 +31,10 @@ import java.util.Map; import java.util.Set; +import static org.apache.dubbo.common.serialize.Constants.COMPACTED_JAVA_SERIALIZATION_ID; +import static org.apache.dubbo.common.serialize.Constants.JAVA_SERIALIZATION_ID; +import static org.apache.dubbo.common.serialize.Constants.NATIVE_JAVA_SERIALIZATION_ID; + public class CodecSupport { private static final Logger logger = LoggerFactory.getLogger(CodecSupport.class); @@ -71,7 +75,7 @@ public static Serialization getSerialization(URL url, Byte id) throws IOExceptio String serializationName = url.getParameter(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION); // Check if "serialization id" passed from network matches the id on this side(only take effect for JDK serialization), for security purpose. if (serialization == null - || ((id == Constants.JAVA_SERIALIZATION_ID || id == Constants.NATIVE_JAVA_SERIALIZATION_ID || id == Constants.COMPACTED_JAVA_SERIALIZATION_ID) + || ((id == JAVA_SERIALIZATION_ID || id == NATIVE_JAVA_SERIALIZATION_ID || id == COMPACTED_JAVA_SERIALIZATION_ID) && !(serializationName.equals(ID_SERIALIZATIONNAME_MAP.get(id))))) { throw new IOException("Unexpected serialization id:" + id + " received from network, please check if the peer send the right id."); } 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 new file mode 100644 index 00000000000..7bc1a98bd25 --- /dev/null +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java @@ -0,0 +1,31 @@ +/* + * 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; + +import static org.apache.dubbo.common.Constants.DEFAULT_IO_THREADS; + +public interface Constants { + String ETCD3_NOTIFY_MAXTHREADS_KEYS = "etcd3.notify.maxthreads"; + + int DEFAULT_ETCD3_NOTIFY_THREADS = DEFAULT_IO_THREADS; + + String DEFAULT_ETCD3_NOTIFY_QUEUES_KEY = "etcd3.notify.queues"; + + int DEFAULT_GRPC_QUEUES = 300_0000; +} + 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 634a6eda0b3..c1f8e2cb936 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,6 +60,10 @@ import java.util.concurrent.locks.ReentrantLock; import static java.util.stream.Collectors.toList; +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.ETCD3_NOTIFY_MAXTHREADS_KEYS; import static org.apache.dubbo.remoting.etcd.jetcd.JEtcdClientWrapper.UTF_8; /** @@ -92,10 +96,10 @@ public JEtcdClient(URL url) { notifyExecutor = new ThreadPoolExecutor( 1 - , url.getParameter(Constants.ETCD3_NOTIFY_MAXTHREADS_KEYS, Constants.DEFAULT_ETCD3_NOTIFY_THREADS) + , url.getParameter(ETCD3_NOTIFY_MAXTHREADS_KEYS, DEFAULT_ETCD3_NOTIFY_THREADS) , Constants.DEFAULT_SESSION_TIMEOUT , TimeUnit.MILLISECONDS - , new LinkedBlockingQueue(url.getParameter(Constants.DEFAULT_ETCD3_NOTIFY_QUEUES_KEY, Constants.DEFAULT_GRPC_QUEUES * 3)) + , new LinkedBlockingQueue(url.getParameter(DEFAULT_ETCD3_NOTIFY_QUEUES_KEY, DEFAULT_GRPC_QUEUES * 3)) , new NamedThreadFactory("etcd3-notify", true)); clientWrapper.start(); diff --git a/dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Constants.java b/dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Constants.java new file mode 100644 index 00000000000..56cae66891a --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Constants.java @@ -0,0 +1,33 @@ +/* + * 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.common.serialize; + +public interface Constants { + byte HESSIAN2_SERIALIZATION_ID = 2; + byte JAVA_SERIALIZATION_ID = 3; + byte COMPACTED_JAVA_SERIALIZATION_ID = 4; + byte FASTJSON_SERIALIZATION_ID = 6; + byte NATIVE_JAVA_SERIALIZATION_ID = 7; + byte KRYO_SERIALIZATION_ID = 8; + byte FST_SERIALIZATION_ID = 9; + byte NATIVE_HESSIAN_SERIALIZATION_ID = 10; + byte PROTOSTUFF_SERIALIZATION_ID = 12; + byte AVRO_SERIALIZATION_ID = 11; + byte GSON_SERIALIZATION_ID = 16; + byte PROTOBUF_JSON_SERIALIZATION_ID = 21; +} diff --git a/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroSerialization.java b/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroSerialization.java index 37eb320f19b..7eb291ec343 100644 --- a/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroSerialization.java +++ b/dubbo-serialization/dubbo-serialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.avro; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,11 +25,13 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.AVRO_SERIALIZATION_ID; + public class AvroSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.AVRO_SERIALIZATION_ID; + return AVRO_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerialization.java b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerialization.java index d1d804e14d0..84c5721ce5b 100644 --- a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerialization.java +++ b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.fastjson; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.FASTJSON_SERIALIZATION_ID; + /** * FastJson serialization implementation * @@ -37,7 +38,7 @@ public class FastJsonSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.FASTJSON_SERIALIZATION_ID; + return FASTJSON_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-fst/src/main/java/org/apache/dubbo/common/serialize/fst/FstSerialization.java b/dubbo-serialization/dubbo-serialization-fst/src/main/java/org/apache/dubbo/common/serialize/fst/FstSerialization.java index c9201d22a3d..b8862f377ce 100644 --- a/dubbo-serialization/dubbo-serialization-fst/src/main/java/org/apache/dubbo/common/serialize/fst/FstSerialization.java +++ b/dubbo-serialization/dubbo-serialization-fst/src/main/java/org/apache/dubbo/common/serialize/fst/FstSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.fst; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.FST_SERIALIZATION_ID; + /** * Fst serialization implementation * @@ -37,7 +38,7 @@ public class FstSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.FST_SERIALIZATION_ID; + return FST_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonSerialization.java b/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonSerialization.java index cb4c2f9b088..a22769a2802 100644 --- a/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonSerialization.java +++ b/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonSerialization.java @@ -17,7 +17,6 @@ package org.apache.dubbo.common.serialize.gson; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -27,12 +26,14 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.GSON_SERIALIZATION_ID; + public class GsonSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.GSON_SERIALIZATION_ID; + return GSON_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java b/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java index 2c46c5b1933..010a5b6f31a 100644 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java +++ b/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.hessian2; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.HESSIAN2_SERIALIZATION_ID; + /** * Hessian2 serialization implementation, hessian2 is the default serialization protocol for dubbo * @@ -37,7 +38,7 @@ public class Hessian2Serialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.HESSIAN2_SERIALIZATION_ID; + return HESSIAN2_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedJavaSerialization.java b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedJavaSerialization.java index e1b75abf0a1..2df9db1aa2a 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedJavaSerialization.java +++ b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/CompactedJavaSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.java; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.COMPACTED_JAVA_SERIALIZATION_ID; + /** * Compacted java serialization implementation * @@ -37,7 +38,7 @@ public class CompactedJavaSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.COMPACTED_JAVA_SERIALIZATION_ID; + return COMPACTED_JAVA_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java index 01d29ee7c04..2045e4efa45 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java +++ b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.java; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.JAVA_SERIALIZATION_ID; + /** * Java serialization implementation * @@ -37,7 +38,7 @@ public class JavaSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.JAVA_SERIALIZATION_ID; + return JAVA_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java index 2d89161ead9..6617d29f6ad 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java +++ b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java @@ -17,7 +17,6 @@ package org.apache.dubbo.common.serialize.nativejava; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -27,6 +26,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.NATIVE_JAVA_SERIALIZATION_ID; + /** * Native java serialization implementation * @@ -39,7 +40,7 @@ public class NativeJavaSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.NATIVE_JAVA_SERIALIZATION_ID; + return NATIVE_JAVA_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/KryoSerialization.java b/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/KryoSerialization.java index 4f903ff707b..369192a9cd0 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/KryoSerialization.java +++ b/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/KryoSerialization.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.kryo; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -26,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.KRYO_SERIALIZATION_ID; + /** * TODO for now kryo serialization doesn't deny classes that don't implement the serializable interface * @@ -37,7 +38,7 @@ public class KryoSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.KRYO_SERIALIZATION_ID; + return KRYO_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-native-hession/src/main/java/org/apache/dubbo/serialize/hessian/Hessian2Serialization.java b/dubbo-serialization/dubbo-serialization-native-hession/src/main/java/org/apache/dubbo/serialize/hessian/Hessian2Serialization.java index aeda121d015..ee5887682d1 100644 --- a/dubbo-serialization/dubbo-serialization-native-hession/src/main/java/org/apache/dubbo/serialize/hessian/Hessian2Serialization.java +++ b/dubbo-serialization/dubbo-serialization-native-hession/src/main/java/org/apache/dubbo/serialize/hessian/Hessian2Serialization.java @@ -26,11 +26,13 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.NATIVE_HESSIAN_SERIALIZATION_ID; + public class Hessian2Serialization implements Serialization { @Override public byte getContentTypeId() { - return 10; + return NATIVE_HESSIAN_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java index 8b9395c95b7..d3d23300173 100644 --- a/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java +++ b/dubbo-serialization/dubbo-serialization-protobuf-json/src/main/java/org/apache/dubbo/common/serialize/protobuf/support/GenericProtobufSerialization.java @@ -24,6 +24,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.PROTOBUF_JSON_SERIALIZATION_ID; + /** * This serizalization is use for google protobuf generic reference. * The entity be transported between client and server by json string. @@ -33,7 +35,7 @@ public class GenericProtobufSerialization implements Serialization { @Override public byte getContentTypeId() { - return 21; + return PROTOBUF_JSON_SERIALIZATION_ID; } @Override @@ -50,4 +52,4 @@ public ObjectOutput serialize(URL url, OutputStream output) { public ObjectInput deserialize(URL url, InputStream input) { return new GenericProtobufObjectInput(input); } -} \ No newline at end of file +} diff --git a/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffSerialization.java b/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffSerialization.java index 66b6833ba41..5218cef9835 100644 --- a/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffSerialization.java +++ b/dubbo-serialization/dubbo-serialization-protostuff/src/main/java/org/apache/dubbo/common/serialize/protostuff/ProtostuffSerialization.java @@ -17,7 +17,6 @@ package org.apache.dubbo.common.serialize.protostuff; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -27,6 +26,8 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.PROTOSTUFF_SERIALIZATION_ID; + /** * Protostuff serialization implementation * @@ -37,7 +38,7 @@ public class ProtostuffSerialization implements Serialization { @Override public byte getContentTypeId() { - return Constants.PROTOSTUFF_SERIALIZATION_ID; + return PROTOSTUFF_SERIALIZATION_ID; } @Override diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/avro/AvroSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/avro/AvroSerializationTest.java index ee591cba4af..d679f384b2c 100644 --- a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/avro/AvroSerializationTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/avro/AvroSerializationTest.java @@ -16,7 +16,6 @@ */ package org.apache.dubbo.common.serialize.avro; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; import org.hamcrest.Matchers; @@ -28,6 +27,7 @@ import java.io.InputStream; import java.io.OutputStream; +import static org.apache.dubbo.common.serialize.Constants.AVRO_SERIALIZATION_ID; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.mock; @@ -47,7 +47,7 @@ public void testContentType() { @Test public void testContentTypeId() { - assertThat(avroSerialization.getContentTypeId(), is(Constants.AVRO_SERIALIZATION_ID)); + assertThat(avroSerialization.getContentTypeId(), is(AVRO_SERIALIZATION_ID)); } @Test