This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 4fe06ec Refer to constants instead of literals (#7688)
4fe06ec is described below
commit 4fe06ec2929c3f782be7ab81a1e329ecf7c0839d
Author: 灼华 <[email protected]>
AuthorDate: Tue May 11 10:52:54 2021 +0800
Refer to constants instead of literals (#7688)
* Refer to constants instead of literals
* Refer to constants instead of literals
* Remove duplicate and unused constant
* Refer to constants instead of literals
* Fix check style
* Fix check style
---
.../org/apache/dubbo/rpc/cluster/RouterChain.java | 4 +++-
.../dubbo/common/constants/RegistryConstants.java | 2 --
.../listener/ServiceInstancesChangedListener.java | 3 ++-
.../remoting/transport/netty4/NettyClient.java | 24 +++++++++++-----------
4 files changed, 17 insertions(+), 16 deletions(-)
diff --git
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
index e340e3d..ba0e331 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
@@ -27,6 +27,8 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
+import static org.apache.dubbo.rpc.cluster.Constants.ROUTER_KEY;
+
/**
* Router chain
*/
@@ -48,7 +50,7 @@ public class RouterChain<T> {
private RouterChain(URL url) {
List<RouterFactory> extensionFactories =
ExtensionLoader.getExtensionLoader(RouterFactory.class)
- .getActivateExtension(url, "router");
+ .getActivateExtension(url, ROUTER_KEY);
List<Router> routers = extensionFactories.stream()
.map(factory -> factory.getRouter(url))
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 2e4ffa9..44d3c3a 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
@@ -23,8 +23,6 @@ public interface RegistryConstants {
String REGISTRY_CLUSTER_KEY = "REGISTRY_CLUSTER";
- String REGISTRY_CLUSTER = "REGISTRY_CLUSTER";
-
String REGISTRY_CLUSTER_TYPE_KEY = "registry-cluster-type";
String REGISTRY_PROTOCOL = "registry";
diff --git
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
index d40fd01..58f3334 100644
---
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
+++
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
@@ -49,6 +49,7 @@ import static
org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_
import static
org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_CLUSTER_KEY;
import static org.apache.dubbo.metadata.MetadataInfo.DEFAULT_REVISION;
import static
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getExportedServicesRevision;
+import static org.apache.dubbo.rpc.Constants.ID_KEY;
/**
* The Service Discovery Changed {@link EventListener Event Listener}
@@ -75,7 +76,7 @@ public class ServiceInstancesChangedListener implements
ConditionalEventListener
public ServiceInstancesChangedListener(Set<String> serviceNames,
ServiceDiscovery serviceDiscovery) {
this.serviceNames = serviceNames;
this.serviceDiscovery = serviceDiscovery;
- this.registryId = serviceDiscovery.getUrl().getParameter("id");
+ this.registryId = serviceDiscovery.getUrl().getParameter(ID_KEY);
this.listeners = new HashMap<>();
this.allInstances = new HashMap<>();
this.serviceUrls = new HashMap<>();
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 6f91cfd..174742f 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,6 +16,16 @@
*/
package org.apache.dubbo.remoting.transport.netty4;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.buffer.PooledByteBufAllocator;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.handler.proxy.Socks5ProxyHandler;
+import io.netty.handler.timeout.IdleStateHandler;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.logger.Logger;
@@ -28,21 +38,11 @@ import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.remoting.transport.AbstractClient;
import org.apache.dubbo.remoting.utils.UrlUtils;
-import io.netty.bootstrap.Bootstrap;
-import io.netty.buffer.PooledByteBufAllocator;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.handler.proxy.Socks5ProxyHandler;
-import io.netty.handler.timeout.IdleStateHandler;
-
import java.net.InetSocketAddress;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static
org.apache.dubbo.common.constants.CommonConstants.SSL_ENABLED_KEY;
+import static org.apache.dubbo.remoting.Constants.DEFAULT_CONNECT_TIMEOUT;
import static
org.apache.dubbo.remoting.transport.netty4.NettyEventLoopFactory.eventLoopGroup;
import static
org.apache.dubbo.remoting.transport.netty4.NettyEventLoopFactory.socketChannelClass;
@@ -98,7 +98,7 @@ public class NettyClient extends AbstractClient {
//.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, getTimeout())
.channel(socketChannelClass());
- bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, Math.max(3000,
getConnectTimeout()));
+ bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,
Math.max(DEFAULT_CONNECT_TIMEOUT, getConnectTimeout()));
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
@Override