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

neuyilan pushed a commit to branch apache_rel_1.0_iotconsens_client
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 1cbe860d32d7cba15f81cf0376b99eeeb73b40e5
Author: HouliangQi <[email protected]>
AuthorDate: Wed Dec 21 18:19:11 2022 +0800

    support modify the dn_max_connection_for_internal_servic of IoTConsensus
---
 .../iotdb/consensus/config/IoTConsensusConfig.java    | 19 +++++++++++++++++--
 .../consensus/iot/client/IoTConsensusClientPool.java  |  7 ++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git 
a/consensus/src/main/java/org/apache/iotdb/consensus/config/IoTConsensusConfig.java
 
b/consensus/src/main/java/org/apache/iotdb/consensus/config/IoTConsensusConfig.java
index d0600a1eee..5d7d27156d 100644
--- 
a/consensus/src/main/java/org/apache/iotdb/consensus/config/IoTConsensusConfig.java
+++ 
b/consensus/src/main/java/org/apache/iotdb/consensus/config/IoTConsensusConfig.java
@@ -75,6 +75,7 @@ public class IoTConsensusConfig {
     private final int selectorNumOfClientManager;
     private final int connectionTimeoutInMs;
     private final int thriftMaxFrameSize;
+    private final int maxConnectionForInternalService;
 
     private RPC(
         int rpcSelectorThreadNum,
@@ -84,7 +85,8 @@ public class IoTConsensusConfig {
         boolean isRpcThriftCompressionEnabled,
         int selectorNumOfClientManager,
         int connectionTimeoutInMs,
-        int thriftMaxFrameSize) {
+        int thriftMaxFrameSize,
+        int maxConnectionForInternalService) {
       this.rpcSelectorThreadNum = rpcSelectorThreadNum;
       this.rpcMinConcurrentClientNum = rpcMinConcurrentClientNum;
       this.rpcMaxConcurrentClientNum = rpcMaxConcurrentClientNum;
@@ -93,6 +95,7 @@ public class IoTConsensusConfig {
       this.selectorNumOfClientManager = selectorNumOfClientManager;
       this.connectionTimeoutInMs = connectionTimeoutInMs;
       this.thriftMaxFrameSize = thriftMaxFrameSize;
+      this.maxConnectionForInternalService = maxConnectionForInternalService;
     }
 
     public int getRpcSelectorThreadNum() {
@@ -127,6 +130,10 @@ public class IoTConsensusConfig {
       return thriftMaxFrameSize;
     }
 
+    public int getMaxConnectionForInternalService() {
+      return maxConnectionForInternalService;
+    }
+
     public static RPC.Builder newBuilder() {
       return new RPC.Builder();
     }
@@ -142,6 +149,8 @@ public class IoTConsensusConfig {
       private int connectionTimeoutInMs = (int) TimeUnit.SECONDS.toMillis(20);
       private int thriftMaxFrameSize = 536870912;
 
+      private int maxConnectionForInternalService = 100;
+
       public RPC.Builder setRpcSelectorThreadNum(int rpcSelectorThreadNum) {
         this.rpcSelectorThreadNum = rpcSelectorThreadNum;
         return this;
@@ -183,6 +192,11 @@ public class IoTConsensusConfig {
         return this;
       }
 
+      public RPC.Builder setMaxConnectionForInternalService(int 
maxConnectionForInternalService) {
+        this.maxConnectionForInternalService = maxConnectionForInternalService;
+        return this;
+      }
+
       public RPC build() {
         return new RPC(
             rpcSelectorThreadNum,
@@ -192,7 +206,8 @@ public class IoTConsensusConfig {
             isRpcThriftCompressionEnabled,
             selectorNumOfClientManager,
             connectionTimeoutInMs,
-            thriftMaxFrameSize);
+            thriftMaxFrameSize,
+            maxConnectionForInternalService);
       }
     }
   }
diff --git 
a/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/IoTConsensusClientPool.java
 
b/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/IoTConsensusClientPool.java
index 3c7f4a4b8d..babc9fb4f5 100644
--- 
a/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/IoTConsensusClientPool.java
+++ 
b/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/IoTConsensusClientPool.java
@@ -35,6 +35,7 @@ public class IoTConsensusClientPool {
 
   public static class SyncIoTConsensusServiceClientPoolFactory
       implements IClientPoolFactory<TEndPoint, SyncIoTConsensusServiceClient> {
+
     private final IoTConsensusConfig config;
 
     public SyncIoTConsensusServiceClientPoolFactory(IoTConsensusConfig config) 
{
@@ -80,7 +81,11 @@ public class IoTConsensusClientPool {
                       config.getRpc().getSelectorNumOfClientManager())
                   .build(),
               IOT_CONSENSUS_CLIENT_POOL_THREAD_NAME),
-          new 
ClientPoolProperty.Builder<AsyncIoTConsensusServiceClient>().build().getConfig());
+          new ClientPoolProperty.Builder<AsyncIoTConsensusServiceClient>()
+              
.setMaxIdleClientForEachNode(config.getRpc().getMaxConnectionForInternalService())
+              
.setMaxTotalClientForEachNode(config.getRpc().getMaxConnectionForInternalService())
+              .build()
+              .getConfig());
     }
   }
 }

Reply via email to