You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ne...@apache.org on 2022/12/21 11:54:25 UTC

[iotdb] branch apache_iot_consensus_max_client created (now 8295dd542d)

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

neuyilan pushed a change to branch apache_iot_consensus_max_client
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 8295dd542d support modify the dn_max_connection_for_internal_servic of IoTConsensus

This branch includes the following new commits:

     new 8295dd542d support modify the dn_max_connection_for_internal_servic of IoTConsensus

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: support modify the dn_max_connection_for_internal_servic of IoTConsensus

Posted by ne...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8295dd542d9298055010be8aaebe68831c8d0ccf
Author: HouliangQi <ne...@163.com>
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());
     }
   }
 }