You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ta...@apache.org on 2022/01/14 06:05:44 UTC

[iotdb] branch fix_idle_eviction created (now 6cb0bff)

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

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


      at 6cb0bff  fix

This branch includes the following new commits:

     new 6cb0bff  fix

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: fix

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

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

commit 6cb0bff3af9f8b1492daa275815c80fb0878997c
Author: LebronAl <TX...@gmail.com>
AuthorDate: Fri Jan 14 14:03:34 2022 +0800

    fix
---
 .../iotdb/cluster/client/ClientPoolFactory.java    |  1 +
 .../cluster/client/ClientPoolFactoryTest.java      | 29 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/client/ClientPoolFactory.java b/cluster/src/main/java/org/apache/iotdb/cluster/client/ClientPoolFactory.java
index 0887992..dfd3283 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/client/ClientPoolFactory.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/client/ClientPoolFactory.java
@@ -54,6 +54,7 @@ public class ClientPoolFactory {
             : new TBinaryProtocol.Factory();
     poolConfig = new GenericKeyedObjectPoolConfig();
     poolConfig.setMaxTotalPerKey(maxConnectionForEachNode);
+    poolConfig.setMaxIdlePerKey(maxConnectionForEachNode / 2);
     poolConfig.setMaxWait(Duration.ofMillis(waitClientTimeoutMS));
     poolConfig.setTestOnReturn(true);
     poolConfig.setTestOnBorrow(true);
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/client/ClientPoolFactoryTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/client/ClientPoolFactoryTest.java
index f1e313e..e05a999 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/client/ClientPoolFactoryTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/client/ClientPoolFactoryTest.java
@@ -130,6 +130,35 @@ public class ClientPoolFactoryTest {
   }
 
   @Test
+  public void poolIdleObjectEvictionTest() throws Exception {
+    GenericKeyedObjectPool<Node, RaftService.AsyncClient> pool =
+        clientPoolFactory.createAsyncDataPool(ClientCategory.DATA);
+
+    pool.setMaxTotalPerKey(2 * pool.getMaxIdlePerKey());
+
+    Node node = constructDefaultNode();
+    List<RaftService.AsyncClient> clientList = new ArrayList<>();
+    for (int i = 0; i < pool.getMaxTotalPerKey(); i++) {
+      RaftService.AsyncClient client = pool.borrowObject(node);
+      Assert.assertNotNull(client);
+      clientList.add(client);
+    }
+
+    for (RaftService.AsyncClient client : clientList) {
+      pool.returnObject(node, client);
+    }
+
+    Assert.assertEquals(0, pool.getNumActive(node));
+    Assert.assertEquals(pool.getMaxIdlePerKey(), pool.getNumIdle(node));
+
+    for (int i = 0; i < pool.getMaxIdlePerKey(); i++) {
+      RaftService.AsyncClient client = pool.borrowObject(node);
+      Assert.assertNotNull(client);
+      Assert.assertTrue(clientList.contains(client));
+    }
+  }
+
+  @Test
   public void createAsyncDataClientTest() throws Exception {
     GenericKeyedObjectPool<Node, RaftService.AsyncClient> pool =
         clientPoolFactory.createAsyncDataPool(ClientCategory.DATA);