You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2021/01/20 04:42:18 UTC

[iotdb] branch master updated: fix asyncManager init

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2ff7489  fix asyncManager init
     new bd156e4  Merge pull request #2527 from LebronAl/cluster_fix_asyncManager_init
2ff7489 is described below

commit 2ff748963be861fbc8d7de016e337d71024db783
Author: LebronAl <TX...@gmail.com>
AuthorDate: Tue Jan 19 22:37:09 2021 +0800

    fix asyncManager init
---
 .../apache/iotdb/cluster/client/async/AsyncClientFactory.java |  6 +++---
 .../apache/iotdb/cluster/client/async/AsyncDataClient.java    | 11 +++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncClientFactory.java b/cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncClientFactory.java
index 45f6d27..258b184 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncClientFactory.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncClientFactory.java
@@ -36,10 +36,9 @@ public abstract class AsyncClientFactory {
   AtomicInteger clientCnt = new AtomicInteger();
 
   static {
-    managers =
-        new TAsyncClientManager[ClusterDescriptor.getInstance().getConfig()
-            .getSelectorNumOfClientPool()];
     if (ClusterDescriptor.getInstance().getConfig().isUseAsyncServer()) {
+      managers = new TAsyncClientManager[ClusterDescriptor.getInstance().getConfig()
+          .getSelectorNumOfClientPool()];
       for (int i = 0; i < managers.length; i++) {
         try {
           managers[i] = new TAsyncClientManager();
@@ -52,6 +51,7 @@ public abstract class AsyncClientFactory {
 
   /**
    * Get a client which will connect the given node and be cached in the given pool.
+   *
    * @param node the cluster node the client will connect.
    * @param pool the pool that will cache the client for reusing.
    * @return
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncDataClient.java b/cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncDataClient.java
index 28a6a02..d6b6f45 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncDataClient.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncDataClient.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.cluster.client.async;
 
 import java.io.IOException;
 import java.util.Date;
+import org.apache.iotdb.cluster.config.ClusterDescriptor;
 import org.apache.iotdb.cluster.rpc.thrift.Node;
 import org.apache.iotdb.cluster.rpc.thrift.RaftService;
 import org.apache.iotdb.cluster.rpc.thrift.TSDataService.AsyncClient;
@@ -109,10 +110,12 @@ public class AsyncDataClient extends AsyncClient {
 
     public SingleManagerFactory(org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
       this.protocolFactory = protocolFactory;
-      try {
-        manager = new TAsyncClientManager();
-      } catch (IOException e) {
-        logger.error("Cannot init manager of SingleThreadFactoryAsync", e);
+      if (ClusterDescriptor.getInstance().getConfig().isUseAsyncServer()) {
+        try {
+          manager = new TAsyncClientManager();
+        } catch (IOException e) {
+          logger.error("Cannot init manager of SingleThreadFactoryAsync", e);
+        }
       }
     }