From 8e3675ef06d085aa1538de82cb8337a146dc76e4 Mon Sep 17 00:00:00 2001 From: huazhongming Date: Sat, 11 May 2019 17:38:37 +0800 Subject: [PATCH 1/4] [DUBBO-3137]: step3 - seperate constants for remoting (#4023) * constants step3-remoting * remove import * modify --- .../configurator/AbstractConfigurator.java | 3 ++- .../rpc/cluster/support/ClusterUtils.java | 5 +++-- .../org/apache/dubbo/common/Constants.java | 4 +++- .../java/org/apache/dubbo/common/URL.java | 5 +++-- .../common/constants/RegistryConstants.java | 6 +++--- .../apache/dubbo/common/utils/UrlUtils.java | 7 ++++--- .../dubbo/config/AbstractReferenceConfig.java | 3 ++- .../apache/dubbo/config/ProtocolConfig.java | 15 ++++++++------- .../apache/dubbo/config/ProviderConfig.java | 7 ++++--- .../apache/dubbo/config/ReferenceConfig.java | 3 ++- .../apache/dubbo/config/RegistryConfig.java | 7 ++++--- .../apache/dubbo/config/ServiceConfig.java | 5 +++-- .../dubbo/config/annotation/Reference.java | 3 ++- .../config/AbstractReferenceConfigTest.java | 3 ++- .../dubbo/config/ServiceConfigTest.java | 5 +++-- .../nacos/NacosDynamicConfiguration.java | 2 +- .../integration/MetadataReportService.java | 5 +++-- .../monitor/dubbo/DubboMonitorFactory.java | 2 +- .../dubbo/monitor/dubbo/MetricsFilter.java | 3 ++- .../integration/RegistryDirectory.java | 3 ++- .../integration/RegistryProtocol.java | 6 +++--- .../registry/support/FailbackRegistry.java | 17 +++++++++-------- .../dubbo/registry/dubbo/DubboRegistry.java | 3 ++- .../registry/dubbo/DubboRegistryFactory.java | 9 +++++---- .../registry/dubbo/DubboRegistryTest.java | 5 +++-- .../registry/dubbo/RegistryDirectoryTest.java | 3 ++- .../dubbo/registry/etcd/EtcdRegistry.java | 5 +++-- .../dubbo/registry/etcd/EtcdRegistryTest.java | 3 ++- .../registry/nacos/NacosRegistryFactory.java | 2 +- .../dubbo/registry/redis/RedisRegistry.java | 3 ++- .../registry/redis/RedisRegistryTest.java | 2 +- .../registry/zookeeper/ZookeeperRegistry.java | 5 +++-- .../java/org/apache/dubbo/remoting/Codec.java | 6 +++--- .../org/apache/dubbo/remoting/Codec2.java | 6 +++--- .../org/apache/dubbo/remoting/Dispatcher.java | 4 ++-- .../apache/dubbo/remoting/Transporter.java | 6 +++--- .../dubbo/remoting/exchange/Exchanger.java | 6 +++--- .../dubbo/remoting/exchange/Exchangers.java | 8 ++++---- .../support/header/HeaderExchangeClient.java | 12 ++++++------ .../support/header/HeaderExchangeHandler.java | 4 ++-- .../support/header/HeaderExchangeServer.java | 14 +++++++------- .../support/header/HeartbeatHandler.java | 4 ++-- .../remoting/telnet/codec/TelnetCodec.java | 8 ++++---- .../telnet/support/TelnetHandlerAdapter.java | 3 ++- .../remoting/transport/AbstractClient.java | 5 +++-- .../remoting/transport/AbstractCodec.java | 5 +++-- .../remoting/transport/AbstractEndpoint.java | 11 ++++++----- .../remoting/transport/AbstractPeer.java | 4 ++-- .../remoting/transport/AbstractServer.java | 19 ++++++++++--------- .../remoting/transport/CodecSupport.java | 6 +++--- .../dispatcher/WrappedChannelHandler.java | 3 ++- .../ConnectionOrderedChannelHandler.java | 5 +++-- .../dubbo/remoting/ChanelHandlerTest.java | 5 +++-- .../remoting/PerformanceClientCloseTest.java | 5 +++-- .../remoting/PerformanceClientFixedTest.java | 5 +++-- .../dubbo/remoting/PerformanceClientTest.java | 6 +++--- .../dubbo/remoting/PerformanceServerTest.java | 11 ++++++----- .../remoting/codec/ExchangeCodecTest.java | 9 ++++----- .../support/header/HeartBeatTaskTest.java | 5 +++-- .../handler/HeaderExchangeHandlerTest.java | 4 ++-- .../codec/DeprecatedTelnetCodec.java | 9 +++++---- .../apache/dubbo/remoting/etcd/Constants.java | 2 +- .../dubbo/remoting/etcd/EtcdTransporter.java | 4 ++-- .../grizzly/GrizzlyCodecAdapter.java | 6 +++--- .../dubbo/remoting/http/HttpBinder.java | 4 ++-- .../remoting/http/jetty/JettyHttpServer.java | 13 +++++++------ .../http/servlet/ServletHttpServer.java | 4 ++-- .../http/tomcat/TomcatHttpServer.java | 3 ++- .../http/jetty/JettyHttpBinderTest.java | 4 ++-- .../http/tomcat/TomcatHttpBinderTest.java | 4 ++-- .../remoting/transport/mina/MinaClient.java | 4 ++-- .../transport/mina/MinaCodecAdapter.java | 6 +++--- .../remoting/transport/mina/MinaServer.java | 3 ++- .../remoting/transport/netty/NettyClient.java | 4 ++-- .../transport/netty/NettyCodecAdapter.java | 6 +++--- .../remoting/transport/netty/NettyServer.java | 3 ++- .../support/header/HeartbeatHandlerTest.java | 14 +++++++------- .../transport/netty/ClientReconnectTest.java | 4 ++-- .../netty/NettyClientToServerTest.java | 6 +++--- .../transport/netty4/NettyClient.java | 4 ++-- .../transport/netty4/NettyServer.java | 3 ++- .../transport/netty4/ClientReconnectTest.java | 4 ++-- .../netty4/NettyClientToServerTest.java | 6 +++--- .../netty4/NettyTransporterTest.java | 6 +++--- .../exchange/support/ExchangeServerPeer.java | 4 ++-- .../remoting/p2p/support/ServerPeer.java | 4 ++-- .../zookeeper/ZookeeperTransporter.java | 4 ++-- .../support/AbstractZookeeperTransporter.java | 7 ++++--- .../dubbo/rpc/filter/CompatibleFilter.java | 4 ++-- .../dubbo/rpc/protocol/AbstractProtocol.java | 3 ++- .../rpc/protocol/AbstractProxyProtocol.java | 5 +++-- .../protocol/dubbo/ChannelWrappedInvoker.java | 3 ++- .../rpc/protocol/dubbo/DubboInvoker.java | 5 +++-- .../rpc/protocol/dubbo/DubboProtocol.java | 17 +++++++++-------- .../dubbo/LazyConnectExchangeClient.java | 3 ++- .../dubbo/ReferenceCountExchangeClient.java | 5 +++-- .../protocol/dubbo/filter/TraceFilter.java | 3 ++- .../dubbo/status/ThreadPoolStatusChecker.java | 4 ++-- .../dubbo/DubboInvokerAvilableTest.java | 9 +++++---- .../rpc/protocol/dubbo/DubboProtocolTest.java | 6 +++--- .../DubboHessianURLConnectionFactory.java | 4 ++-- .../rpc/protocol/hessian/HessianProtocol.java | 7 ++++--- .../hessian/HttpClientConnectionFactory.java | 4 ++-- .../dubbo/rpc/protocol/http/HttpProtocol.java | 7 ++++--- .../protocol/memcached/MemcachedProtocol.java | 4 ++-- .../rpc/protocol/redis/RedisProtocol.java | 3 ++- .../rpc/protocol/redis/RedisProtocolTest.java | 4 ++-- .../dubbo/rpc/protocol/rest/NettyServer.java | 9 +++++---- .../dubbo/rpc/protocol/rest/RestProtocol.java | 7 ++++--- .../rpc/protocol/rest/RestProtocolTest.java | 11 ++++++----- .../rpc/protocol/thrift/ThriftInvoker.java | 3 ++- .../rpc/protocol/thrift/ThriftProtocol.java | 11 ++++++----- .../webservice/WebServiceProtocol.java | 3 ++- 113 files changed, 350 insertions(+), 287 deletions(-) diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java index 5e53b1bbd54..15665a5b74e 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.rpc.cluster.Configurator; @@ -104,7 +105,7 @@ private URL configureIfMatch(String host, URL url) { || configApplication.equals(currentApplication)) { Set conditionKeys = new HashSet(); conditionKeys.add(Constants.CATEGORY_KEY); - conditionKeys.add(Constants.CHECK_KEY); + conditionKeys.add(RemotingConstants.CHECK_KEY); conditionKeys.add(Constants.DYNAMIC_KEY); conditionKeys.add(Constants.ENABLED_KEY); conditionKeys.add(Constants.GROUP_KEY); diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java index e6ed749f0cb..6c58740eb88 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.StringUtils; import java.util.HashMap; @@ -59,8 +60,8 @@ public static URL mergeUrl(URL remoteUrl, Map localMap) { map.remove(Constants.ALIVE_KEY); map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.ALIVE_KEY); - map.remove(Constants.TRANSPORTER_KEY); - map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.TRANSPORTER_KEY); + map.remove(RemotingConstants.TRANSPORTER_KEY); + map.remove(Constants.DEFAULT_KEY_PREFIX + RemotingConstants.TRANSPORTER_KEY); map.remove(Constants.ASYNC_KEY); map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.ASYNC_KEY); 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 42c9f39748f..73c1f21662d 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 @@ -17,6 +17,8 @@ package org.apache.dubbo.common; +import org.apache.dubbo.common.constants.RemotingConstants; + import java.util.concurrent.ExecutorService; import java.util.regex.Pattern; @@ -789,7 +791,7 @@ public class Constants { 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, + public static final String[] DEFAULT_REGISTER_PROVIDER_KEYS = {APPLICATION_KEY, RemotingConstants.CODEC_KEY, RemotingConstants.EXCHANGER_KEY, RemotingConstants.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}; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java index 35a3b7bd1f9..e77e6ff208e 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.config.Configuration; import org.apache.dubbo.common.config.InmemoryConfiguration; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.ArrayUtils; import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.common.utils.NetUtils; @@ -414,7 +415,7 @@ public String getBackupAddress() { public String getBackupAddress(int defaultPort) { StringBuilder address = new StringBuilder(appendDefaultPort(getAddress(), defaultPort)); - String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]); + String[] backups = getParameter(RemotingConstants.BACKUP_KEY, new String[0]); if (ArrayUtils.isNotEmpty(backups)) { for (String backup : backups) { address.append(","); @@ -427,7 +428,7 @@ public String getBackupAddress(int defaultPort) { public List getBackupUrls() { List urls = new ArrayList<>(); urls.add(this); - String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]); + String[] backups = getParameter(RemotingConstants.BACKUP_KEY, new String[0]); if (backups != null && backups.length > 0) { for (String backup : backups) { urls.add(this.setAddress(backup)); diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java index bcfc9dcc436..331a67c587c 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java @@ -19,17 +19,17 @@ import static org.apache.dubbo.common.Constants.APPLICATION_KEY; import static org.apache.dubbo.common.Constants.CLUSTER_KEY; -import static org.apache.dubbo.common.Constants.CODEC_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.CODEC_KEY; import static org.apache.dubbo.common.Constants.CONNECTIONS_KEY; import static org.apache.dubbo.common.Constants.DEPRECATED_KEY; import static org.apache.dubbo.common.Constants.DUBBO_VERSION_KEY; -import static org.apache.dubbo.common.Constants.EXCHANGER_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.EXCHANGER_KEY; import static org.apache.dubbo.common.Constants.GROUP_KEY; import static org.apache.dubbo.common.Constants.LOADBALANCE_KEY; import static org.apache.dubbo.common.Constants.MOCK_KEY; import static org.apache.dubbo.common.Constants.PATH_KEY; import static org.apache.dubbo.common.Constants.RELEASE_KEY; -import static org.apache.dubbo.common.Constants.SERIALIZATION_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.SERIALIZATION_KEY; import static org.apache.dubbo.common.Constants.TIMEOUT_KEY; import static org.apache.dubbo.common.Constants.TIMESTAMP_KEY; import static org.apache.dubbo.common.Constants.TOKEN_KEY; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java index f7ca5c007b9..32ab016af43 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import java.util.ArrayList; import java.util.HashMap; @@ -60,7 +61,7 @@ public static URL parseURL(String address, Map defaults) { } backup.append(addresses[i]); } - url += URL_PARAM_STARTING_SYMBOL + Constants.BACKUP_KEY + "=" + backup.toString(); + url += URL_PARAM_STARTING_SYMBOL + RemotingConstants.BACKUP_KEY + "=" + backup.toString(); } } String defaultProtocol = defaults == null ? null : defaults.get(Constants.PROTOCOL_KEY); @@ -468,12 +469,12 @@ public static boolean isProvider(URL url) { } public static int getHeartbeat(URL url) { - return url.getParameter(Constants.HEARTBEAT_KEY, Constants.DEFAULT_HEARTBEAT); + return url.getParameter(RemotingConstants.HEARTBEAT_KEY, RemotingConstants.DEFAULT_HEARTBEAT); } public static int getIdleTimeout(URL url) { int heartBeat = getHeartbeat(url); - int idleTimeout = url.getParameter(Constants.HEARTBEAT_TIMEOUT_KEY, heartBeat * 3); + int idleTimeout = url.getParameter(RemotingConstants.HEARTBEAT_TIMEOUT_KEY, heartBeat * 3); if (idleTimeout < heartBeat * 2) { throw new IllegalStateException("idleTimeout < heartbeatInterval * 2"); } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java index cf490ed4079..75281e965e1 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java @@ -17,6 +17,7 @@ package org.apache.dubbo.config; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.config.support.Parameter; import org.apache.dubbo.rpc.InvokerListener; import org.apache.dubbo.rpc.support.ProtocolUtils; @@ -179,7 +180,7 @@ public Boolean getStubevent() { return stubevent; } - @Parameter(key = Constants.RECONNECT_KEY) + @Parameter(key = RemotingConstants.RECONNECT_KEY) public String getReconnect() { return reconnect; } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java index 008f7bf03fb..4cb2f7dcdd7 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java @@ -17,6 +17,7 @@ package org.apache.dubbo.config; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.serialize.Serialization; import org.apache.dubbo.common.status.StatusChecker; @@ -318,7 +319,7 @@ public String getCodec() { public void setCodec(String codec) { if (Constants.DUBBO_PROTOCOL.equals(name)) { - checkMultiExtension(Codec.class, Constants.CODEC_KEY, codec); + checkMultiExtension(Codec.class, RemotingConstants.CODEC_KEY, codec); } this.codec = codec; } @@ -329,7 +330,7 @@ public String getSerialization() { public void setSerialization(String serialization) { if (Constants.DUBBO_PROTOCOL.equals(name)) { - checkMultiExtension(Serialization.class, Constants.SERIALIZATION_KEY, serialization); + checkMultiExtension(Serialization.class, RemotingConstants.SERIALIZATION_KEY, serialization); } this.serialization = serialization; } @@ -372,7 +373,7 @@ public String getServer() { public void setServer(String server) { if (Constants.DUBBO_PROTOCOL.equals(name)) { - checkMultiExtension(Transporter.class, Constants.SERVER_KEY, server); + checkMultiExtension(Transporter.class, RemotingConstants.SERVER_KEY, server); } this.server = server; } @@ -383,7 +384,7 @@ public String getClient() { public void setClient(String client) { if (Constants.DUBBO_PROTOCOL.equals(name)) { - checkMultiExtension(Transporter.class, Constants.CLIENT_KEY, client); + checkMultiExtension(Transporter.class, RemotingConstants.CLIENT_KEY, client); } this.client = client; } @@ -436,7 +437,7 @@ public String getTransporter() { } public void setTransporter(String transporter) { - checkExtension(Transporter.class, Constants.TRANSPORTER_KEY, transporter); + checkExtension(Transporter.class, RemotingConstants.TRANSPORTER_KEY, transporter); this.transporter = transporter; } @@ -445,7 +446,7 @@ public String getExchanger() { } public void setExchanger(String exchanger) { - checkExtension(Exchanger.class, Constants.EXCHANGER_KEY, exchanger); + checkExtension(Exchanger.class, RemotingConstants.EXCHANGER_KEY, exchanger); this.exchanger = exchanger; } @@ -475,7 +476,7 @@ public String getDispatcher() { } public void setDispatcher(String dispatcher) { - checkExtension(Dispatcher.class, Constants.DISPACTHER_KEY, dispatcher); + checkExtension(Dispatcher.class, RemotingConstants.DISPACTHER_KEY, dispatcher); this.dispatcher = dispatcher; } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProviderConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProviderConfig.java index 58e9748d312..b76ab7958fb 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProviderConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProviderConfig.java @@ -17,6 +17,7 @@ package org.apache.dubbo.config; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.status.StatusChecker; import org.apache.dubbo.common.threadpool.ThreadPool; import org.apache.dubbo.config.support.Parameter; @@ -367,7 +368,7 @@ public String getTransporter() { } public void setTransporter(String transporter) { - checkExtension(Transporter.class, Constants.TRANSPORTER_KEY, transporter); + checkExtension(Transporter.class, RemotingConstants.TRANSPORTER_KEY, transporter); this.transporter = transporter; } @@ -376,7 +377,7 @@ public String getExchanger() { } public void setExchanger(String exchanger) { - checkExtension(Exchanger.class, Constants.EXCHANGER_KEY, exchanger); + checkExtension(Exchanger.class, RemotingConstants.EXCHANGER_KEY, exchanger); this.exchanger = exchanger; } @@ -406,7 +407,7 @@ public String getDispatcher() { } public void setDispatcher(String dispatcher) { - checkExtension(Dispatcher.class, Constants.DISPATCHER_KEY, dispatcher); + checkExtension(Dispatcher.class, RemotingConstants.DISPATCHER_KEY, dispatcher); checkExtension(Dispatcher.class, "dispather", dispatcher); this.dispatcher = dispatcher; } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java index 5ecae9c0519..32f5dd14dcd 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.common.Version; import org.apache.dubbo.common.bytecode.Wrapper; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.utils.ClassUtils; import org.apache.dubbo.common.utils.CollectionUtils; @@ -561,7 +562,7 @@ public String getClient() { } public void setClient(String client) { - checkName(Constants.CLIENT_KEY, client); + checkName(RemotingConstants.CLIENT_KEY, client); this.client = client; } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java index 994518795f1..bb72e218e85 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java @@ -17,6 +17,7 @@ package org.apache.dubbo.config; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.config.support.Parameter; @@ -269,7 +270,7 @@ public String getTransporter() { } public void setTransporter(String transporter) { - checkName(Constants.TRANSPORTER_KEY, transporter); + checkName(RemotingConstants.TRANSPORTER_KEY, transporter); /*if(transporter != null && transporter.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(transporter)){ throw new IllegalStateException("No such transporter type : " + transporter); }*/ @@ -281,7 +282,7 @@ public String getServer() { } public void setServer(String server) { - checkName(Constants.SERVER_KEY, server); + checkName(RemotingConstants.SERVER_KEY, server); /*if(server != null && server.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(server)){ throw new IllegalStateException("No such server type : " + server); }*/ @@ -293,7 +294,7 @@ public String getClient() { } public void setClient(String client) { - checkName(Constants.CLIENT_KEY, client); + checkName(RemotingConstants.CLIENT_KEY, client); /*if(client != null && client.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(client)){ throw new IllegalStateException("No such client type : " + client); }*/ diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java index 86c5ed45f9a..0c755b475bf 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java @@ -22,6 +22,7 @@ import org.apache.dubbo.common.Version; import org.apache.dubbo.common.bytecode.Wrapper; import org.apache.dubbo.common.config.Environment; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.utils.ClassUtils; import org.apache.dubbo.common.utils.CollectionUtils; @@ -684,7 +685,7 @@ private String findConfigedHosts(ProtocolConfig protocolConfig, List regist } } - map.put(Constants.BIND_IP_KEY, hostToBind); + map.put(RemotingConstants.BIND_IP_KEY, hostToBind); // registry ip is not used for bind ip by default String hostToRegistry = getValueFromConfig(protocolConfig, Constants.DUBBO_IP_TO_REGISTRY); @@ -736,7 +737,7 @@ private Integer findConfigedPorts(ProtocolConfig protocolConfig, String name, Ma } // save bind port, used as url's key later - map.put(Constants.BIND_PORT_KEY, String.valueOf(portToBind)); + map.put(RemotingConstants.BIND_PORT_KEY, String.valueOf(portToBind)); // registry port, not used as bind port by default String portToRegistryStr = getValueFromConfig(protocolConfig, Constants.DUBBO_PORT_TO_REGISTRY); diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/annotation/Reference.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/annotation/Reference.java index c4851bd1031..5b22abdbc9b 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/annotation/Reference.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/annotation/Reference.java @@ -17,6 +17,7 @@ package org.apache.dubbo.config.annotation; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.rpc.ExporterListener; import org.apache.dubbo.rpc.Filter; @@ -101,7 +102,7 @@ * Whether to reconnect if connection is lost, if not specify, reconnect is enabled by default, and the interval * for retry connecting is 2000 ms * - * @see Constants#DEFAULT_RECONNECT_PERIOD + * @see RemotingConstants#DEFAULT_RECONNECT_PERIOD */ String reconnect() default ""; diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractReferenceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractReferenceConfigTest.java index c77d3fde823..92985b20f7b 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractReferenceConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractReferenceConfigTest.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -125,7 +126,7 @@ public void testReconnect() throws Exception { Map parameters = new HashMap(); AbstractInterfaceConfig.appendParameters(parameters, referenceConfig); assertThat(referenceConfig.getReconnect(), equalTo("reconnect")); - assertThat(parameters, hasKey(Constants.RECONNECT_KEY)); + assertThat(parameters, hasKey(RemotingConstants.RECONNECT_KEY)); } @Test diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java index 2dff18b5af5..3a54f30c5ff 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.config.api.DemoService; import org.apache.dubbo.config.api.Greeting; import org.apache.dubbo.config.context.ConfigManager; @@ -132,8 +133,8 @@ public void testExport() throws Exception { assertThat(url.getPath(), equalTo(DemoService.class.getName())); assertThat(url.getParameters(), hasEntry(Constants.ANYHOST_KEY, "true")); assertThat(url.getParameters(), hasEntry(Constants.APPLICATION_KEY, "app")); - assertThat(url.getParameters(), hasKey(Constants.BIND_IP_KEY)); - assertThat(url.getParameters(), hasKey(Constants.BIND_PORT_KEY)); + assertThat(url.getParameters(), hasKey(RemotingConstants.BIND_IP_KEY)); + assertThat(url.getParameters(), hasKey(RemotingConstants.BIND_PORT_KEY)); assertThat(url.getParameters(), hasEntry(Constants.EXPORT_KEY, "true")); assertThat(url.getParameters(), hasEntry("echo.0.callback", "false")); assertThat(url.getParameters(), hasEntry(Constants.GENERIC_KEY, "false")); diff --git a/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java index fdb536fa8a3..2d63c99ec29 100644 --- a/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java +++ b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java @@ -44,7 +44,7 @@ import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR; import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE; import static com.alibaba.nacos.client.naming.utils.UtilAndComs.NACOS_NAMING_LOG_NAME; -import static org.apache.dubbo.common.Constants.BACKUP_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY; import static org.apache.dubbo.common.Constants.CONFIG_NAMESPACE_KEY; import static org.apache.dubbo.common.Constants.GROUP_CHAR_SEPERATOR; import static org.apache.dubbo.common.Constants.PROPERTIES_CHAR_SEPERATOR; diff --git a/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/integration/MetadataReportService.java b/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/integration/MetadataReportService.java index f2428f9fe9e..832dac62fe8 100644 --- a/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/integration/MetadataReportService.java +++ b/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/integration/MetadataReportService.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URLBuilder; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; @@ -78,7 +79,7 @@ public static MetadataReportService instance(Supplier metadataReportUrl) { public void publishProvider(URL providerUrl) throws RpcException { //first add into the list // remove the individul param - providerUrl = providerUrl.removeParameters(Constants.PID_KEY, Constants.TIMESTAMP_KEY, Constants.BIND_IP_KEY, Constants.BIND_PORT_KEY, Constants.TIMESTAMP_KEY); + providerUrl = providerUrl.removeParameters(Constants.PID_KEY, Constants.TIMESTAMP_KEY, RemotingConstants.BIND_IP_KEY, RemotingConstants.BIND_PORT_KEY, Constants.TIMESTAMP_KEY); try { String interfaceName = providerUrl.getParameter(Constants.INTERFACE_KEY); @@ -98,7 +99,7 @@ public void publishProvider(URL providerUrl) throws RpcException { } public void publishConsumer(URL consumerURL) throws RpcException { - consumerURL = consumerURL.removeParameters(Constants.PID_KEY, Constants.TIMESTAMP_KEY, Constants.BIND_IP_KEY, Constants.BIND_PORT_KEY, Constants.TIMESTAMP_KEY); + consumerURL = consumerURL.removeParameters(Constants.PID_KEY, Constants.TIMESTAMP_KEY, RemotingConstants.BIND_IP_KEY, RemotingConstants.BIND_PORT_KEY, Constants.TIMESTAMP_KEY); metadataReport.storeConsumerMetadata(new MetadataIdentifier(consumerURL.getServiceInterface(), consumerURL.getParameter(Constants.VERSION_KEY), consumerURL.getParameter(Constants.GROUP_KEY),Constants.CONSUMER_SIDE, consumerURL.getParameter(Constants.APPLICATION_KEY)), consumerURL.getParameters()); diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactory.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactory.java index 2c80bc4e5b5..5d73112bfd4 100644 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactory.java +++ b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitorFactory.java @@ -26,7 +26,7 @@ import org.apache.dubbo.rpc.Protocol; import org.apache.dubbo.rpc.ProxyFactory; -import static org.apache.dubbo.common.Constants.CHECK_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.CHECK_KEY; import static org.apache.dubbo.common.Constants.DUBBO_PROTOCOL; import static org.apache.dubbo.common.Constants.PROTOCOL_KEY; import static org.apache.dubbo.common.Constants.REFERENCE_FILTER_KEY; diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java index 90544aaf8a1..a05c510de71 100644 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java +++ b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java @@ -28,6 +28,7 @@ import com.alibaba.metrics.common.MetricsCollectorFactory; import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; @@ -165,7 +166,7 @@ private void setCompassQuantity(String groupName, String result, long duration, private List getThreadPoolMessage() { DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); - Map executors = dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY); + Map executors = dataStore.get(RemotingConstants.EXECUTOR_SERVICE_COMPONENT_KEY); List threadPoolMtricList = new ArrayList<>(); for (Map.Entry entry : executors.entrySet()) { diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java index 54bb0068a3e..9538742ede1 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URLBuilder; import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; @@ -432,7 +433,7 @@ private URL mergeUrl(URL providerUrl) { providerUrl = overrideWithConfigurator(providerUrl); - providerUrl = providerUrl.addParameter(Constants.CHECK_KEY, String.valueOf(false)); // Do not check whether the connection is successful or not, always create Invoker! + providerUrl = providerUrl.addParameter(RemotingConstants.CHECK_KEY, String.valueOf(false)); // Do not check whether the connection is successful or not, always create Invoker! // The combination of directoryUrl and override is at the end of notify, which can't be handled here this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // Merge the provider side parameters 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 6c5870bd47e..b1b3393b1cf 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 @@ -55,10 +55,10 @@ import static java.util.concurrent.Executors.newSingleThreadExecutor; import static org.apache.dubbo.common.Constants.ACCEPT_FOREIGN_IP; import static org.apache.dubbo.common.Constants.ANY_VALUE; -import static org.apache.dubbo.common.Constants.BIND_IP_KEY; -import static org.apache.dubbo.common.Constants.BIND_PORT_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.BIND_IP_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.BIND_PORT_KEY; import static org.apache.dubbo.common.Constants.CATEGORY_KEY; -import static org.apache.dubbo.common.Constants.CHECK_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.CHECK_KEY; import static org.apache.dubbo.common.Constants.COMMA_SPLIT_PATTERN; import static org.apache.dubbo.common.Constants.CONFIGURATORS_CATEGORY; import static org.apache.dubbo.common.Constants.CONFIGURATORS_SUFFIX; diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java index cbf1527231f..1132ad8b60f 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.timer.HashedWheelTimer; import org.apache.dubbo.common.utils.CollectionUtils; import org.apache.dubbo.common.utils.NamedThreadFactory; @@ -233,8 +234,8 @@ public void register(URL url) { Throwable t = e; // If the startup detection is opened, the Exception is thrown directly. - boolean check = getUrl().getParameter(Constants.CHECK_KEY, true) - && url.getParameter(Constants.CHECK_KEY, true) + boolean check = getUrl().getParameter(RemotingConstants.CHECK_KEY, true) + && url.getParameter(RemotingConstants.CHECK_KEY, true) && !Constants.CONSUMER_PROTOCOL.equals(url.getProtocol()); boolean skipFailback = t instanceof SkipFailbackWrapperException; if (check || skipFailback) { @@ -263,8 +264,8 @@ public void unregister(URL url) { Throwable t = e; // If the startup detection is opened, the Exception is thrown directly. - boolean check = getUrl().getParameter(Constants.CHECK_KEY, true) - && url.getParameter(Constants.CHECK_KEY, true) + boolean check = getUrl().getParameter(RemotingConstants.CHECK_KEY, true) + && url.getParameter(RemotingConstants.CHECK_KEY, true) && !Constants.CONSUMER_PROTOCOL.equals(url.getProtocol()); boolean skipFailback = t instanceof SkipFailbackWrapperException; if (check || skipFailback) { @@ -297,8 +298,8 @@ public void subscribe(URL url, NotifyListener listener) { logger.error("Failed to subscribe " + url + ", Using cached list: " + urls + " from cache file: " + getUrl().getParameter(Constants.FILE_KEY, System.getProperty("user.home") + "/dubbo-registry-" + url.getHost() + ".cache") + ", cause: " + t.getMessage(), t); } else { // If the startup detection is opened, the Exception is thrown directly. - boolean check = getUrl().getParameter(Constants.CHECK_KEY, true) - && url.getParameter(Constants.CHECK_KEY, true); + boolean check = getUrl().getParameter(RemotingConstants.CHECK_KEY, true) + && url.getParameter(RemotingConstants.CHECK_KEY, true); boolean skipFailback = t instanceof SkipFailbackWrapperException; if (check || skipFailback) { if (skipFailback) { @@ -326,8 +327,8 @@ public void unsubscribe(URL url, NotifyListener listener) { Throwable t = e; // If the startup detection is opened, the Exception is thrown directly. - boolean check = getUrl().getParameter(Constants.CHECK_KEY, true) - && url.getParameter(Constants.CHECK_KEY, true); + boolean check = getUrl().getParameter(RemotingConstants.CHECK_KEY, true) + && url.getParameter(RemotingConstants.CHECK_KEY, true); boolean skipFailback = t instanceof SkipFailbackWrapperException; if (check || skipFailback) { if (skipFailback) { diff --git a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java index c936d2979be..05c785a7e23 100644 --- a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java +++ b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistry.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.ExecutorUtil; @@ -100,7 +101,7 @@ protected final void connect() { clientLock.unlock(); } } catch (Throwable t) { // Ignore all the exceptions and wait for the next retry - if (getUrl().getParameter(Constants.CHECK_KEY, true)) { + if (getUrl().getParameter(RemotingConstants.CHECK_KEY, true)) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } diff --git a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistryFactory.java b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistryFactory.java index ee331c83186..c199774b391 100644 --- a/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-default/src/main/java/org/apache/dubbo/registry/dubbo/DubboRegistryFactory.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URLBuilder; import org.apache.dubbo.common.bytecode.Wrapper; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.registry.Registry; @@ -54,10 +55,10 @@ private static URL getRegistryURL(URL url) { .addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()) .addParameter(Constants.CLUSTER_STICKY_KEY, "true") .addParameter(Constants.LAZY_CONNECT_KEY, "true") - .addParameter(Constants.RECONNECT_KEY, "false") + .addParameter(RemotingConstants.RECONNECT_KEY, "false") .addParameterIfAbsent(Constants.TIMEOUT_KEY, "10000") .addParameterIfAbsent(Constants.CALLBACK_INSTANCES_LIMIT_KEY, "10000") - .addParameterIfAbsent(Constants.CONNECT_TIMEOUT_KEY, "10000") + .addParameterIfAbsent(RemotingConstants.CONNECT_TIMEOUT_KEY, "10000") .addParameter(Constants.METHODS_KEY, StringUtils.join(new HashSet<>(Arrays.asList(Wrapper.getWrapper(RegistryService.class).getDeclaredMethodNames())), ",")) //.addParameter(Constants.STUB_KEY, RegistryServiceStub.class.getName()) //.addParameter(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString()) //for event dispatch @@ -83,8 +84,8 @@ public void setCluster(Cluster cluster) { public Registry createRegistry(URL url) { url = getRegistryURL(url); List urls = new ArrayList<>(); - urls.add(url.removeParameter(Constants.BACKUP_KEY)); - String backup = url.getParameter(Constants.BACKUP_KEY); + urls.add(url.removeParameter(RemotingConstants.BACKUP_KEY)); + String backup = url.getParameter(RemotingConstants.BACKUP_KEY); if (backup != null && backup.length() > 0) { String[] addresses = Constants.COMMA_SPLIT_PATTERN.split(backup); for (String address : addresses) { diff --git a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/DubboRegistryTest.java b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/DubboRegistryTest.java index 3a317785a09..336383f5c99 100644 --- a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/DubboRegistryTest.java +++ b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/DubboRegistryTest.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.NetUtils; @@ -55,10 +56,10 @@ public class DubboRegistryTest { @BeforeEach public void setUp() { registryURL = new URL(Constants.REGISTRY_PROTOCOL, NetUtils.getLocalHost(), NetUtils.getAvailablePort()) - .addParameter(Constants.CHECK_KEY, false) + .addParameter(RemotingConstants.CHECK_KEY, false) .setServiceInterface(RegistryService.class.getName()); serviceURL = new URL(DubboProtocol.NAME, NetUtils.getLocalHost(), NetUtils.getAvailablePort()) - .addParameter(Constants.CHECK_KEY, false) + .addParameter(RemotingConstants.CHECK_KEY, false) .setServiceInterface(RegistryService.class.getName()); registryService = new MockDubboRegistry(registryURL); diff --git a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java index 7d672097596..e6911fd8347 100644 --- a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java +++ b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.utils.LogUtil; import org.apache.dubbo.common.utils.NetUtils; @@ -371,7 +372,7 @@ public void testParametersMerge() { Invoker invoker = (Invoker) invokers.get(0); URL url = invoker.getUrl(); - Assertions.assertEquals(false, url.getParameter(Constants.CHECK_KEY, false)); + Assertions.assertEquals(false, url.getParameter(RemotingConstants.CHECK_KEY, false)); } { serviceUrls.clear(); diff --git a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdRegistry.java b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdRegistry.java index f0516c37989..1f70044c164 100644 --- a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdRegistry.java +++ b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdRegistry.java @@ -34,6 +34,7 @@ package org.apache.dubbo.registry.etcd; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.ConcurrentHashSet; @@ -179,7 +180,7 @@ public void doSubscribe(URL url, NotifyListener listener) { * eg: /dubbo/interface, /dubbo/interface and so on. */ subscribe(url.setPath(child).addParameters(Constants.INTERFACE_KEY, child, - Constants.CHECK_KEY, String.valueOf(false)), listener); + RemotingConstants.CHECK_KEY, String.valueOf(false)), listener); } } }); @@ -196,7 +197,7 @@ public void doSubscribe(URL url, NotifyListener listener) { service = URL.decode(service); anyServices.add(service); subscribe(url.setPath(service).addParameters(Constants.INTERFACE_KEY, service, - Constants.CHECK_KEY, String.valueOf(false)), listener); + RemotingConstants.CHECK_KEY, String.valueOf(false)), listener); } } else { List urls = new ArrayList<>(); diff --git a/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java b/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java index c23c1d23a0a..7de75411791 100644 --- a/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java +++ b/dubbo-registry/dubbo-registry-etcd3/src/test/java/org/apache/dubbo/registry/etcd/EtcdRegistryTest.java @@ -52,6 +52,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.registry.NotifyListener; @@ -95,7 +96,7 @@ public class EtcdRegistryTest { + Constants.ROUTERS_CATEGORY + "," + Constants.CONFIGURATORS_CATEGORY, Constants.ENABLED_KEY, Constants.ANY_VALUE, - Constants.CHECK_KEY, String.valueOf(false)); + RemotingConstants.CHECK_KEY, String.valueOf(false)); @Test public void test_register() { diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java index 52dcd112be6..d0e508d4533 100644 --- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java @@ -37,7 +37,7 @@ import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY; import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR; import static com.alibaba.nacos.client.naming.utils.UtilAndComs.NACOS_NAMING_LOG_NAME; -import static org.apache.dubbo.common.Constants.BACKUP_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY; /** * Nacos {@link RegistryFactory} diff --git a/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java b/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java index b693842eb91..5303ddc495a 100644 --- a/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java +++ b/dubbo-registry/dubbo-registry-redis/src/main/java/org/apache/dubbo/registry/redis/RedisRegistry.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URLBuilder; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.ArrayUtils; @@ -125,7 +126,7 @@ public RedisRegistry(URL url) { List addresses = new ArrayList<>(); addresses.add(url.getAddress()); - String[] backups = url.getParameter(Constants.BACKUP_KEY, new String[0]); + String[] backups = url.getParameter(RemotingConstants.BACKUP_KEY, new String[0]); if (ArrayUtils.isNotEmpty(backups)) { addresses.addAll(Arrays.asList(backups)); } diff --git a/dubbo-registry/dubbo-registry-redis/src/test/java/org/apache/dubbo/registry/redis/RedisRegistryTest.java b/dubbo-registry/dubbo-registry-redis/src/test/java/org/apache/dubbo/registry/redis/RedisRegistryTest.java index 44650cef722..0cc1c3126a3 100644 --- a/dubbo-registry/dubbo-registry-redis/src/test/java/org/apache/dubbo/registry/redis/RedisRegistryTest.java +++ b/dubbo-registry/dubbo-registry-redis/src/test/java/org/apache/dubbo/registry/redis/RedisRegistryTest.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.Set; -import static org.apache.dubbo.common.Constants.BACKUP_KEY; +import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java index 1c3eb27e982..102d5881af2 100644 --- a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java +++ b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URLBuilder; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.CollectionUtils; @@ -131,7 +132,7 @@ public void doSubscribe(final URL url, final NotifyListener listener) { if (!anyServices.contains(child)) { anyServices.add(child); subscribe(url.setPath(child).addParameters(Constants.INTERFACE_KEY, child, - Constants.CHECK_KEY, String.valueOf(false)), listener); + RemotingConstants.CHECK_KEY, String.valueOf(false)), listener); } } }); @@ -144,7 +145,7 @@ public void doSubscribe(final URL url, final NotifyListener listener) { service = URL.decode(service); anyServices.add(service); subscribe(url.setPath(service).addParameters(Constants.INTERFACE_KEY, service, - Constants.CHECK_KEY, String.valueOf(false)), listener); + RemotingConstants.CHECK_KEY, String.valueOf(false)), listener); } } } else { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Codec.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Codec.java index ed2261d6126..d40d4a27215 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Codec.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Codec.java @@ -16,7 +16,7 @@ */ package org.apache.dubbo.remoting; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Adaptive; import org.apache.dubbo.common.extension.SPI; @@ -45,7 +45,7 @@ public interface Codec { * @param output output stream. * @param message message. */ - @Adaptive({Constants.CODEC_KEY}) + @Adaptive({RemotingConstants.CODEC_KEY}) void encode(Channel channel, OutputStream output, Object message) throws IOException; /** @@ -56,7 +56,7 @@ public interface Codec { * @return message or NEED_MORE_INPUT poison. * @see #NEED_MORE_INPUT */ - @Adaptive({Constants.CODEC_KEY}) + @Adaptive({RemotingConstants.CODEC_KEY}) Object decode(Channel channel, InputStream input) throws IOException; } \ No newline at end of file diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Codec2.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Codec2.java index 2adfe477efb..7d6770b5fb5 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Codec2.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Codec2.java @@ -16,7 +16,7 @@ */ package org.apache.dubbo.remoting; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Adaptive; import org.apache.dubbo.common.extension.SPI; import org.apache.dubbo.remoting.buffer.ChannelBuffer; @@ -26,10 +26,10 @@ @SPI public interface Codec2 { - @Adaptive({Constants.CODEC_KEY}) + @Adaptive({RemotingConstants.CODEC_KEY}) void encode(Channel channel, ChannelBuffer buffer, Object message) throws IOException; - @Adaptive({Constants.CODEC_KEY}) + @Adaptive({RemotingConstants.CODEC_KEY}) Object decode(Channel channel, ChannelBuffer buffer) throws IOException; diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Dispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Dispatcher.java index 2fd3133a5dc..201b0979c35 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Dispatcher.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Dispatcher.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Adaptive; import org.apache.dubbo.common.extension.SPI; import org.apache.dubbo.remoting.transport.dispatcher.all.AllDispatcher; @@ -35,7 +35,7 @@ public interface Dispatcher { * @param url * @return channel handler */ - @Adaptive({Constants.DISPATCHER_KEY, "dispather", "channel.handler"}) + @Adaptive({RemotingConstants.DISPATCHER_KEY, "dispather", "channel.handler"}) // The last two parameters are reserved for compatibility with the old configuration ChannelHandler dispatch(ChannelHandler handler, URL url); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Transporter.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Transporter.java index 33ac2bedd3f..6493ac51056 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Transporter.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Transporter.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Adaptive; import org.apache.dubbo.common.extension.SPI; @@ -41,7 +41,7 @@ public interface Transporter { * @throws RemotingException * @see org.apache.dubbo.remoting.Transporters#bind(URL, ChannelHandler...) */ - @Adaptive({Constants.SERVER_KEY, Constants.TRANSPORTER_KEY}) + @Adaptive({RemotingConstants.SERVER_KEY, RemotingConstants.TRANSPORTER_KEY}) Server bind(URL url, ChannelHandler handler) throws RemotingException; /** @@ -53,7 +53,7 @@ public interface Transporter { * @throws RemotingException * @see org.apache.dubbo.remoting.Transporters#connect(URL, ChannelHandler...) */ - @Adaptive({Constants.CLIENT_KEY, Constants.TRANSPORTER_KEY}) + @Adaptive({RemotingConstants.CLIENT_KEY, RemotingConstants.TRANSPORTER_KEY}) Client connect(URL url, ChannelHandler handler) throws RemotingException; } \ No newline at end of file diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Exchanger.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Exchanger.java index 6f1ef5e6288..8c46273fff0 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Exchanger.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Exchanger.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.exchange; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Adaptive; import org.apache.dubbo.common.extension.SPI; import org.apache.dubbo.remoting.RemotingException; @@ -39,7 +39,7 @@ public interface Exchanger { * @param handler * @return message server */ - @Adaptive({Constants.EXCHANGER_KEY}) + @Adaptive({RemotingConstants.EXCHANGER_KEY}) ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException; /** @@ -49,7 +49,7 @@ public interface Exchanger { * @param handler * @return message channel */ - @Adaptive({Constants.EXCHANGER_KEY}) + @Adaptive({RemotingConstants.EXCHANGER_KEY}) ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException; } \ No newline at end of file diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Exchangers.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Exchangers.java index 073e18c7c0c..c3fc864b514 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Exchangers.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Exchangers.java @@ -16,9 +16,9 @@ */ package org.apache.dubbo.remoting.exchange; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.remoting.ChannelHandler; import org.apache.dubbo.remoting.RemotingException; @@ -66,7 +66,7 @@ public static ExchangeServer bind(URL url, ExchangeHandler handler) throws Remot if (handler == null) { throw new IllegalArgumentException("handler == null"); } - url = url.addParameterIfAbsent(Constants.CODEC_KEY, "exchange"); + url = url.addParameterIfAbsent(RemotingConstants.CODEC_KEY, "exchange"); return getExchanger(url).bind(url, handler); } @@ -105,12 +105,12 @@ public static ExchangeClient connect(URL url, ExchangeHandler handler) throws Re if (handler == null) { throw new IllegalArgumentException("handler == null"); } - url = url.addParameterIfAbsent(Constants.CODEC_KEY, "exchange"); + url = url.addParameterIfAbsent(RemotingConstants.CODEC_KEY, "exchange"); return getExchanger(url).connect(url, handler); } public static Exchanger getExchanger(URL url) { - String type = url.getParameter(Constants.EXCHANGER_KEY, Constants.DEFAULT_EXCHANGER); + String type = url.getParameter(RemotingConstants.EXCHANGER_KEY, RemotingConstants.DEFAULT_EXCHANGER); return getExchanger(type); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java index 3e57fba90c4..944daac3079 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.exchange.support.header; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.timer.HashedWheelTimer; import org.apache.dubbo.common.utils.Assert; import org.apache.dubbo.common.utils.NamedThreadFactory; @@ -45,7 +45,7 @@ public class HeaderExchangeClient implements ExchangeClient { private final ExchangeChannel channel; private static final HashedWheelTimer IDLE_CHECK_TIMER = new HashedWheelTimer( - new NamedThreadFactory("dubbo-client-idleCheck", true), 1, TimeUnit.SECONDS, Constants.TICKS_PER_WHEEL); + new NamedThreadFactory("dubbo-client-idleCheck", true), 1, TimeUnit.SECONDS, RemotingConstants.TICKS_PER_WHEEL); private HeartbeatTimerTask heartBeatTimerTask; private ReconnectTimerTask reconnectTimerTask; @@ -206,15 +206,15 @@ private void doClose() { * Each interval cannot be less than 1000ms. */ private long calculateLeastDuration(int time) { - if (time / Constants.HEARTBEAT_CHECK_TICK <= 0) { - return Constants.LEAST_HEARTBEAT_DURATION; + if (time / RemotingConstants.HEARTBEAT_CHECK_TICK <= 0) { + return RemotingConstants.LEAST_HEARTBEAT_DURATION; } else { - return time / Constants.HEARTBEAT_CHECK_TICK; + return time / RemotingConstants.HEARTBEAT_CHECK_TICK; } } private boolean shouldReconnect(URL url) { - return url.getParameter(Constants.RECONNECT_KEY, true); + return url.getParameter(RemotingConstants.RECONNECT_KEY, true); } @Override diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java index 6f342f997c0..0b19d6afe31 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeHandler.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.exchange.support.header; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.NetUtils; @@ -73,7 +73,7 @@ private static boolean isClientSide(Channel channel) { void handlerEvent(Channel channel, Request req) throws RemotingException { if (req.getData() != null && req.getData().equals(Request.READONLY_EVENT)) { - channel.setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); + channel.setAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); } } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java index 8a74e234134..be52d6d601e 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java @@ -16,9 +16,9 @@ */ package org.apache.dubbo.remoting.exchange.support.header; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.timer.HashedWheelTimer; @@ -53,7 +53,7 @@ public class HeaderExchangeServer implements ExchangeServer { private AtomicBoolean closed = new AtomicBoolean(false); private static final HashedWheelTimer IDLE_CHECK_TIMER = new HashedWheelTimer(new NamedThreadFactory("dubbo-server-idleCheck", true), 1, - TimeUnit.SECONDS, Constants.TICKS_PER_WHEEL); + TimeUnit.SECONDS, RemotingConstants.TICKS_PER_WHEEL); private CloseTimerTask closeTimerTask; @@ -100,7 +100,7 @@ public void close(final int timeout) { if (timeout > 0) { final long max = (long) timeout; final long start = System.currentTimeMillis(); - if (getUrl().getParameter(Constants.CHANNEL_SEND_READONLYEVENT_KEY, true)) { + if (getUrl().getParameter(RemotingConstants.CHANNEL_SEND_READONLYEVENT_KEY, true)) { sendChannelReadOnlyEvent(); } while (HeaderExchangeServer.this.isRunning() @@ -131,7 +131,7 @@ private void sendChannelReadOnlyEvent() { for (Channel channel : channels) { try { if (channel.isConnected()) { - channel.send(request, getUrl().getParameter(Constants.CHANNEL_READONLYEVENT_SENT_KEY, true)); + channel.send(request, getUrl().getParameter(RemotingConstants.CHANNEL_READONLYEVENT_SENT_KEY, true)); } } catch (RemotingException e) { logger.warn("send cannot write message error.", e); @@ -246,10 +246,10 @@ public void send(Object message, boolean sent) throws RemotingException { * Each interval cannot be less than 1000ms. */ private long calculateLeastDuration(int time) { - if (time / Constants.HEARTBEAT_CHECK_TICK <= 0) { - return Constants.LEAST_HEARTBEAT_DURATION; + if (time / RemotingConstants.HEARTBEAT_CHECK_TICK <= 0) { + return RemotingConstants.LEAST_HEARTBEAT_DURATION; } else { - return time / Constants.HEARTBEAT_CHECK_TICK; + return time / RemotingConstants.HEARTBEAT_CHECK_TICK; } } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeartbeatHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeartbeatHandler.java index 71068714368..87d912187ea 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeartbeatHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeartbeatHandler.java @@ -17,7 +17,7 @@ package org.apache.dubbo.remoting.exchange.support.header; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.Channel; @@ -69,7 +69,7 @@ public void received(Channel channel, Object message) throws RemotingException { res.setEvent(Response.HEARTBEAT_EVENT); channel.send(res); if (logger.isInfoEnabled()) { - int heartbeat = channel.getUrl().getParameter(Constants.HEARTBEAT_KEY, 0); + int heartbeat = channel.getUrl().getParameter(RemotingConstants.HEARTBEAT_KEY, 0); if (logger.isDebugEnabled()) { logger.debug("Received heartbeat from remote channel " + channel.getRemoteAddress() + ", cause: The channel has no data-transmission exceeds a heartbeat period" diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/codec/TelnetCodec.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/codec/TelnetCodec.java index ce481fc8519..b34ee153692 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/codec/TelnetCodec.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/codec/TelnetCodec.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.telnet.codec; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.CollectionUtils; @@ -60,7 +60,7 @@ public class TelnetCodec extends TransportCodec { private static Charset getCharset(Channel channel) { if (channel != null) { - Object attribute = channel.getAttribute(Constants.CHARSET_KEY); + Object attribute = channel.getAttribute(RemotingConstants.CHARSET_KEY); if (attribute instanceof String) { try { return Charset.forName((String) attribute); @@ -72,7 +72,7 @@ private static Charset getCharset(Channel channel) { } URL url = channel.getUrl(); if (url != null) { - String parameter = url.getParameter(Constants.CHARSET_KEY); + String parameter = url.getParameter(RemotingConstants.CHARSET_KEY); if (StringUtils.isNotEmpty(parameter)) { try { return Charset.forName(parameter); @@ -83,7 +83,7 @@ private static Charset getCharset(Channel channel) { } } try { - return Charset.forName(Constants.DEFAULT_CHARSET); + return Charset.forName(RemotingConstants.DEFAULT_CHARSET); } catch (Throwable t) { logger.warn(t.getMessage(), t); } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java index 66418f3b573..89a781c5bef 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/TelnetHandlerAdapter.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.remoting.Channel; @@ -31,7 +32,7 @@ public class TelnetHandlerAdapter extends ChannelHandlerAdapter implements Telne @Override public String telnet(Channel channel, String message) throws RemotingException { - String prompt = channel.getUrl().getParameterAndDecoded(Constants.PROMPT_KEY, Constants.DEFAULT_PROMPT); + String prompt = channel.getUrl().getParameterAndDecoded(RemotingConstants.PROMPT_KEY, RemotingConstants.DEFAULT_PROMPT); boolean noprompt = message.contains("--no-prompt"); message = message.replace("--no-prompt", ""); StringBuilder buf = new StringBuilder(); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java index dd02651e018..aa10dd819f5 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; @@ -50,7 +51,7 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client public AbstractClient(URL url, ChannelHandler handler) throws RemotingException { super(url, handler); - needReconnect = url.getParameter(Constants.SEND_RECONNECT_KEY, false); + needReconnect = url.getParameter(RemotingConstants.SEND_RECONNECT_KEY, false); try { doOpen(); @@ -67,7 +68,7 @@ public AbstractClient(URL url, ChannelHandler handler) throws RemotingException logger.info("Start " + getClass().getSimpleName() + " " + NetUtils.getLocalAddress() + " connect to the server " + getRemoteAddress()); } } catch (RemotingException t) { - if (url.getParameter(Constants.CHECK_KEY, true)) { + if (url.getParameter(RemotingConstants.CHECK_KEY, true)) { close(); throw t; } else { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractCodec.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractCodec.java index 5269d2c571c..346f54ca320 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractCodec.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractCodec.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.serialize.Serialization; @@ -36,9 +37,9 @@ public abstract class AbstractCodec implements Codec2 { private static final Logger logger = LoggerFactory.getLogger(AbstractCodec.class); protected static void checkPayload(Channel channel, long size) throws IOException { - int payload = Constants.DEFAULT_PAYLOAD; + int payload = RemotingConstants.DEFAULT_PAYLOAD; if (channel != null && channel.getUrl() != null) { - payload = channel.getUrl().getParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD); + payload = channel.getUrl().getParameter(RemotingConstants.PAYLOAD_KEY, RemotingConstants.DEFAULT_PAYLOAD); } if (payload > 0 && size > payload) { ExceedPayloadLimitException e = new ExceedPayloadLimitException("Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java index 94b6be287b0..0a438bf7491 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.Resetable; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; @@ -44,11 +45,11 @@ public AbstractEndpoint(URL url, ChannelHandler handler) { super(url, handler); this.codec = getChannelCodec(url); this.timeout = url.getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); - this.connectTimeout = url.getPositiveParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT); + this.connectTimeout = url.getPositiveParameter(RemotingConstants.CONNECT_TIMEOUT_KEY, RemotingConstants.DEFAULT_CONNECT_TIMEOUT); } protected static Codec2 getChannelCodec(URL url) { - String codecName = url.getParameter(Constants.CODEC_KEY, "telnet"); + String codecName = url.getParameter(RemotingConstants.CODEC_KEY, "telnet"); if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) { return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName); } else { @@ -74,8 +75,8 @@ public void reset(URL url) { logger.error(t.getMessage(), t); } try { - if (url.hasParameter(Constants.CONNECT_TIMEOUT_KEY)) { - int t = url.getParameter(Constants.CONNECT_TIMEOUT_KEY, 0); + if (url.hasParameter(RemotingConstants.CONNECT_TIMEOUT_KEY)) { + int t = url.getParameter(RemotingConstants.CONNECT_TIMEOUT_KEY, 0); if (t > 0) { this.connectTimeout = t; } @@ -84,7 +85,7 @@ public void reset(URL url) { logger.error(t.getMessage(), t); } try { - if (url.hasParameter(Constants.CODEC_KEY)) { + if (url.hasParameter(RemotingConstants.CODEC_KEY)) { this.codec = getChannelCodec(url); } } catch (Throwable t) { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractPeer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractPeer.java index 18f235b9b63..2ec6fc603d0 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractPeer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractPeer.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.transport; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.ChannelHandler; import org.apache.dubbo.remoting.Endpoint; @@ -50,7 +50,7 @@ public AbstractPeer(URL url, ChannelHandler handler) { @Override public void send(Object message) throws RemotingException { - send(message, url.getParameter(Constants.SENT_KEY, false)); + send(message, url.getParameter(RemotingConstants.SENT_KEY, false)); } @Override diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java index 2020fee79fb..0af47a63c3e 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; @@ -51,14 +52,14 @@ public AbstractServer(URL url, ChannelHandler handler) throws RemotingException super(url, handler); localAddress = getUrl().toInetSocketAddress(); - String bindIp = getUrl().getParameter(Constants.BIND_IP_KEY, getUrl().getHost()); - int bindPort = getUrl().getParameter(Constants.BIND_PORT_KEY, getUrl().getPort()); + String bindIp = getUrl().getParameter(RemotingConstants.BIND_IP_KEY, getUrl().getHost()); + int bindPort = getUrl().getParameter(RemotingConstants.BIND_PORT_KEY, getUrl().getPort()); if (url.getParameter(Constants.ANYHOST_KEY, false) || NetUtils.isInvalidLocalHost(bindIp)) { bindIp = Constants.ANYHOST_VALUE; } bindAddress = new InetSocketAddress(bindIp, bindPort); - this.accepts = url.getParameter(Constants.ACCEPTS_KEY, Constants.DEFAULT_ACCEPTS); - this.idleTimeout = url.getParameter(Constants.IDLE_TIMEOUT_KEY, Constants.DEFAULT_IDLE_TIMEOUT); + this.accepts = url.getParameter(RemotingConstants.ACCEPTS_KEY, RemotingConstants.DEFAULT_ACCEPTS); + this.idleTimeout = url.getParameter(RemotingConstants.IDLE_TIMEOUT_KEY, RemotingConstants.DEFAULT_IDLE_TIMEOUT); try { doOpen(); if (logger.isInfoEnabled()) { @@ -70,7 +71,7 @@ public AbstractServer(URL url, ChannelHandler handler) throws RemotingException } //fixme replace this with better method DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); - executor = (ExecutorService) dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY, Integer.toString(url.getPort())); + executor = (ExecutorService) dataStore.get(RemotingConstants.EXECUTOR_SERVICE_COMPONENT_KEY, Integer.toString(url.getPort())); } protected abstract void doOpen() throws Throwable; @@ -83,8 +84,8 @@ public void reset(URL url) { return; } try { - if (url.hasParameter(Constants.ACCEPTS_KEY)) { - int a = url.getParameter(Constants.ACCEPTS_KEY, 0); + if (url.hasParameter(RemotingConstants.ACCEPTS_KEY)) { + int a = url.getParameter(RemotingConstants.ACCEPTS_KEY, 0); if (a > 0) { this.accepts = a; } @@ -93,8 +94,8 @@ public void reset(URL url) { logger.error(t.getMessage(), t); } try { - if (url.hasParameter(Constants.IDLE_TIMEOUT_KEY)) { - int t = url.getParameter(Constants.IDLE_TIMEOUT_KEY, 0); + if (url.hasParameter(RemotingConstants.IDLE_TIMEOUT_KEY)) { + int t = url.getParameter(RemotingConstants.IDLE_TIMEOUT_KEY, 0); if (t > 0) { this.idleTimeout = t; } 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 ca48dcaf1e0..cfa6c604e0f 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 @@ -17,8 +17,8 @@ package org.apache.dubbo.remoting.transport; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; @@ -67,12 +67,12 @@ public static Serialization getSerializationById(Byte id) { public static Serialization getSerialization(URL url) { return ExtensionLoader.getExtensionLoader(Serialization.class).getExtension( - url.getParameter(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION)); + url.getParameter(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION)); } public static Serialization getSerialization(URL url, Byte id) throws IOException { Serialization serialization = getSerializationById(id); - String serializationName = url.getParameter(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION); + String serializationName = url.getParameter(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.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 == JAVA_SERIALIZATION_ID || id == NATIVE_JAVA_SERIALIZATION_ID || id == COMPACTED_JAVA_SERIALIZATION_ID) diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/WrappedChannelHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/WrappedChannelHandler.java index 072f998e068..f545a413d3f 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/WrappedChannelHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/WrappedChannelHandler.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; @@ -49,7 +50,7 @@ public WrappedChannelHandler(ChannelHandler handler, URL url) { this.url = url; executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url); - String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY; + String componentKey = RemotingConstants.EXECUTOR_SERVICE_COMPONENT_KEY; if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) { componentKey = Constants.CONSUMER_SIDE; } diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java index d6aff15a4a1..79465e68679 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport; import org.apache.dubbo.common.utils.NamedThreadFactory; import org.apache.dubbo.remoting.Channel; @@ -46,11 +47,11 @@ public ConnectionOrderedChannelHandler(ChannelHandler handler, URL url) { String threadName = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME); connectionExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(url.getPositiveParameter(Constants.CONNECT_QUEUE_CAPACITY, Integer.MAX_VALUE)), + new LinkedBlockingQueue(url.getPositiveParameter(RemotingConstants.CONNECT_QUEUE_CAPACITY, Integer.MAX_VALUE)), new NamedThreadFactory(threadName, true), new AbortPolicyWithReport(threadName, url) ); // FIXME There's no place to release connectionExecutor! - queuewarninglimit = url.getParameter(Constants.CONNECT_QUEUE_WARNING_SIZE, Constants.DEFAULT_CONNECT_QUEUE_WARNING_SIZE); + queuewarninglimit = url.getParameter(RemotingConstants.CONNECT_QUEUE_WARNING_SIZE, RemotingConstants.DEFAULT_CONNECT_QUEUE_WARNING_SIZE); } @Override diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/ChanelHandlerTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/ChanelHandlerTest.java index 7f226554383..2d87e54ed1b 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/ChanelHandlerTest.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/ChanelHandlerTest.java @@ -17,6 +17,7 @@ package org.apache.dubbo.remoting; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.exchange.ExchangeClient; @@ -79,8 +80,8 @@ public void testClient() throws Throwable { return; } final String server = System.getProperty("server", "127.0.0.1:9911"); - final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER); - final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION); + final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER); + final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION); final int timeout = PerformanceUtils.getIntProperty(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); int sleep = PerformanceUtils.getIntProperty("sleep", 60 * 1000 * 60); diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientCloseTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientCloseTest.java index cb6b99f51f9..d92648ac7d8 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientCloseTest.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientCloseTest.java @@ -17,6 +17,7 @@ package org.apache.dubbo.remoting; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.exchange.ExchangeClient; @@ -43,8 +44,8 @@ public void testClient() throws Throwable { return; } final String server = System.getProperty("server", "127.0.0.1:9911"); - final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER); - final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION); + final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER); + final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION); final int timeout = PerformanceUtils.getIntProperty(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); final int concurrent = PerformanceUtils.getIntProperty("concurrent", 1); final int runs = PerformanceUtils.getIntProperty("runs", Integer.MAX_VALUE); diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientFixedTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientFixedTest.java index 24009e83768..ae2aecc77be 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientFixedTest.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientFixedTest.java @@ -17,6 +17,7 @@ package org.apache.dubbo.remoting; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.exchange.ExchangeClient; @@ -40,8 +41,8 @@ public void testClient() throws Exception { return; } final String server = System.getProperty("server", "127.0.0.1:9911"); - final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER); - final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION); + final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER); + final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION); final int timeout = PerformanceUtils.getIntProperty(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); //final int length = PerformanceUtils.getIntProperty("length", 1024); final int connectionCount = PerformanceUtils.getIntProperty(Constants.CONNECTIONS_KEY, 1); diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientTest.java index e3e2347a9ee..43570b6c5a7 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientTest.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceClientTest.java @@ -17,13 +17,13 @@ package org.apache.dubbo.remoting; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.exchange.ExchangeClient; import org.apache.dubbo.remoting.exchange.Exchangers; import org.apache.dubbo.remoting.exchange.support.ExchangeHandlerAdapter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.text.DecimalFormat; @@ -52,8 +52,8 @@ public void testClient() throws Throwable { return; } final String server = System.getProperty("server", "127.0.0.1:9911"); - final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER); - final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION); + final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER); + final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION); final int timeout = PerformanceUtils.getIntProperty(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); final int length = PerformanceUtils.getIntProperty("length", 1024); final int connections = PerformanceUtils.getIntProperty(Constants.CONNECTIONS_KEY, 1); diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceServerTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceServerTest.java index 413aa05b657..580dbb3e980 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceServerTest.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceServerTest.java @@ -17,6 +17,7 @@ package org.apache.dubbo.remoting; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.exchange.ExchangeChannel; @@ -61,13 +62,13 @@ private static void restartServer(int times, int alive, int sleep) throws Except private static ExchangeServer statServer() throws Exception { final int port = PerformanceUtils.getIntProperty("port", 9911); - final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER); - final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION); + final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER); + final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION); final String threadpool = PerformanceUtils.getProperty(Constants.THREADPOOL_KEY, Constants.DEFAULT_THREADPOOL); final int threads = PerformanceUtils.getIntProperty(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); - final int iothreads = PerformanceUtils.getIntProperty(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS); - final int buffer = PerformanceUtils.getIntProperty(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE); - final String channelHandler = PerformanceUtils.getProperty(Constants.DISPATCHER_KEY, ExecutionDispatcher.NAME); + final int iothreads = PerformanceUtils.getIntProperty(Constants.IO_THREADS_KEY, RemotingConstants.DEFAULT_IO_THREADS); + final int buffer = PerformanceUtils.getIntProperty(RemotingConstants.BUFFER_KEY, RemotingConstants.DEFAULT_BUFFER_SIZE); + final String channelHandler = PerformanceUtils.getProperty(RemotingConstants.DISPATCHER_KEY, ExecutionDispatcher.NAME); // Start server diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/codec/ExchangeCodecTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/codec/ExchangeCodecTest.java index ac17a41ed86..7b9cbca7f16 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/codec/ExchangeCodecTest.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/codec/ExchangeCodecTest.java @@ -17,8 +17,8 @@ package org.apache.dubbo.remoting.codec; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.io.Bytes; import org.apache.dubbo.common.io.UnsafeByteArrayOutputStream; @@ -32,7 +32,6 @@ import org.apache.dubbo.remoting.exchange.codec.ExchangeCodec; import org.apache.dubbo.remoting.telnet.codec.TelnetCodec; -import org.apache.dubbo.remoting.transport.CodecSupport; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -65,7 +64,7 @@ public class ExchangeCodecTest extends TelnetCodecTest { private static final short MAGIC = (short) 0xdabb; private static final byte MAGIC_HIGH = (byte) Bytes.short2bytes(MAGIC)[0]; private static final byte MAGIC_LOW = (byte) Bytes.short2bytes(MAGIC)[1]; - Serialization serialization = getSerialization(Constants.DEFAULT_REMOTING_SERIALIZATION); + Serialization serialization = getSerialization(RemotingConstants.DEFAULT_REMOTING_SERIALIZATION); private static Serialization getSerialization(String name) { Serialization serialization = ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(name); @@ -443,7 +442,7 @@ public void testMessageLengthExceedPayloadLimitWhenEncode() throws Exception { Request request = new Request(1L); request.setData("hello"); ChannelBuffer encodeBuffer = ChannelBuffers.dynamicBuffer(512); - AbstractMockChannel channel = getCliendSideChannel(url.addParameter(Constants.PAYLOAD_KEY, 4)); + AbstractMockChannel channel = getCliendSideChannel(url.addParameter(RemotingConstants.PAYLOAD_KEY, 4)); try { codec.encode(channel, encodeBuffer, request); Assertions.fail(); @@ -454,7 +453,7 @@ public void testMessageLengthExceedPayloadLimitWhenEncode() throws Exception { Response response = new Response(1L); response.setResult("hello"); encodeBuffer = ChannelBuffers.dynamicBuffer(512); - channel = getServerSideChannel(url.addParameter(Constants.PAYLOAD_KEY, 4)); + channel = getServerSideChannel(url.addParameter(RemotingConstants.PAYLOAD_KEY, 4)); codec.encode(channel, encodeBuffer, response); Assertions.assertTrue(channel.getReceivedMessage() instanceof Response); Response receiveMessage = (Response) channel.getReceivedMessage(); diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java index 782b8480cdc..24a4080c486 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.timer.HashedWheelTimer; import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.exchange.Request; @@ -42,7 +43,7 @@ public class HeartBeatTaskTest { @BeforeEach public void setup() throws Exception { long tickDuration = 1000; - heartbeatTimer = new HashedWheelTimer(tickDuration / Constants.HEARTBEAT_CHECK_TICK, TimeUnit.MILLISECONDS); + heartbeatTimer = new HashedWheelTimer(tickDuration / RemotingConstants.HEARTBEAT_CHECK_TICK, TimeUnit.MILLISECONDS); channel = new MockChannel() { @@ -53,7 +54,7 @@ public URL getUrl() { }; AbstractTimerTask.ChannelProvider cp = () -> Collections.singletonList(channel); - heartbeatTimerTask = new HeartbeatTimerTask(cp, tickDuration / Constants.HEARTBEAT_CHECK_TICK, (int) tickDuration); + heartbeatTimerTask = new HeartbeatTimerTask(cp, tickDuration / RemotingConstants.HEARTBEAT_CHECK_TICK, (int) tickDuration); } @Test diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/handler/HeaderExchangeHandlerTest.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/handler/HeaderExchangeHandlerTest.java index 3c11eca1c45..c9c044d9a12 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/handler/HeaderExchangeHandlerTest.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/handler/HeaderExchangeHandlerTest.java @@ -17,7 +17,7 @@ package org.apache.dubbo.remoting.handler; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.RemotingException; import org.apache.dubbo.remoting.exchange.ExchangeChannel; @@ -160,7 +160,7 @@ public void test_received_request_event_readonly() throws RemotingException { final Channel mchannel = new MockedChannel(); HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(new MockedExchangeHandler()); hexhandler.received(mchannel, request); - Assertions.assertTrue(mchannel.hasAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY)); + Assertions.assertTrue(mchannel.hasAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY)); } @Test diff --git a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/codec/DeprecatedTelnetCodec.java b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/codec/DeprecatedTelnetCodec.java index 49d3a02ce4d..5b30d5cbabb 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/codec/DeprecatedTelnetCodec.java +++ b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/codec/DeprecatedTelnetCodec.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -55,9 +56,9 @@ public class DeprecatedTelnetCodec implements Codec { private static final List EXIT = Arrays.asList(new Object[]{new byte[]{3} /* Windows Ctrl+C */, new byte[]{-1, -12, -1, -3, 6} /* Linux Ctrl+C */, new byte[]{-1, -19, -1, -3, 6} /* Linux Pause */}); static void checkPayload(Channel channel, long size) throws IOException { - int payload = Constants.DEFAULT_PAYLOAD; + int payload = RemotingConstants.DEFAULT_PAYLOAD; if (channel != null && channel.getUrl() != null) { - payload = channel.getUrl().getPositiveParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD); + payload = channel.getUrl().getPositiveParameter(RemotingConstants.PAYLOAD_KEY, RemotingConstants.DEFAULT_PAYLOAD); } if (size > payload) { IOException e = new IOException("Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel); @@ -68,7 +69,7 @@ static void checkPayload(Channel channel, long size) throws IOException { private static Charset getCharset(Channel channel) { if (channel != null) { - Object attribute = channel.getAttribute(Constants.CHARSET_KEY); + Object attribute = channel.getAttribute(RemotingConstants.CHARSET_KEY); if (attribute instanceof String) { try { return Charset.forName((String) attribute); @@ -80,7 +81,7 @@ private static Charset getCharset(Channel channel) { } URL url = channel.getUrl(); if (url != null) { - String parameter = url.getParameter(Constants.CHARSET_KEY); + String parameter = url.getParameter(RemotingConstants.CHARSET_KEY); if (StringUtils.isNotEmpty(parameter)) { try { return Charset.forName(parameter); diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java index 7bc1a98bd25..48115a91560 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/Constants.java @@ -17,7 +17,7 @@ package org.apache.dubbo.remoting.etcd; -import static org.apache.dubbo.common.Constants.DEFAULT_IO_THREADS; +import static org.apache.dubbo.common.constants.RemotingConstants.DEFAULT_IO_THREADS; public interface Constants { String ETCD3_NOTIFY_MAXTHREADS_KEYS = "etcd3.notify.maxthreads"; diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/EtcdTransporter.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/EtcdTransporter.java index 2c0befb0a4c..821fc0524e0 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/EtcdTransporter.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/EtcdTransporter.java @@ -33,15 +33,15 @@ */ package org.apache.dubbo.remoting.etcd; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Adaptive; import org.apache.dubbo.common.extension.SPI; @SPI("jetcd") public interface EtcdTransporter { - @Adaptive({Constants.CLIENT_KEY, Constants.TRANSPORTER_KEY}) + @Adaptive({RemotingConstants.CLIENT_KEY, RemotingConstants.TRANSPORTER_KEY}) EtcdClient connect(URL url); } diff --git a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyCodecAdapter.java b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyCodecAdapter.java index 4e813f36f01..a7162456795 100644 --- a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyCodecAdapter.java +++ b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyCodecAdapter.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.transport.grizzly; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.ChannelHandler; import org.apache.dubbo.remoting.Codec2; @@ -52,8 +52,8 @@ public GrizzlyCodecAdapter(Codec2 codec, URL url, ChannelHandler handler) { this.codec = codec; this.url = url; this.handler = handler; - int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE); - this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE; + int b = url.getPositiveParameter(RemotingConstants.BUFFER_KEY, RemotingConstants.DEFAULT_BUFFER_SIZE); + this.bufferSize = b >= RemotingConstants.MIN_BUFFER_SIZE && b <= RemotingConstants.MAX_BUFFER_SIZE ? b : RemotingConstants.DEFAULT_BUFFER_SIZE; } @Override diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpBinder.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpBinder.java index 92e3dd02ce2..4f1392bf847 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpBinder.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/HttpBinder.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.http; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Adaptive; import org.apache.dubbo.common.extension.SPI; @@ -33,7 +33,7 @@ public interface HttpBinder { * @param url server url. * @return server. */ - @Adaptive({Constants.SERVER_KEY}) + @Adaptive({RemotingConstants.SERVER_KEY}) HttpServer bind(URL url, HttpHandler handler); } \ No newline at end of file diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpServer.java index 6ff19df36de..0274271b85b 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpServer.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyHttpServer.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.NetUtils; @@ -51,7 +52,7 @@ public JettyHttpServer(URL url, final HttpHandler handler) { Log.setLog(new StdErrLog()); Log.getLog().setDebugEnabled(false); - DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), handler); + DispatcherServlet.addHttpHandler(url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort()), handler); int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); QueuedThreadPool threadPool = new QueuedThreadPool(); @@ -63,11 +64,11 @@ public JettyHttpServer(URL url, final HttpHandler handler) { ServerConnector connector = new ServerConnector(server); - String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost()); + String bindIp = url.getParameter(RemotingConstants.BIND_IP_KEY, url.getHost()); if (!url.isAnyHost() && NetUtils.isValidLocalHost(bindIp)) { connector.setHost(bindIp); } - connector.setPort(url.getParameter(Constants.BIND_PORT_KEY, url.getPort())); + connector.setPort(url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort())); server.addConnector(connector); @@ -80,12 +81,12 @@ public JettyHttpServer(URL url, final HttpHandler handler) { // TODO Context.SESSIONS is the best option here? (In jetty 9.x, it becomes ServletContextHandler.SESSIONS) ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); context.setServletHandler(servletHandler); - ServletManager.getInstance().addServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), context.getServletContext()); + ServletManager.getInstance().addServletContext(url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort()), context.getServletContext()); try { server.start(); } catch (Exception e) { - throw new IllegalStateException("Failed to start jetty server on " + url.getParameter(Constants.BIND_IP_KEY) + ":" + url.getParameter(Constants.BIND_PORT_KEY) + ", cause: " + throw new IllegalStateException("Failed to start jetty server on " + url.getParameter(RemotingConstants.BIND_IP_KEY) + ":" + url.getParameter(RemotingConstants.BIND_PORT_KEY) + ", cause: " + e.getMessage(), e); } } @@ -95,7 +96,7 @@ public void close() { super.close(); // - ServletManager.getInstance().removeServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort())); + ServletManager.getInstance().removeServletContext(url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort())); if (server != null) { try { diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpServer.java index 772e46e99b4..cd23699e72a 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpServer.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/servlet/ServletHttpServer.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.http.servlet; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.http.HttpHandler; import org.apache.dubbo.remoting.http.support.AbstractHttpServer; @@ -25,7 +25,7 @@ public class ServletHttpServer extends AbstractHttpServer { public ServletHttpServer(URL url, HttpHandler handler) { super(url, handler); - DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, 8080), handler); + DispatcherServlet.addHttpHandler(url.getParameter(RemotingConstants.BIND_PORT_KEY, 8080), handler); } } \ No newline at end of file diff --git a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java index f8a898c9713..901d5880471 100755 --- a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java +++ b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.http.HttpHandler; @@ -54,7 +55,7 @@ public TomcatHttpServer(URL url, final HttpHandler handler) { // "minSpareThreads", String.valueOf(url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS))); tomcat.getConnector().setProperty( - "maxConnections", String.valueOf(url.getParameter(Constants.ACCEPTS_KEY, -1))); + "maxConnections", String.valueOf(url.getParameter(RemotingConstants.ACCEPTS_KEY, -1))); tomcat.getConnector().setProperty("URIEncoding", "UTF-8"); tomcat.getConnector().setProperty("connectionTimeout", "60000"); diff --git a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java index 0aca829f2be..63dae7b7e58 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java +++ b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/jetty/JettyHttpBinderTest.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.http.jetty; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.remoting.http.HttpHandler; import org.apache.dubbo.remoting.http.HttpServer; @@ -36,7 +36,7 @@ public class JettyHttpBinderTest { public void shouldAbleHandleRequestForJettyBinder() throws Exception { int port = NetUtils.getAvailablePort(); URL url = new URL("http", "localhost", port, - new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)}); + new String[]{RemotingConstants.BIND_PORT_KEY, String.valueOf(port)}); HttpServer httpServer = new JettyHttpServer(url, new HttpHandler() { @Override public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException { diff --git a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java index 9b3e3b16d63..086f624334e 100644 --- a/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java +++ b/dubbo-remoting/dubbo-remoting-http/src/test/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpBinderTest.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.http.tomcat; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.remoting.http.HttpHandler; import org.apache.dubbo.remoting.http.HttpServer; @@ -37,7 +37,7 @@ public class TomcatHttpBinderTest { public void shouldAbleHandleRequestForTomcatBinder() throws Exception { int port = NetUtils.getAvailablePort(); URL url = new URL("http", "localhost", port, - new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)}); + new String[]{RemotingConstants.BIND_PORT_KEY, String.valueOf(port)}); HttpServer httpServer = new TomcatHttpBinder().bind(url, new HttpHandler() { @Override diff --git a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaClient.java b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaClient.java index b5e9c8426d1..ee926a26477 100644 --- a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaClient.java +++ b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaClient.java @@ -16,9 +16,9 @@ */ package org.apache.dubbo.remoting.transport.mina; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.NamedThreadFactory; @@ -71,7 +71,7 @@ protected void doOpen() throws Throwable { connector = c; } else { // set thread pool. - connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, + connector = new SocketConnector(RemotingConstants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true))); // config SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig(); diff --git a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaCodecAdapter.java b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaCodecAdapter.java index 5e60fb2d490..128f119c062 100644 --- a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaCodecAdapter.java +++ b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaCodecAdapter.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.transport.mina; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.ChannelHandler; import org.apache.dubbo.remoting.Codec2; @@ -54,8 +54,8 @@ public MinaCodecAdapter(Codec2 codec, URL url, ChannelHandler handler) { this.codec = codec; this.url = url; this.handler = handler; - int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE); - this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE; + int b = url.getPositiveParameter(RemotingConstants.BUFFER_KEY, RemotingConstants.DEFAULT_BUFFER_SIZE); + this.bufferSize = b >= RemotingConstants.MIN_BUFFER_SIZE && b <= RemotingConstants.MAX_BUFFER_SIZE ? b : RemotingConstants.DEFAULT_BUFFER_SIZE; } @Override diff --git a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaServer.java b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaServer.java index 540213b4443..4937944eccb 100644 --- a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaServer.java +++ b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaServer.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.ExecutorUtil; @@ -56,7 +57,7 @@ public MinaServer(URL url, ChannelHandler handler) throws RemotingException { @Override protected void doOpen() throws Throwable { // set thread pool. - acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS), + acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, RemotingConstants.DEFAULT_IO_THREADS), Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker", true))); // config diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyClient.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyClient.java index e9912985ebc..80b8ae60474 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyClient.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyClient.java @@ -16,9 +16,9 @@ */ package org.apache.dubbo.remoting.transport.netty; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.NamedThreadFactory; @@ -50,7 +50,7 @@ public class NettyClient extends AbstractClient { // https://issues.jboss.org/browse/NETTY-424 private static final ChannelFactory CHANNEL_FACTORY = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(new NamedThreadFactory("NettyClientBoss", true)), Executors.newCachedThreadPool(new NamedThreadFactory("NettyClientWorker", true)), - Constants.DEFAULT_IO_THREADS); + RemotingConstants.DEFAULT_IO_THREADS); private ClientBootstrap bootstrap; private volatile Channel channel; // volatile, please copy reference to use diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyCodecAdapter.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyCodecAdapter.java index f23ee2dee09..5088001278c 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyCodecAdapter.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyCodecAdapter.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.transport.netty; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.Codec2; import org.apache.dubbo.remoting.buffer.DynamicChannelBuffer; @@ -56,8 +56,8 @@ public NettyCodecAdapter(Codec2 codec, URL url, org.apache.dubbo.remoting.Channe this.codec = codec; this.url = url; this.handler = handler; - int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE); - this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE; + int b = url.getPositiveParameter(RemotingConstants.BUFFER_KEY, RemotingConstants.DEFAULT_BUFFER_SIZE); + this.bufferSize = b >= RemotingConstants.MIN_BUFFER_SIZE && b <= RemotingConstants.MAX_BUFFER_SIZE ? b : RemotingConstants.DEFAULT_BUFFER_SIZE; } public ChannelHandler getEncoder() { diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyServer.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyServer.java index 61cd3f1ef0c..b25461e0f14 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyServer.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyServer.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.CollectionUtils; @@ -67,7 +68,7 @@ protected void doOpen() throws Throwable { NettyHelper.setNettyLoggerFactory(); ExecutorService boss = Executors.newCachedThreadPool(new NamedThreadFactory("NettyServerBoss", true)); ExecutorService worker = Executors.newCachedThreadPool(new NamedThreadFactory("NettyServerWorker", true)); - ChannelFactory channelFactory = new NioServerSocketChannelFactory(boss, worker, getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS)); + ChannelFactory channelFactory = new NioServerSocketChannelFactory(boss, worker, getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, RemotingConstants.DEFAULT_IO_THREADS)); bootstrap = new ServerBootstrap(channelFactory); final NettyHandler nettyHandler = new NettyHandler(getUrl(), this); diff --git a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartbeatHandlerTest.java b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartbeatHandlerTest.java index 52c3e9d03e7..7a1134e8fae 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartbeatHandlerTest.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartbeatHandlerTest.java @@ -17,8 +17,8 @@ package org.apache.dubbo.remoting.exchange.support.header; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.Channel; @@ -61,17 +61,17 @@ public void after() throws Exception { @Test public void testServerHeartbeat() throws Exception { URL serverURL = URL.valueOf("header://localhost:55555?transporter=netty3"); - serverURL = serverURL.addParameter(Constants.HEARTBEAT_KEY, 1000); + serverURL = serverURL.addParameter(RemotingConstants.HEARTBEAT_KEY, 1000); TestHeartbeatHandler handler = new TestHeartbeatHandler(); server = Exchangers.bind(serverURL, handler); System.out.println("Server bind successfully"); FakeChannelHandlers.setTestingChannelHandlers(); - serverURL = serverURL.removeParameter(Constants.HEARTBEAT_KEY); + serverURL = serverURL.removeParameter(RemotingConstants.HEARTBEAT_KEY); // Let the client not reply to the heartbeat, and turn off automatic reconnect to simulate the client dropped. - serverURL = serverURL.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000); - serverURL = serverURL.addParameter(Constants.RECONNECT_KEY, false); + serverURL = serverURL.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000); + serverURL = serverURL.addParameter(RemotingConstants.RECONNECT_KEY, false); client = Exchangers.connect(serverURL); Thread.sleep(10000); @@ -82,7 +82,7 @@ public void testServerHeartbeat() throws Exception { @Test public void testHeartbeat() throws Exception { URL serverURL = URL.valueOf("header://localhost:55555?transporter=netty3"); - serverURL = serverURL.addParameter(Constants.HEARTBEAT_KEY, 1000); + serverURL = serverURL.addParameter(RemotingConstants.HEARTBEAT_KEY, 1000); TestHeartbeatHandler handler = new TestHeartbeatHandler(); server = Exchangers.bind(serverURL, handler); System.out.println("Server bind successfully"); @@ -104,7 +104,7 @@ public void testClientHeartbeat() throws Exception { System.out.println("Server bind successfully"); FakeChannelHandlers.resetChannelHandlers(); - serverURL = serverURL.addParameter(Constants.HEARTBEAT_KEY, 1000); + serverURL = serverURL.addParameter(RemotingConstants.HEARTBEAT_KEY, 1000); client = Exchangers.connect(serverURL); Thread.sleep(10000); Assertions.assertTrue(handler.connectCount > 0); diff --git a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/ClientReconnectTest.java b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/ClientReconnectTest.java index 4cb7eb6784d..52452126bf5 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/ClientReconnectTest.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/ClientReconnectTest.java @@ -16,7 +16,7 @@ */ package org.apache.dubbo.remoting.transport.netty; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.DubboAppender; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.remoting.Channel; @@ -70,7 +70,7 @@ public void testReconnect() throws RemotingException, InterruptedException { public Client startClient(int port, int heartbeat) throws RemotingException { - final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?check=false&client=netty3&" + Constants.HEARTBEAT_KEY + "=" + heartbeat; + final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?check=false&client=netty3&" + RemotingConstants.HEARTBEAT_KEY + "=" + heartbeat; return Exchangers.connect(url); } diff --git a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/NettyClientToServerTest.java b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/NettyClientToServerTest.java index 3d4e52d022f..060efbe9d1f 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/NettyClientToServerTest.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/NettyClientToServerTest.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.transport.netty; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.RemotingException; import org.apache.dubbo.remoting.exchange.ExchangeChannel; import org.apache.dubbo.remoting.exchange.ExchangeServer; @@ -32,14 +32,14 @@ public class NettyClientToServerTest extends ClientToServerTest { protected ExchangeServer newServer(int port, Replier receiver) throws RemotingException { // add heartbeat cycle to avoid unstable ut. URL url = URL.valueOf("exchange://localhost:" + port + "?server=netty3"); - url = url.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000); + url = url.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000); return Exchangers.bind(url, receiver); } protected ExchangeChannel newClient(int port) throws RemotingException { // add heartbeat cycle to avoid unstable ut. URL url = URL.valueOf("exchange://localhost:" + port + "?client=netty3&timeout=3000"); - url = url.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000); + url = url.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000); return Exchangers.connect(url); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java index 322d658b856..e772905bcec 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java @@ -16,9 +16,9 @@ */ package org.apache.dubbo.remoting.transport.netty4; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.ConfigUtils; @@ -51,7 +51,7 @@ public class NettyClient extends AbstractClient { private static final Logger logger = LoggerFactory.getLogger(NettyClient.class); - private static final NioEventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(Constants.DEFAULT_IO_THREADS, new DefaultThreadFactory("NettyClientWorker", true)); + private static final NioEventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(RemotingConstants.DEFAULT_IO_THREADS, new DefaultThreadFactory("NettyClientWorker", true)); private static final String SOCKS_PROXY_HOST = "socksProxyHost"; diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServer.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServer.java index 62b6c55f93c..ad952a75ce1 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServer.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServer.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.ExecutorUtil; @@ -74,7 +75,7 @@ protected void doOpen() throws Throwable { bootstrap = new ServerBootstrap(); bossGroup = new NioEventLoopGroup(1, new DefaultThreadFactory("NettyServerBoss", true)); - workerGroup = new NioEventLoopGroup(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS), + workerGroup = new NioEventLoopGroup(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, RemotingConstants.DEFAULT_IO_THREADS), new DefaultThreadFactory("NettyServerWorker", true)); final NettyServerHandler nettyServerHandler = new NettyServerHandler(getUrl(), this); diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/ClientReconnectTest.java b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/ClientReconnectTest.java index f21918d3d15..1768183c3ee 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/ClientReconnectTest.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/ClientReconnectTest.java @@ -16,7 +16,7 @@ */ package org.apache.dubbo.remoting.transport.netty4; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.DubboAppender; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.remoting.Channel; @@ -72,7 +72,7 @@ public void testReconnect() throws RemotingException, InterruptedException { public Client startClient(int port, int heartbeat) throws RemotingException { - final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?client=netty4&check=false&" + Constants.HEARTBEAT_KEY + "=" + heartbeat; + final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?client=netty4&check=false&" + RemotingConstants.HEARTBEAT_KEY + "=" + heartbeat; return Exchangers.connect(url); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyClientToServerTest.java b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyClientToServerTest.java index 1d3d5132d8a..04eaef883cc 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyClientToServerTest.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyClientToServerTest.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.transport.netty4; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.RemotingException; import org.apache.dubbo.remoting.exchange.ExchangeChannel; import org.apache.dubbo.remoting.exchange.ExchangeServer; @@ -32,14 +32,14 @@ public class NettyClientToServerTest extends ClientToServerTest { protected ExchangeServer newServer(int port, Replier receiver) throws RemotingException { // add heartbeat cycle to avoid unstable ut. URL url = URL.valueOf("exchange://localhost:" + port + "?server=netty4"); - url = url.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000); + url = url.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000); return Exchangers.bind(url, receiver); } protected ExchangeChannel newClient(int port) throws RemotingException { // add heartbeat cycle to avoid unstable ut. URL url = URL.valueOf("exchange://localhost:" + port + "?client=netty4&timeout=3000"); - url = url.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000); + url = url.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000); return Exchangers.connect(url); } diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyTransporterTest.java b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyTransporterTest.java index b0bf7209a0c..db942c554e5 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyTransporterTest.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyTransporterTest.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.transport.netty4; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.RemotingException; @@ -36,7 +36,7 @@ public class NettyTransporterTest { public void shouldAbleToBindNetty4() throws Exception { int port = NetUtils.getAvailablePort(); URL url = new URL("http", "localhost", port, - new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)}); + new String[]{RemotingConstants.BIND_PORT_KEY, String.valueOf(port)}); Server server = new NettyTransporter().bind(url, new ChannelHandlerAdapter()); @@ -49,7 +49,7 @@ public void shouldConnectToNetty4Server() throws Exception { int port = NetUtils.getAvailablePort(); URL url = new URL("http", "localhost", port, - new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)}); + new String[]{RemotingConstants.BIND_PORT_KEY, String.valueOf(port)}); new NettyTransporter().bind(url, new ChannelHandlerAdapter() { diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/org/apache/dubbo/remoting/p2p/exchange/support/ExchangeServerPeer.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/org/apache/dubbo/remoting/p2p/exchange/support/ExchangeServerPeer.java index 35d5ff70147..2f534c9e8bd 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/org/apache/dubbo/remoting/p2p/exchange/support/ExchangeServerPeer.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/org/apache/dubbo/remoting/p2p/exchange/support/ExchangeServerPeer.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.p2p.exchange.support; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.Channel; @@ -105,7 +105,7 @@ public ExchangeChannel getExchangeChannel(InetSocketAddress remoteAddress) { @Override public void send(Object message) throws RemotingException { - send(message, getUrl().getParameter(Constants.SENT_KEY, false)); + send(message, getUrl().getParameter(RemotingConstants.SENT_KEY, false)); } @Override diff --git a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/org/apache/dubbo/remoting/p2p/support/ServerPeer.java b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/org/apache/dubbo/remoting/p2p/support/ServerPeer.java index 83e5e8815b7..a6d215fb611 100644 --- a/dubbo-remoting/dubbo-remoting-p2p/src/main/java/org/apache/dubbo/remoting/p2p/support/ServerPeer.java +++ b/dubbo-remoting/dubbo-remoting-p2p/src/main/java/org/apache/dubbo/remoting/p2p/support/ServerPeer.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.remoting.p2p.support; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.Channel; @@ -92,7 +92,7 @@ public Channel getChannel(InetSocketAddress remoteAddress) { @Override public void send(Object message) throws RemotingException { - send(message, getUrl().getParameter(Constants.SENT_KEY, false)); + send(message, getUrl().getParameter(RemotingConstants.SENT_KEY, false)); } @Override diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java index a339d97a177..96a459c93bc 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/ZookeeperTransporter.java @@ -16,15 +16,15 @@ */ package org.apache.dubbo.remoting.zookeeper; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Adaptive; import org.apache.dubbo.common.extension.SPI; @SPI("curator") public interface ZookeeperTransporter { - @Adaptive({Constants.CLIENT_KEY, Constants.TRANSPORTER_KEY}) + @Adaptive({RemotingConstants.CLIENT_KEY, RemotingConstants.TRANSPORTER_KEY}) ZookeeperClient connect(URL url); } diff --git a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporter.java b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporter.java index 72c702a1df3..ab6ada6a38c 100644 --- a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporter.java +++ b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/support/AbstractZookeeperTransporter.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.remoting.zookeeper.ZookeeperClient; @@ -110,7 +111,7 @@ List getURLBackupAddress(URL url) { List addressList = new ArrayList(); addressList.add(url.getAddress()); - addressList.addAll(url.getParameter(Constants.BACKUP_KEY, Collections.EMPTY_LIST)); + addressList.addAll(url.getParameter(RemotingConstants.BACKUP_KEY, Collections.EMPTY_LIST)); return addressList; } @@ -138,8 +139,8 @@ URL toClientURL(URL url) { if (url.getParameter(Constants.TIMEOUT_KEY) != null) { parameterMap.put(Constants.TIMEOUT_KEY, url.getParameter(Constants.TIMEOUT_KEY)); } - if (url.getParameter(Constants.BACKUP_KEY) != null) { - parameterMap.put(Constants.BACKUP_KEY, url.getParameter(Constants.BACKUP_KEY)); + if (url.getParameter(RemotingConstants.BACKUP_KEY) != null) { + parameterMap.put(RemotingConstants.BACKUP_KEY, url.getParameter(RemotingConstants.BACKUP_KEY)); } return new URL(url.getProtocol(), url.getUsername(), url.getPassword(), url.getHost(), url.getPort(), ZookeeperTransporter.class.getName(), parameterMap); diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/CompatibleFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/CompatibleFilter.java index ace832ca33c..74ab6d6f4de 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/CompatibleFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/CompatibleFilter.java @@ -16,7 +16,7 @@ */ package org.apache.dubbo.rpc.filter; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.CompatibleTypeUtils; @@ -59,7 +59,7 @@ public Result invoke(Invoker invoker, Invocation invocation) throws RpcExcept Method method = invoker.getInterface().getMethod(invocation.getMethodName(), invocation.getParameterTypes()); Class type = method.getReturnType(); Object newValue; - String serialization = invoker.getUrl().getParameter(Constants.SERIALIZATION_KEY); + String serialization = invoker.getUrl().getParameter(RemotingConstants.SERIALIZATION_KEY); if ("json".equals(serialization) || "fastjson".equals(serialization)) { // If the serialization key is json or fastjson diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java index 814e9182280..afac729e266 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.ConcurrentHashSet; @@ -44,7 +45,7 @@ public abstract class AbstractProtocol implements Protocol { protected final Set> invokers = new ConcurrentHashSet>(); protected static String serviceKey(URL url) { - int port = url.getParameter(Constants.BIND_PORT_KEY, url.getPort()); + int port = url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort()); return serviceKey(port, url.getPath(), url.getParameter(Constants.VERSION_KEY), url.getParameter(Constants.GROUP_KEY)); } diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProxyProtocol.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProxyProtocol.java index a77a5bdc5f3..ef9ab321cb4 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProxyProtocol.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProxyProtocol.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.rpc.Exporter; import org.apache.dubbo.rpc.Invocation; @@ -130,11 +131,11 @@ protected RpcException getRpcException(Class type, URL url, Invocation invoca } protected String getAddr(URL url) { - String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost()); + String bindIp = url.getParameter(RemotingConstants.BIND_IP_KEY, url.getHost()); if (url.getParameter(Constants.ANYHOST_KEY, false)) { bindIp = Constants.ANYHOST_VALUE; } - return NetUtils.getIpByHost(bindIp) + ":" + url.getParameter(Constants.BIND_PORT_KEY, url.getPort()); + return NetUtils.getIpByHost(bindIp) + ":" + url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort()); } protected int getErrorCode(Throwable e) { diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java index 4c78c1cceb9..14c76446143 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.ChannelHandler; import org.apache.dubbo.remoting.RemotingException; @@ -59,7 +60,7 @@ protected Result doInvoke(Invocation invocation) throws Throwable { try { if (getUrl().getMethodParameter(invocation.getMethodName(), Constants.ASYNC_KEY, false)) { // may have concurrency issue - currentClient.send(inv, getUrl().getMethodParameter(invocation.getMethodName(), Constants.SENT_KEY, false)); + currentClient.send(inv, getUrl().getMethodParameter(invocation.getMethodName(), RemotingConstants.SENT_KEY, false)); return new RpcResult(); } int timeout = getUrl().getMethodParameter(invocation.getMethodName(), Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java index 5f2c61b1cae..0bddaf16384 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.ConfigurationUtils; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.AtomicPositiveInteger; import org.apache.dubbo.remoting.RemotingException; import org.apache.dubbo.remoting.TimeoutException; @@ -85,7 +86,7 @@ protected Result doInvoke(final Invocation invocation) throws Throwable { boolean isOneway = RpcUtils.isOneway(getUrl(), invocation); int timeout = getUrl().getMethodParameter(methodName, Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); if (isOneway) { - boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false); + boolean isSent = getUrl().getMethodParameter(methodName, RemotingConstants.SENT_KEY, false); currentClient.send(inv, isSent); RpcContext.getContext().setFuture(null); return new RpcResult(); @@ -120,7 +121,7 @@ public boolean isAvailable() { return false; } for (ExchangeClient client : clients) { - if (client.isConnected() && !client.hasAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY)) { + if (client.isConnected() && !client.hasAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY)) { //cannot write == not Available ? return true; } diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java index 77443016cfb..9d881d08f0e 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URLBuilder; import org.apache.dubbo.common.config.ConfigurationUtils; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.serialize.support.SerializableClassRegistry; import org.apache.dubbo.common.serialize.support.SerializationOptimizer; @@ -315,12 +316,12 @@ private void openServer(URL url) { private ExchangeServer createServer(URL url) { url = URLBuilder.from(url) // send readonly event when server closes, it's enabled by default - .addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString()) + .addParameterIfAbsent(RemotingConstants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString()) // enable heartbeat by default - .addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT)) - .addParameter(Constants.CODEC_KEY, DubboCodec.NAME) + .addParameterIfAbsent(RemotingConstants.HEARTBEAT_KEY, String.valueOf(RemotingConstants.DEFAULT_HEARTBEAT)) + .addParameter(RemotingConstants.CODEC_KEY, DubboCodec.NAME) .build(); - String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER); + String str = url.getParameter(RemotingConstants.SERVER_KEY, RemotingConstants.DEFAULT_REMOTING_SERVER); if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) { throw new RpcException("Unsupported server type: " + str + ", url: " + url); @@ -333,7 +334,7 @@ private ExchangeServer createServer(URL url) { throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e); } - str = url.getParameter(Constants.CLIENT_KEY); + str = url.getParameter(RemotingConstants.CLIENT_KEY); if (str != null && str.length() > 0) { Set supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions(); if (!supportedTypes.contains(str)) { @@ -555,11 +556,11 @@ private ReferenceCountExchangeClient buildReferenceCountExchangeClient(URL url) private ExchangeClient initClient(URL url) { // client type setting. - String str = url.getParameter(Constants.CLIENT_KEY, url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_CLIENT)); + String str = url.getParameter(RemotingConstants.CLIENT_KEY, url.getParameter(RemotingConstants.SERVER_KEY, RemotingConstants.DEFAULT_REMOTING_CLIENT)); - url = url.addParameter(Constants.CODEC_KEY, DubboCodec.NAME); + url = url.addParameter(RemotingConstants.CODEC_KEY, DubboCodec.NAME); // enable heartbeat by default - url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT)); + url = url.addParameterIfAbsent(RemotingConstants.HEARTBEAT_KEY, String.valueOf(RemotingConstants.DEFAULT_HEARTBEAT)); // BIO is not allowed since it has severe performance issue. if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) { diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java index f2bc4534fdc..c0111a38b20 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.Parameters; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.NetUtils; @@ -59,7 +60,7 @@ final class LazyConnectExchangeClient implements ExchangeClient { public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) { // lazy connect, need set send.reconnect = true, to avoid channel bad status. - this.url = url.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString()); + this.url = url.addParameter(RemotingConstants.SEND_RECONNECT_KEY, Boolean.TRUE.toString()); this.requestHandler = requestHandler; this.initialState = url.getParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Constants.DEFAULT_LAZY_CONNECT_INITIAL_STATE); this.requestWithWarning = url.getParameter(REQUEST_WITH_WARNING_KEY, false); diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java index faafe082852..5befa5f2ee7 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.Parameters; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.URLBuilder; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.ChannelHandler; import org.apache.dubbo.remoting.RemotingException; import org.apache.dubbo.remoting.exchange.ExchangeClient; @@ -168,8 +169,8 @@ private void replaceWithLazyClient() { // this is a defensive operation to avoid client is closed by accident, the initial state of the client is false URL lazyUrl = URLBuilder.from(url) .addParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Boolean.FALSE) - .addParameter(Constants.RECONNECT_KEY, Boolean.FALSE) - .addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString()) + .addParameter(RemotingConstants.RECONNECT_KEY, Boolean.FALSE) + .addParameter(RemotingConstants.SEND_RECONNECT_KEY, Boolean.TRUE.toString()) .addParameter("warning", Boolean.TRUE.toString()) .addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true) .addParameter("_client_memo", "referencecounthandler.replacewithlazyclient") diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java index 1249c93e2c8..004e47f1588 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java @@ -17,6 +17,7 @@ package org.apache.dubbo.rpc.protocol.dubbo.filter; import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Activate; import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; @@ -103,7 +104,7 @@ public Result invoke(Invoker invoker, Invocation invocation) throws RpcExcept } count = c.getAndIncrement(); if (count < max) { - String prompt = channel.getUrl().getParameter(Constants.PROMPT_KEY, Constants.DEFAULT_PROMPT); + String prompt = channel.getUrl().getParameter(RemotingConstants.PROMPT_KEY, RemotingConstants.DEFAULT_PROMPT); channel.send("\r\n" + RpcContext.getContext().getRemoteAddress() + " -> " + invoker.getInterface().getName() + "." + invocation.getMethodName() diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/status/ThreadPoolStatusChecker.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/status/ThreadPoolStatusChecker.java index 1e88c15b34b..6797782f3a5 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/status/ThreadPoolStatusChecker.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/status/ThreadPoolStatusChecker.java @@ -16,7 +16,7 @@ */ package org.apache.dubbo.rpc.protocol.dubbo.status; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.Activate; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.status.Status; @@ -36,7 +36,7 @@ public class ThreadPoolStatusChecker implements StatusChecker { @Override public Status check() { DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); - Map executors = dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY); + Map executors = dataStore.get(RemotingConstants.EXECUTOR_SERVICE_COMPONENT_KEY); StringBuilder msg = new StringBuilder(); Status.Level level = Status.Level.OK; diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvokerAvilableTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvokerAvilableTest.java index e2b71d05432..b63a3584652 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvokerAvilableTest.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvokerAvilableTest.java @@ -20,6 +20,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.ConfigurationUtils; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.remoting.exchange.ExchangeClient; @@ -76,12 +77,12 @@ public void test_Normal_ChannelReadOnly() throws Exception { DubboInvoker invoker = (DubboInvoker) protocol.refer(IDemoService.class, url); Assertions.assertEquals(true, invoker.isAvailable()); - getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); + getClients(invoker)[0].setAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); Assertions.assertEquals(false, invoker.isAvailable()); // reset status since connection is shared among invokers - getClients(invoker)[0].removeAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY); + getClients(invoker)[0].removeAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY); } @Disabled @@ -130,7 +131,7 @@ public void test_Lazy_ChannelReadOnly() throws Exception { Assertions.assertEquals(true, invoker.isAvailable()); try { - getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); + getClients(invoker)[0].setAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); fail(); } catch (IllegalStateException e) { @@ -140,7 +141,7 @@ public void test_Lazy_ChannelReadOnly() throws Exception { Assertions.assertEquals("ok", service.get()); Assertions.assertEquals(true, invoker.isAvailable()); - getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); + getClients(invoker)[0].setAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE); Assertions.assertEquals(false, invoker.isAvailable()); } diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java index 61d9b6cc148..b5df719f3ea 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java @@ -17,8 +17,8 @@ package org.apache.dubbo.rpc.protocol.dubbo; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.rpc.Protocol; import org.apache.dubbo.rpc.ProxyFactory; @@ -96,8 +96,8 @@ public void testDubboProtocol() throws Exception { @Test public void testDubboProtocolWithMina() throws Exception { DemoService service = new DemoServiceImpl(); - protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:9011/" + DemoService.class.getName()).addParameter(Constants.SERVER_KEY, "mina"))); - service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9011/" + DemoService.class.getName()).addParameter(Constants.CLIENT_KEY, "mina").addParameter("timeout", 3000l))); + protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:9011/" + DemoService.class.getName()).addParameter(RemotingConstants.SERVER_KEY, "mina"))); + service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9011/" + DemoService.class.getName()).addParameter(RemotingConstants.CLIENT_KEY, "mina").addParameter("timeout", 3000l))); for (int i = 0; i < 10; i++) { assertEquals(service.enumlength(new Type[]{}), Type.Lower); assertEquals(service.getSize(null), -1); diff --git a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/DubboHessianURLConnectionFactory.java b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/DubboHessianURLConnectionFactory.java index 21c566fe0fb..10d1a1bffe3 100644 --- a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/DubboHessianURLConnectionFactory.java +++ b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/DubboHessianURLConnectionFactory.java @@ -17,7 +17,7 @@ package org.apache.dubbo.rpc.protocol.hessian; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.rpc.RpcContext; import com.caucho.hessian.client.HessianConnection; @@ -33,7 +33,7 @@ public HessianConnection open(URL url) throws IOException { HessianConnection connection = super.open(url); RpcContext context = RpcContext.getContext(); for (String key : context.getAttachments().keySet()) { - connection.addHeader(Constants.DEFAULT_EXCHANGER + key, context.getAttachment(key)); + connection.addHeader(RemotingConstants.DEFAULT_EXCHANGER + key, context.getAttachment(key)); } return connection; diff --git a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java index 3b9239171a9..0c76e1e7662 100644 --- a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java +++ b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HessianProtocol.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.http.HttpBinder; import org.apache.dubbo.remoting.http.HttpHandler; import org.apache.dubbo.remoting.http.HttpServer; @@ -107,7 +108,7 @@ protected T doRefer(Class serviceType, URL url) throws RpcException { hessianProxyFactory.setHessian2Request(isHessian2Request); boolean isOverloadEnabled = url.getParameter(Constants.HESSIAN_OVERLOAD_METHOD_KEY, Constants.DEFAULT_HESSIAN_OVERLOAD_METHOD); hessianProxyFactory.setOverloadEnabled(isOverloadEnabled); - String client = url.getParameter(Constants.CLIENT_KEY, Constants.DEFAULT_HTTP_CLIENT); + String client = url.getParameter(RemotingConstants.CLIENT_KEY, Constants.DEFAULT_HTTP_CLIENT); if ("httpclient".equals(client)) { HessianConnectionFactory factory = new HttpClientConnectionFactory(); factory.setHessianProxyFactory(hessianProxyFactory); @@ -174,8 +175,8 @@ public void handle(HttpServletRequest request, HttpServletResponse response) Enumeration enumeration = request.getHeaderNames(); while (enumeration.hasMoreElements()) { String key = enumeration.nextElement(); - if (key.startsWith(Constants.DEFAULT_EXCHANGER)) { - RpcContext.getContext().setAttachment(key.substring(Constants.DEFAULT_EXCHANGER.length()), + if (key.startsWith(RemotingConstants.DEFAULT_EXCHANGER)) { + RpcContext.getContext().setAttachment(key.substring(RemotingConstants.DEFAULT_EXCHANGER.length()), request.getHeader(key)); } } diff --git a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java index 2c6f6db890b..b5bec3e2c5e 100644 --- a/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java +++ b/dubbo-rpc/dubbo-rpc-hessian/src/main/java/org/apache/dubbo/rpc/protocol/hessian/HttpClientConnectionFactory.java @@ -16,7 +16,7 @@ */ package org.apache.dubbo.rpc.protocol.hessian; -import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.rpc.RpcContext; import com.caucho.hessian.client.HessianConnection; @@ -49,7 +49,7 @@ public HessianConnection open(URL url) { HttpClientConnection httpClientConnection = new HttpClientConnection(httpClient, url); RpcContext context = RpcContext.getContext(); for (String key : context.getAttachments().keySet()) { - httpClientConnection.addHeader(Constants.DEFAULT_EXCHANGER + key, context.getAttachment(key)); + httpClientConnection.addHeader(RemotingConstants.DEFAULT_EXCHANGER + key, context.getAttachment(key)); } return httpClientConnection; } diff --git a/dubbo-rpc/dubbo-rpc-http/src/main/java/org/apache/dubbo/rpc/protocol/http/HttpProtocol.java b/dubbo-rpc/dubbo-rpc-http/src/main/java/org/apache/dubbo/rpc/protocol/http/HttpProtocol.java index 0188a0fe329..d744ebfc0e8 100644 --- a/dubbo-rpc/dubbo-rpc-http/src/main/java/org/apache/dubbo/rpc/protocol/http/HttpProtocol.java +++ b/dubbo-rpc/dubbo-rpc-http/src/main/java/org/apache/dubbo/rpc/protocol/http/HttpProtocol.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.common.Version; import org.apache.dubbo.remoting.http.HttpBinder; @@ -153,7 +154,7 @@ public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation httpProxyFactoryBean.setServiceUrl(key); httpProxyFactoryBean.setServiceInterface(serviceType); - String client = url.getParameter(Constants.CLIENT_KEY); + String client = url.getParameter(RemotingConstants.CLIENT_KEY); if (StringUtils.isEmpty(client) || "simple".equals(client)) { SimpleHttpInvokerRequestExecutor httpInvokerRequestExecutor = new SimpleHttpInvokerRequestExecutor() { @Override @@ -161,14 +162,14 @@ protected void prepareConnection(HttpURLConnection con, int contentLength) throws IOException { super.prepareConnection(con, contentLength); con.setReadTimeout(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT)); - con.setConnectTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT)); + con.setConnectTimeout(url.getParameter(RemotingConstants.CONNECT_TIMEOUT_KEY, RemotingConstants.DEFAULT_CONNECT_TIMEOUT)); } }; httpProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); } else if ("commons".equals(client)) { HttpComponentsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new HttpComponentsHttpInvokerRequestExecutor(); httpInvokerRequestExecutor.setReadTimeout(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT)); - httpInvokerRequestExecutor.setConnectTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT)); + httpInvokerRequestExecutor.setConnectTimeout(url.getParameter(RemotingConstants.CONNECT_TIMEOUT_KEY, RemotingConstants.DEFAULT_CONNECT_TIMEOUT)); httpProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); } else { throw new IllegalStateException("Unsupported http protocol client " + client + ", only supported: simple, commons"); diff --git a/dubbo-rpc/dubbo-rpc-memcached/src/main/java/org/apache/dubbo/rpc/protocol/memcached/MemcachedProtocol.java b/dubbo-rpc/dubbo-rpc-memcached/src/main/java/org/apache/dubbo/rpc/protocol/memcached/MemcachedProtocol.java index 8fa088bb95f..2633e961d85 100644 --- a/dubbo-rpc/dubbo-rpc-memcached/src/main/java/org/apache/dubbo/rpc/protocol/memcached/MemcachedProtocol.java +++ b/dubbo-rpc/dubbo-rpc-memcached/src/main/java/org/apache/dubbo/rpc/protocol/memcached/MemcachedProtocol.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.rpc.protocol.memcached; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.rpc.Exporter; import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.Invoker; @@ -59,7 +59,7 @@ public Exporter export(final Invoker invoker) throws RpcException { public Invoker refer(final Class type, final URL url) throws RpcException { try { String address = url.getAddress(); - String backup = url.getParameter(Constants.BACKUP_KEY); + String backup = url.getParameter(RemotingConstants.BACKUP_KEY); if (backup != null && backup.length() > 0) { address += "," + backup; } diff --git a/dubbo-rpc/dubbo-rpc-redis/src/main/java/org/apache/dubbo/rpc/protocol/redis/RedisProtocol.java b/dubbo-rpc/dubbo-rpc-redis/src/main/java/org/apache/dubbo/rpc/protocol/redis/RedisProtocol.java index ba35c298ec4..f93b4447920 100644 --- a/dubbo-rpc/dubbo-rpc-redis/src/main/java/org/apache/dubbo/rpc/protocol/redis/RedisProtocol.java +++ b/dubbo-rpc/dubbo-rpc-redis/src/main/java/org/apache/dubbo/rpc/protocol/redis/RedisProtocol.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; @@ -64,7 +65,7 @@ public Exporter export(final Invoker invoker) throws RpcException { } private Serialization getSerialization(URL url) { - return ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(url.getParameter(Constants.SERIALIZATION_KEY, "java")); + return ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(url.getParameter(RemotingConstants.SERIALIZATION_KEY, "java")); } @Override diff --git a/dubbo-rpc/dubbo-rpc-redis/src/test/java/org/apache/dubbo/rpc/protocol/redis/RedisProtocolTest.java b/dubbo-rpc/dubbo-rpc-redis/src/test/java/org/apache/dubbo/rpc/protocol/redis/RedisProtocolTest.java index 9abada0a49e..f42cc821b87 100644 --- a/dubbo-rpc/dubbo-rpc-redis/src/test/java/org/apache/dubbo/rpc/protocol/redis/RedisProtocolTest.java +++ b/dubbo-rpc/dubbo-rpc-redis/src/test/java/org/apache/dubbo/rpc/protocol/redis/RedisProtocolTest.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.rpc.protocol.redis; -import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.Serialization; @@ -177,7 +177,7 @@ public void testAuthRedis() { JedisPool pool = new JedisPool(new GenericObjectPoolConfig(), "localhost", registryUrl.getPort(), 2000, password, database, (String) null); try (Jedis jedis = pool.getResource()) { byte[] valueByte = jedis.get("key".getBytes()); - Serialization serialization = ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(this.registryUrl.getParameter(Constants.SERIALIZATION_KEY, "java")); + Serialization serialization = ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(this.registryUrl.getParameter(RemotingConstants.SERIALIZATION_KEY, "java")); ObjectInput oin = serialization.deserialize(this.registryUrl, new ByteArrayInputStream(valueByte)); String actual = (String) oin.readObject(); assertThat(value, is(actual)); diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/NettyServer.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/NettyServer.java index 7ee4a8f8641..d8380f54b8c 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/NettyServer.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/NettyServer.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.NetUtils; import io.netty.channel.ChannelOption; @@ -37,17 +38,17 @@ public class NettyServer extends BaseRestServer { @Override protected void doStart(URL url) { - String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost()); + String bindIp = url.getParameter(RemotingConstants.BIND_IP_KEY, url.getHost()); if (!url.isAnyHost() && NetUtils.isValidLocalHost(bindIp)) { server.setHostname(bindIp); } - server.setPort(url.getParameter(Constants.BIND_PORT_KEY, url.getPort())); + server.setPort(url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort())); Map channelOption = new HashMap(); channelOption.put(ChannelOption.SO_KEEPALIVE, url.getParameter(Constants.KEEP_ALIVE_KEY, Constants.DEFAULT_KEEP_ALIVE)); server.setChildChannelOptions(channelOption); server.setExecutorThreadCount(url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS)); - server.setIoWorkerCount(url.getParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS)); - server.setMaxRequestSize(url.getParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD)); + server.setIoWorkerCount(url.getParameter(Constants.IO_THREADS_KEY, RemotingConstants.DEFAULT_IO_THREADS)); + server.setMaxRequestSize(url.getParameter(RemotingConstants.PAYLOAD_KEY, RemotingConstants.DEFAULT_PAYLOAD)); server.start(); } diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java index 6265254d4c6..4934ca50ba6 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.StringUtils; import org.apache.dubbo.remoting.http.HttpBinder; import org.apache.dubbo.remoting.http.servlet.BootstrapListener; @@ -89,13 +90,13 @@ protected Runnable doExport(T impl, Class type, URL url) throws RpcExcept String addr = getAddr(url); Class implClass = ApplicationModel.getProviderModel(url.getPathKey()).getServiceInstance().getClass(); RestServer server = servers.computeIfAbsent(addr, restServer -> { - RestServer s = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, DEFAULT_SERVER)); + RestServer s = serverFactory.createServer(url.getParameter(RemotingConstants.SERVER_KEY, DEFAULT_SERVER)); s.start(url); return s; }); String contextPath = getContextPath(url); - if ("servlet".equalsIgnoreCase(url.getParameter(Constants.SERVER_KEY, DEFAULT_SERVER))) { + if ("servlet".equalsIgnoreCase(url.getParameter(RemotingConstants.SERVER_KEY, DEFAULT_SERVER))) { ServletContext servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT); if (servletContext == null) { throw new RpcException("No servlet context found. Since you are using server='servlet', " + @@ -142,7 +143,7 @@ protected T doRefer(Class serviceType, URL url) throws RpcException { } connectionMonitor.addConnectionManager(connectionManager); RequestConfig requestConfig = RequestConfig.custom() - .setConnectTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT)) + .setConnectTimeout(url.getParameter(RemotingConstants.CONNECT_TIMEOUT_KEY, RemotingConstants.DEFAULT_CONNECT_TIMEOUT)) .setSocketTimeout(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT)) .build(); diff --git a/dubbo-rpc/dubbo-rpc-rest/src/test/java/org/apache/dubbo/rpc/protocol/rest/RestProtocolTest.java b/dubbo-rpc/dubbo-rpc-rest/src/test/java/org/apache/dubbo/rpc/protocol/rest/RestProtocolTest.java index d1d3295d7cb..aa850301427 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/test/java/org/apache/dubbo/rpc/protocol/rest/RestProtocolTest.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/test/java/org/apache/dubbo/rpc/protocol/rest/RestProtocolTest.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.rpc.Exporter; @@ -112,7 +113,7 @@ public void testNettyServer() { ProviderModel providerModel = new ProviderModel(exportUrl.getServiceKey(), server, DemoService.class); ApplicationModel.initProviderModel(exportUrl.getServiceKey(), providerModel); - URL nettyUrl = exportUrl.addParameter(Constants.SERVER_KEY, "netty"); + URL nettyUrl = exportUrl.addParameter(RemotingConstants.SERVER_KEY, "netty"); Exporter exporter = protocol.export(proxy.getInvoker(new DemoServiceImpl(), DemoService.class, nettyUrl)); DemoService demoService = this.proxy.getProxy(protocol.refer(DemoService.class, nettyUrl)); @@ -130,7 +131,7 @@ public void testServletWithoutWebConfig() { ProviderModel providerModel = new ProviderModel(exportUrl.getServiceKey(), server, DemoService.class); ApplicationModel.initProviderModel(exportUrl.getPathKey(), providerModel); - URL servletUrl = exportUrl.addParameter(Constants.SERVER_KEY, "servlet"); + URL servletUrl = exportUrl.addParameter(RemotingConstants.SERVER_KEY, "servlet"); protocol.export(proxy.getInvoker(server, DemoService.class, servletUrl)); }); @@ -143,7 +144,7 @@ public void testErrorHandler() { ProviderModel providerModel = new ProviderModel(exportUrl.getServiceKey(), server, DemoService.class); ApplicationModel.initProviderModel(exportUrl.getServiceKey(), providerModel); - URL nettyUrl = exportUrl.addParameter(Constants.SERVER_KEY, "netty"); + URL nettyUrl = exportUrl.addParameter(RemotingConstants.SERVER_KEY, "netty"); Exporter exporter = protocol.export(proxy.getInvoker(server, DemoService.class, nettyUrl)); DemoService demoService = this.proxy.getProxy(protocol.refer(DemoService.class, nettyUrl)); @@ -173,7 +174,7 @@ public void testFilter() { ProviderModel providerModel = new ProviderModel(exportUrl.getServiceKey(), server, DemoService.class); ApplicationModel.initProviderModel(exportUrl.getServiceKey(), providerModel); - URL nettyUrl = exportUrl.addParameter(Constants.SERVER_KEY, "netty") + URL nettyUrl = exportUrl.addParameter(RemotingConstants.SERVER_KEY, "netty") .addParameter(Constants.EXTENSION_KEY, "org.apache.dubbo.rpc.protocol.rest.support.LoggingFilter"); Exporter exporter = protocol.export(proxy.getInvoker(server, DemoService.class, nettyUrl)); @@ -193,7 +194,7 @@ public void testRpcContextFilter() { ApplicationModel.initProviderModel(exportUrl.getServiceKey(), providerModel); // use RpcContextFilter - URL nettyUrl = exportUrl.addParameter(Constants.SERVER_KEY, "netty") + URL nettyUrl = exportUrl.addParameter(RemotingConstants.SERVER_KEY, "netty") .addParameter(Constants.EXTENSION_KEY, "org.apache.dubbo.rpc.protocol.rest.RpcContextFilter"); Exporter exporter = protocol.export(proxy.getInvoker(server, DemoService.class, nettyUrl)); diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftInvoker.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftInvoker.java index fa123e232a5..a6aeba1ebed 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftInvoker.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftInvoker.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.utils.AtomicPositiveInteger; import org.apache.dubbo.remoting.RemotingException; import org.apache.dubbo.remoting.TimeoutException; @@ -106,7 +107,7 @@ public boolean isAvailable() { for (ExchangeClient client : clients) { if (client.isConnected() - && !client.hasAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY)) { + && !client.hasAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY)) { //cannot write == not Available ? return true; } diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java index 055af6f8bb3..ec6370938c4 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/ThriftProtocol.java @@ -19,6 +19,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.ConfigurationUtils; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.common.extension.ExtensionLoader; import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.RemotingException; @@ -116,7 +117,7 @@ public int getDefaultPort() { public Exporter export(Invoker invoker) throws RpcException { // can use thrift codec only - URL url = invoker.getUrl().addParameter(Constants.CODEC_KEY, ThriftCodec.NAME); + URL url = invoker.getUrl().addParameter(RemotingConstants.CODEC_KEY, ThriftCodec.NAME); // find server. String key = url.getAddress(); // client can expose a service for server to invoke only. @@ -183,7 +184,7 @@ private ExchangeClient initClient(URL url) { ExchangeClient client; - url = url.addParameter(Constants.CODEC_KEY, ThriftCodec.NAME); + url = url.addParameter(RemotingConstants.CODEC_KEY, ThriftCodec.NAME); try { client = Exchangers.connect(url); @@ -198,8 +199,8 @@ private ExchangeClient initClient(URL url) { private ExchangeServer getServer(URL url) { // enable sending readonly event when server closes by default - url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString()); - String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER); + url = url.addParameterIfAbsent(RemotingConstants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString()); + String str = url.getParameter(RemotingConstants.SERVER_KEY, RemotingConstants.DEFAULT_REMOTING_SERVER); if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) { throw new RpcException("Unsupported server type: " + str + ", url: " + url); @@ -211,7 +212,7 @@ private ExchangeServer getServer(URL url) { } catch (RemotingException e) { throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e); } - str = url.getParameter(Constants.CLIENT_KEY); + str = url.getParameter(RemotingConstants.CLIENT_KEY); if (str != null && str.length() > 0) { Set supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions(); if (!supportedTypes.contains(str)) { diff --git a/dubbo-rpc/dubbo-rpc-webservice/src/main/java/org/apache/dubbo/rpc/protocol/webservice/WebServiceProtocol.java b/dubbo-rpc/dubbo-rpc-webservice/src/main/java/org/apache/dubbo/rpc/protocol/webservice/WebServiceProtocol.java index ddb270def40..62215aa6d27 100644 --- a/dubbo-rpc/dubbo-rpc-webservice/src/main/java/org/apache/dubbo/rpc/protocol/webservice/WebServiceProtocol.java +++ b/dubbo-rpc/dubbo-rpc-webservice/src/main/java/org/apache/dubbo/rpc/protocol/webservice/WebServiceProtocol.java @@ -18,6 +18,7 @@ import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.constants.RemotingConstants; import org.apache.dubbo.remoting.http.HttpBinder; import org.apache.dubbo.remoting.http.HttpHandler; import org.apache.dubbo.remoting.http.HttpServer; @@ -116,7 +117,7 @@ protected T doRefer(final Class serviceType, final URL url) throws RpcExc Client proxy = ClientProxy.getClient(ref); HTTPConduit conduit = (HTTPConduit) proxy.getConduit(); HTTPClientPolicy policy = new HTTPClientPolicy(); - policy.setConnectionTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT)); + policy.setConnectionTimeout(url.getParameter(RemotingConstants.CONNECT_TIMEOUT_KEY, RemotingConstants.DEFAULT_CONNECT_TIMEOUT)); policy.setReceiveTimeout(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT)); conduit.setClient(policy); return ref; From a1e5c8e76d30e1a8ed7e43c87a94077d0b87c9a8 Mon Sep 17 00:00:00 2001 From: jimin Date: Sun, 12 May 2019 10:35:27 +0800 Subject: [PATCH 2/4] optimize some code style (#4006) * optimize constant naming style * optimize some code style Signed-off-by: jimin.jm --- .../java/org/apache/dubbo/common/utils/NetUtils.java | 10 +++++----- .../dubbo/metadata/support/AbstractMetadataReport.java | 4 ++-- .../org/apache/dubbo/monitor/dubbo/MetricsFilter.java | 3 ++- .../java/org/apache/dubbo/qos/command/impl/Ls.java | 4 ++-- .../dubbo/registry/integration/RegistryProtocol.java | 10 +++++----- .../dubbo/registry/nacos/NacosRegistryFactory.java | 1 + .../dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java | 4 +++- .../org/apache/dubbo/rpc/filter/ActiveLimitFilter.java | 6 +++--- .../common/serialize/gson/GsonJsonObjectInput.java | 4 +++- 9 files changed, 26 insertions(+), 20 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java index e5b85ecd577..828a97e7d36 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java @@ -428,7 +428,7 @@ public static boolean matchIpRange(String pattern, String host, int port) throws host = inetAddress.getHostAddress(); - String[] ip_address = host.split(splitCharacter); + String[] ipAddress = host.split(splitCharacter); if (pattern.equals(host)) { return true; } @@ -442,7 +442,7 @@ public static boolean matchIpRange(String pattern, String host, int port) throws } } for (int i = 0; i < mask.length; i++) { - if (mask[i].equals("*") || mask[i].equals(ip_address[i])) { + if (mask[i].equals("*") || mask[i].equals(ipAddress[i])) { continue; } else if (mask[i].contains("-")) { String[] rangeNumStrs = mask[i].split("-"); @@ -451,13 +451,13 @@ public static boolean matchIpRange(String pattern, String host, int port) throws } Integer min = getNumOfIpSegment(rangeNumStrs[0], isIpv4); Integer max = getNumOfIpSegment(rangeNumStrs[1], isIpv4); - Integer ip = getNumOfIpSegment(ip_address[i], isIpv4); + Integer ip = getNumOfIpSegment(ipAddress[i], isIpv4); if (ip < min || ip > max) { return false; } - } else if ("0".equals(ip_address[i]) && ("0".equals(mask[i]) || "00".equals(mask[i]) || "000".equals(mask[i]) || "0000".equals(mask[i]))) { + } else if ("0".equals(ipAddress[i]) && ("0".equals(mask[i]) || "00".equals(mask[i]) || "000".equals(mask[i]) || "0000".equals(mask[i]))) { continue; - } else if (!mask[i].equals(ip_address[i])) { + } else if (!mask[i].equals(ipAddress[i])) { return false; } } diff --git a/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/support/AbstractMetadataReport.java b/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/support/AbstractMetadataReport.java index 16daa2eeb50..49b4b8f7dcc 100644 --- a/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/support/AbstractMetadataReport.java +++ b/dubbo-metadata-report/dubbo-metadata-report-api/src/main/java/org/apache/dubbo/metadata/support/AbstractMetadataReport.java @@ -74,7 +74,7 @@ public abstract class AbstractMetadataReport implements MetadataReport { boolean syncReport; // Local disk cache file File file; - private AtomicBoolean INIT = new AtomicBoolean(false); + private AtomicBoolean initialized = new AtomicBoolean(false); public MetadataReportRetry metadataReportRetry; public AbstractMetadataReport(URL reportServerURL) { @@ -90,7 +90,7 @@ public AbstractMetadataReport(URL reportServerURL) { } } // if this file exist, firstly delete it. - if (!INIT.getAndSet(true) && file.exists()) { + if (!initialized.getAndSet(true) && file.exists()) { file.delete(); } } diff --git a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java index a05c510de71..52bec170f4e 100644 --- a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java +++ b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/MetricsFilter.java @@ -186,8 +186,9 @@ private List getThreadPoolMessage() { } private MetricObject value2MetricObject(String metric, Integer value, MetricLevel level) { - if (metric == null || value == null || level == null) + if (metric == null || value == null || level == null) { return null; + } return new MetricObject .Builder(metric) diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java index 4777727c59a..469a40a3391 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/Ls.java @@ -45,7 +45,7 @@ public String execute(CommandContext commandContext, String[] args) { public String listProvider() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("As Provider side:" + System.lineSeparator()); - Collection ProviderModelList = ApplicationModel.allProviderModels(); + Collection providerModelList = ApplicationModel.allProviderModels(); TTable tTable = new TTable(new TTable.ColumnDefine[]{ new TTable.ColumnDefine(TTable.Align.MIDDLE), @@ -56,7 +56,7 @@ public String listProvider() { tTable.addRow("Provider Service Name", "PUB"); //Content - for (ProviderModel providerModel : ProviderModelList) { + for (ProviderModel providerModel : providerModelList) { tTable.addRow(providerModel.getServiceName(), isRegistered(providerModel.getServiceName()) ? "Y" : "N"); } stringBuilder.append(tTable.rendering()); 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 b1b3393b1cf..c70be0b92ce 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 @@ -295,18 +295,18 @@ private URL getRegisteredProviderUrl(final URL providerUrl, final URL registryUr MONITOR_KEY, BIND_IP_KEY, BIND_PORT_KEY, QOS_ENABLE, QOS_PORT, ACCEPT_FOREIGN_IP, VALIDATION_KEY, INTERFACES); } else { - String extra_keys = registryUrl.getParameter(EXTRA_KEYS_KEY, ""); + String extraKeys = registryUrl.getParameter(EXTRA_KEYS_KEY, ""); // if path is not the same as interface name then we should keep INTERFACE_KEY, // otherwise, the registry structure of zookeeper would be '/dubbo/path/providers', // but what we expect is '/dubbo/interface/providers' if (!providerUrl.getPath().equals(providerUrl.getParameter(Constants.INTERFACE_KEY))) { - if (StringUtils.isNotEmpty(extra_keys)) { - extra_keys += ","; + if (StringUtils.isNotEmpty(extraKeys)) { + extraKeys += ","; } - extra_keys += Constants.INTERFACE_KEY; + extraKeys += Constants.INTERFACE_KEY; } String[] paramsToRegistry = getParamsToRegistry(DEFAULT_REGISTER_PROVIDER_KEYS - , Constants.COMMA_SPLIT_PATTERN.split(extra_keys)); + , Constants.COMMA_SPLIT_PATTERN.split(extraKeys)); return URL.valueOf(providerUrl, paramsToRegistry, providerUrl.getParameter(METHODS_KEY, (String[]) null)); } diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java index d0e508d4533..2b66fb1e95b 100644 --- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java @@ -48,6 +48,7 @@ public class NacosRegistryFactory extends AbstractRegistryFactory { private final Logger logger = LoggerFactory.getLogger(getClass()); + @Override protected Registry createRegistry(URL url) { return new NacosRegistry(url, buildNamingService(url)); } diff --git a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java index c27fb56b07d..01bf17d264d 100644 --- a/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java +++ b/dubbo-remoting/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java @@ -186,7 +186,9 @@ public List getChildren(String path) { int index = len, count = 0; if (key.length() > len) { for (; (index = key.indexOf(Constants.PATH_SEPARATOR, index)) != -1; ++index) { - if (count++ > 1) break; + if (count++ > 1) { + break; + } } } return count == 1; diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java index 1c2f69fecb9..926fd019425 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java @@ -47,12 +47,12 @@ public Result invoke(Invoker invoker, Invocation invocation) throws RpcExcept String methodName = invocation.getMethodName(); int max = invoker.getUrl().getMethodParameter(methodName, Constants.ACTIVES_KEY, 0); RpcStatus count = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()); - if (!count.beginCount(url, methodName, max)) { + if (!RpcStatus.beginCount(url, methodName, max)) { long timeout = invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.TIMEOUT_KEY, 0); long start = System.currentTimeMillis(); long remain = timeout; synchronized (count) { - while (!count.beginCount(url, methodName, max)) { + while (!RpcStatus.beginCount(url, methodName, max)) { try { count.wait(remain); } catch (InterruptedException e) { @@ -79,7 +79,7 @@ public Result invoke(Invoker invoker, Invocation invocation) throws RpcExcept isSuccess = false; throw t; } finally { - count.endCount(url, methodName, System.currentTimeMillis() - begin, isSuccess); + RpcStatus.endCount(url, methodName, System.currentTimeMillis() - begin, isSuccess); if (max > 0) { synchronized (count) { count.notifyAll(); diff --git a/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonJsonObjectInput.java b/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonJsonObjectInput.java index 94014f2d4a8..056d719dd28 100644 --- a/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonJsonObjectInput.java +++ b/dubbo-serialization/dubbo-serialization-gson/src/main/java/org/apache/dubbo/common/serialize/gson/GsonJsonObjectInput.java @@ -107,7 +107,9 @@ public T readObject(Class cls, Type type) throws IOException, ClassNotFou private String readLine() throws IOException { String line = reader.readLine(); - if (line == null || line.trim().length() == 0) throw new EOFException(); + if (line == null || line.trim().length() == 0) { + throw new EOFException(); + } return line; } From 309b69432800cf5ecb342fef8f6484c849739bd6 Mon Sep 17 00:00:00 2001 From: jimin Date: Sun, 12 May 2019 10:44:08 +0800 Subject: [PATCH 3/4] optimize array code style (#4031) Signed-off-by: jimin.jm --- .../apache/dubbo/common/io/StreamUtils.java | 2 +- .../common/io/UnsafeByteArrayInputStream.java | 10 ++-- .../io/UnsafeByteArrayOutputStream.java | 4 +- .../common/json/GenericJSONConverter.java | 2 +- .../apache/dubbo/common/json/J2oVisitor.java | 2 +- .../org/apache/dubbo/common/json/Yylex.java | 10 ++-- .../support/AbortPolicyWithReport.java | 49 ++++++++++++------- .../support/command/LogTelnetHandler.java | 2 +- .../remoting/transport/AbstractCodec.java | 33 +++++++------ .../dubbo/telnet/LogTelnetHandler.java | 2 +- .../io/RandomAccessByteArrayOutputStream.java | 4 +- 11 files changed, 69 insertions(+), 51 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/io/StreamUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/io/StreamUtils.java index 2a463c3e098..ab2836ef913 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/io/StreamUtils.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/io/StreamUtils.java @@ -40,7 +40,7 @@ public int read() throws IOException { } @Override - public int read(byte b[], int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/io/UnsafeByteArrayInputStream.java b/dubbo-common/src/main/java/org/apache/dubbo/common/io/UnsafeByteArrayInputStream.java index c5b72bdc199..df96a1c1d01 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/io/UnsafeByteArrayInputStream.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/io/UnsafeByteArrayInputStream.java @@ -23,19 +23,19 @@ * UnsafeByteArrayInputStream. */ public class UnsafeByteArrayInputStream extends InputStream { - protected byte mData[]; + protected byte[] mData; protected int mPosition, mLimit, mMark = 0; - public UnsafeByteArrayInputStream(byte buf[]) { + public UnsafeByteArrayInputStream(byte[] buf) { this(buf, 0, buf.length); } - public UnsafeByteArrayInputStream(byte buf[], int offset) { + public UnsafeByteArrayInputStream(byte[] buf, int offset) { this(buf, offset, buf.length - offset); } - public UnsafeByteArrayInputStream(byte buf[], int offset, int length) { + public UnsafeByteArrayInputStream(byte[] buf, int offset, int length) { mData = buf; mPosition = mMark = offset; mLimit = Math.min(offset + length, buf.length); @@ -47,7 +47,7 @@ public int read() { } @Override - public int read(byte b[], int off, int len) { + public int read(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/io/UnsafeByteArrayOutputStream.java b/dubbo-common/src/main/java/org/apache/dubbo/common/io/UnsafeByteArrayOutputStream.java index 1ac43c893dd..6e75eb83109 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/io/UnsafeByteArrayOutputStream.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/io/UnsafeByteArrayOutputStream.java @@ -25,7 +25,7 @@ * UnsafeByteArrayOutputStream. */ public class UnsafeByteArrayOutputStream extends OutputStream { - protected byte mBuffer[]; + protected byte[] mBuffer; protected int mCount; @@ -51,7 +51,7 @@ public void write(int b) { } @Override - public void write(byte b[], int off, int len) { + public void write(byte[] b, int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/json/GenericJSONConverter.java b/dubbo-common/src/main/java/org/apache/dubbo/common/json/GenericJSONConverter.java index 74cf09a142b..9082eb155cb 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/json/GenericJSONConverter.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/json/GenericJSONConverter.java @@ -474,7 +474,7 @@ public void writeValue(Object obj, JSONWriter jb, boolean writeClass) throws IOE jb.objectBegin(); Wrapper w = Wrapper.getWrapper(c); - String pns[] = w.getPropertyNames(); + String[] pns = w.getPropertyNames(); for (String pn : pns) { if ((obj instanceof Throwable) && ( diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/json/J2oVisitor.java b/dubbo-common/src/main/java/org/apache/dubbo/common/json/J2oVisitor.java index fdcf674c590..3aa3fd9ed1c 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/json/J2oVisitor.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/json/J2oVisitor.java @@ -83,7 +83,7 @@ private static Object toArray(Class c, Stack list, int len) throws Pa return EMPTY_STRING_ARRAY; } else { Object o; - String ss[] = new String[len]; + String[] ss = new String[len]; for (int i = len - 1; i >= 0; i--) { o = list.pop(); ss[i] = (o == null ? null : o.toString()); diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/json/Yylex.java b/dubbo-common/src/main/java/org/apache/dubbo/common/json/Yylex.java index 822175e6031..32a73a7589e 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/json/Yylex.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/json/Yylex.java @@ -45,7 +45,7 @@ public class Yylex { * at the beginning of a line * l is of the form l = 2*k, k a non negative integer */ - private static final int ZZ_LEXSTATE[] = { + private static final int[] ZZ_LEXSTATE = { 0, 0, 1, 1, 2, 2 }; @@ -92,7 +92,7 @@ public class Yylex { /** * The transition table of the DFA */ - private static final int ZZ_TRANS[] = { + private static final int[] ZZ_TRANS = { 3, 4, 5, 5, 6, 3, 5, 3, 7, 8, 3, 9, 3, 5, 10, 11, 5, 12, 5, 5, 13, 5, 5, 5, 5, 5, 14, 5, 5, 5, @@ -247,7 +247,7 @@ public class Yylex { private static final int ZZ_NO_MATCH = 1; private static final int ZZ_PUSHBACK_2BIG = 2; /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { + private static final String[] ZZ_ERROR_MSG = { "Unkown internal scanner error", "Error: could not match input", "Error: pushback value was too large" @@ -276,7 +276,7 @@ public class Yylex { * this buffer contains the current text to be matched and is * the source of the yytext() string */ - private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + private char[] zzBuffer = new char[ZZ_BUFFERSIZE]; /** * the textposition at the last accepting state */ @@ -447,7 +447,7 @@ private boolean zzRefill() throws java.io.IOException { /* is the buffer big enough? */ if (zzCurrentPos >= zzBuffer.length) { /* if not: blow it up */ - char newBuffer[] = new char[zzCurrentPos * 2]; + char[] newBuffer = new char[zzCurrentPos * 2]; System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); zzBuffer = newBuffer; } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReport.java b/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReport.java index 8a137613f17..cb368db895c 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReport.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReport.java @@ -16,21 +16,21 @@ */ package org.apache.dubbo.common.threadpool.support; -import org.apache.dubbo.common.Constants; -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.logger.Logger; -import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.common.utils.JVMUtil; - import java.io.File; import java.io.FileOutputStream; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.ExecutorService; + +import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.logger.Logger; +import org.apache.dubbo.common.logger.LoggerFactory; +import org.apache.dubbo.common.utils.JVMUtil; /** * Abort Policy. @@ -46,6 +46,16 @@ public class AbortPolicyWithReport extends ThreadPoolExecutor.AbortPolicy { private static volatile long lastPrintTime = 0; + private static final long TEN_MINUTES_MILLS = 10 * 60 * 1000; + + private static final String OS_WIN_PREFIX = "win"; + + private static final String OS_NAME_KEY = "os.name"; + + private static final String WIN_DATETIME_FORMAT = "yyyy-MM-dd_HH-mm-ss"; + + private static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd_HH:mm:ss"; + private static Semaphore guard = new Semaphore(1); public AbortPolicyWithReport(String threadName, URL url) { @@ -56,11 +66,13 @@ public AbortPolicyWithReport(String threadName, URL url) { @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { String msg = String.format("Thread pool is EXHAUSTED!" + - " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," + - " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!", - threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(), - e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(), - url.getProtocol(), url.getIp(), url.getPort()); + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: " + + "%d)," + + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!", + threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), + e.getLargestPoolSize(), + e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(), + url.getProtocol(), url.getIp(), url.getPort()); logger.warn(msg); dumpJStack(); throw new RejectedExecutionException(msg); @@ -70,7 +82,7 @@ private void dumpJStack() { long now = System.currentTimeMillis(); //dump every 10 minutes - if (now - lastPrintTime < 10 * 60 * 1000) { + if (now - lastPrintTime < TEN_MINUTES_MILLS) { return; } @@ -84,18 +96,19 @@ private void dumpJStack() { SimpleDateFormat sdf; - String os = System.getProperty("os.name").toLowerCase(); + String os = System.getProperty(OS_NAME_KEY).toLowerCase(); // window system don't support ":" in file name - if (os.contains("win")) { - sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); + if (os.contains(OS_WIN_PREFIX)) { + sdf = new SimpleDateFormat(WIN_DATETIME_FORMAT); } else { - sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); + sdf = new SimpleDateFormat(DEFAULT_DATETIME_FORMAT); } String dateStr = sdf.format(new Date()); //try-with-resources - try (FileOutputStream jStackStream = new FileOutputStream(new File(dumpPath, "Dubbo_JStack.log" + "." + dateStr))) { + try (FileOutputStream jStackStream = new FileOutputStream( + new File(dumpPath, "Dubbo_JStack.log" + "." + dateStr))) { JVMUtil.jstack(jStackStream); } catch (Throwable t) { logger.error("dump jStack error", t); diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/command/LogTelnetHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/command/LogTelnetHandler.java index db531dc626f..2d39c23b73b 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/command/LogTelnetHandler.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/command/LogTelnetHandler.java @@ -48,7 +48,7 @@ public String telnet(Channel channel, String message) { if (message == null || message.trim().length() == 0) { buf.append("EXAMPLE: log error / log 100"); } else { - String str[] = message.split(" "); + String[] str = message.split(" "); if (!StringUtils.isInteger(str[0])) { LoggerFactory.setLevel(Level.valueOf(message.toUpperCase())); } else { diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractCodec.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractCodec.java index 346f54ca320..e5f76964370 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractCodec.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractCodec.java @@ -16,6 +16,9 @@ */ package org.apache.dubbo.remoting.transport; +import java.io.IOException; +import java.net.InetSocketAddress; + import org.apache.dubbo.common.Constants; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.constants.RemotingConstants; @@ -26,9 +29,6 @@ import org.apache.dubbo.remoting.Channel; import org.apache.dubbo.remoting.Codec2; -import java.io.IOException; -import java.net.InetSocketAddress; - /** * AbstractCodec */ @@ -36,13 +36,18 @@ public abstract class AbstractCodec implements Codec2 { private static final Logger logger = LoggerFactory.getLogger(AbstractCodec.class); + private static final String CLIENT_SIDE = "client"; + + private static final String SERVER_SIDE = "server"; + protected static void checkPayload(Channel channel, long size) throws IOException { int payload = RemotingConstants.DEFAULT_PAYLOAD; if (channel != null && channel.getUrl() != null) { payload = channel.getUrl().getParameter(RemotingConstants.PAYLOAD_KEY, RemotingConstants.DEFAULT_PAYLOAD); } if (payload > 0 && size > payload) { - ExceedPayloadLimitException e = new ExceedPayloadLimitException("Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel); + ExceedPayloadLimitException e = new ExceedPayloadLimitException( + "Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel); logger.error(e); throw e; } @@ -53,21 +58,21 @@ protected Serialization getSerialization(Channel channel) { } protected boolean isClientSide(Channel channel) { - String side = (String) channel.getAttribute(Constants.SIDE_KEY); - if ("client".equals(side)) { + String side = (String)channel.getAttribute(Constants.SIDE_KEY); + if (CLIENT_SIDE.equals(side)) { return true; - } else if ("server".equals(side)) { + } else if (SERVER_SIDE.equals(side)) { return false; } else { InetSocketAddress address = channel.getRemoteAddress(); URL url = channel.getUrl(); - boolean client = url.getPort() == address.getPort() - && NetUtils.filterLocalHost(url.getIp()).equals( - NetUtils.filterLocalHost(address.getAddress() - .getHostAddress())); - channel.setAttribute(Constants.SIDE_KEY, client ? "client" - : "server"); - return client; + boolean isClient = url.getPort() == address.getPort() + && NetUtils.filterLocalHost(url.getIp()).equals( + NetUtils.filterLocalHost(address.getAddress() + .getHostAddress())); + channel.setAttribute(Constants.SIDE_KEY, isClient ? CLIENT_SIDE + : SERVER_SIDE); + return isClient; } } diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java index b62198d11d4..86bcd9b26a8 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java @@ -48,7 +48,7 @@ public String telnet(Channel channel, String message) { if (message == null || message.trim().length() == 0) { buf.append("EXAMPLE: log error / log 100"); } else { - String str[] = message.split(" "); + String[] str = message.split(" "); if (!StringUtils.isInteger(str[0])) { LoggerFactory.setLevel(Level.valueOf(message.toUpperCase())); } else { diff --git a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/io/RandomAccessByteArrayOutputStream.java b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/io/RandomAccessByteArrayOutputStream.java index a5d0d119370..660dd8031db 100644 --- a/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/io/RandomAccessByteArrayOutputStream.java +++ b/dubbo-rpc/dubbo-rpc-thrift/src/main/java/org/apache/dubbo/rpc/protocol/thrift/io/RandomAccessByteArrayOutputStream.java @@ -25,7 +25,7 @@ @Deprecated public class RandomAccessByteArrayOutputStream extends OutputStream { - protected byte buffer[]; + protected byte[] buffer; protected int count; @@ -54,7 +54,7 @@ public void write(int b) { } @Override - public void write(byte b[], int off, int len) { + public void write(byte[] b, int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); From 6a3f4c75bd99a50e23d447174170c5867c17821f Mon Sep 17 00:00:00 2001 From: Taosheng Wei Date: Sun, 12 May 2019 10:47:31 +0800 Subject: [PATCH 4/4] use equal explicit class to replace anonymous class (#4027) --- .../rpc/cluster/support/AvailableCluster.java | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AvailableCluster.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AvailableCluster.java index 85e91e0527f..a2e353b4e4c 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AvailableCluster.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AvailableCluster.java @@ -16,15 +16,10 @@ */ package org.apache.dubbo.rpc.cluster.support; -import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.Invoker; -import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.cluster.Cluster; import org.apache.dubbo.rpc.cluster.Directory; -import org.apache.dubbo.rpc.cluster.LoadBalance; - -import java.util.List; /** * AvailableCluster @@ -36,19 +31,7 @@ public class AvailableCluster implements Cluster { @Override public Invoker join(Directory directory) throws RpcException { - - return new AbstractClusterInvoker(directory) { - @Override - public Result doInvoke(Invocation invocation, List> invokers, LoadBalance loadbalance) throws RpcException { - for (Invoker invoker : invokers) { - if (invoker.isAvailable()) { - return invoker.invoke(invocation); - } - } - throw new RpcException("No provider available in " + invokers); - } - }; - + return new AvailableClusterInvoker<>(directory); } }