This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch 3.0.5-release
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.0.5-release by this push:
     new c2b6303  Passing parameters down directly from Protocol to Remoting 
components. (#9453)
c2b6303 is described below

commit c2b630340404f3dee3d4292692ff3234ae7ca545
Author: ken.lj <[email protected]>
AuthorDate: Mon Dec 20 14:19:02 2021 +0800

    Passing parameters down directly from Protocol to Remoting components. 
(#9453)
    
    fixes #9440
---
 .../java/org/apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java   | 4 ++--
 .../dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java       | 7 +++++--
 .../dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java    | 8 +++++---
 3 files changed, 12 insertions(+), 7 deletions(-)

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 50110d7..eed8192 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
@@ -607,7 +607,7 @@ public class DubboProtocol extends AbstractProtocol {
      */
     private ReferenceCountExchangeClient buildReferenceCountExchangeClient(URL 
url) {
         ExchangeClient exchangeClient = initClient(url);
-        ReferenceCountExchangeClient client = new 
ReferenceCountExchangeClient(exchangeClient);
+        ReferenceCountExchangeClient client = new 
ReferenceCountExchangeClient(exchangeClient, DubboCodec.NAME);
         // read configs
         int shutdownTimeout = 
ConfigurationUtils.getServerShutdownTimeout(url.getScopeModel());
         client.setShutdownWaitTime(shutdownTimeout);
@@ -640,7 +640,7 @@ public class DubboProtocol extends AbstractProtocol {
         try {
             // connection should be lazy
             if (url.getParameter(LAZY_CONNECT_KEY, false)) {
-                client = new LazyConnectExchangeClient(url, requestHandler);
+                client = new LazyConnectExchangeClient(url, requestHandler, 
DubboCodec.NAME, url.getParameters());
 
             } else {
                 client = Exchangers.connect(url, requestHandler);
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 f31144a..a5bb837 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
@@ -29,6 +29,7 @@ import org.apache.dubbo.remoting.exchange.ExchangeHandler;
 import org.apache.dubbo.remoting.exchange.Exchangers;
 
 import java.net.InetSocketAddress;
+import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.atomic.AtomicLong;
@@ -60,9 +61,11 @@ final class LazyConnectExchangeClient implements 
ExchangeClient {
     private volatile ExchangeClient client;
     private final AtomicLong warningCount = new AtomicLong(0);
 
-    public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) {
+    public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler, 
String codec, Map<String, String> parameters) {
         // lazy connect, need set send.reconnect = true, to avoid channel bad 
status.
-        this.url = new ServiceConfigURL(url.getProtocol(), url.getUsername(), 
url.getPassword(), url.getHost(), url.getPort(), url.getPath(), 
url.getParameters())
+        // Parameters like 'username', 'password' and 'path' are set but will 
not be used in following processes.
+        // The most important parameters here are 'host', port', 'parameters' 
and 'codec', 'codec' can also be extracted from 'parameters'
+        this.url = new ServiceConfigURL(codec, url.getUsername(), 
url.getPassword(), url.getHost(), url.getPort(), url.getPath(), parameters)
             .addParameter(SEND_RECONNECT_KEY, Boolean.TRUE.toString());
         this.requestHandler = requestHandler;
         this.initialState = url.getParameter(LAZY_CONNECT_INITIAL_STATE_KEY, 
DEFAULT_LAZY_CONNECT_INITIAL_STATE);
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 a2ff32b..db72065 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
@@ -43,16 +43,18 @@ final class ReferenceCountExchangeClient implements 
ExchangeClient {
 
     private final static Logger logger = 
LoggerFactory.getLogger(ReferenceCountExchangeClient.class);
     private final URL url;
+    private final String codec;
     private final AtomicInteger referenceCount = new AtomicInteger(0);
     private final AtomicInteger disconnectCount = new AtomicInteger(0);
     private final Integer warningPeriod = 50;
     private ExchangeClient client;
     private int shutdownWaitTime = DEFAULT_SERVER_SHUTDOWN_TIMEOUT;
 
-    public ReferenceCountExchangeClient(ExchangeClient client) {
+    public ReferenceCountExchangeClient(ExchangeClient client, String codec) {
         this.client = client;
-        referenceCount.incrementAndGet();
+        this.referenceCount.incrementAndGet();
         this.url = client.getUrl();
+        this.codec = codec;
     }
 
     @Override
@@ -213,7 +215,7 @@ final class ReferenceCountExchangeClient implements 
ExchangeClient {
                     //.addParameter(RECONNECT_KEY, Boolean.FALSE)
                     .addParameter(SEND_RECONNECT_KEY, Boolean.TRUE.toString());
             
//.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true);
-            client = new LazyConnectExchangeClient(lazyUrl, 
client.getExchangeHandler());
+            client = new LazyConnectExchangeClient(lazyUrl, 
client.getExchangeHandler(), codec, lazyUrl.getParameters());
         }
     }
 

Reply via email to