You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/09/15 02:35:32 UTC

[GitHub] [iotdb] chengjianyun commented on a change in pull request #3886: [cluster-refactor] refactor client pool

chengjianyun commented on a change in pull request #3886:
URL: https://github.com/apache/iotdb/pull/3886#discussion_r708791329



##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/utils/ClientUtils.java
##########
@@ -19,52 +19,42 @@
 
 package org.apache.iotdb.cluster.utils;
 
-import org.apache.iotdb.cluster.client.async.AsyncDataClient;
-import org.apache.iotdb.cluster.client.async.AsyncDataHeartbeatClient;
-import org.apache.iotdb.cluster.client.async.AsyncMetaClient;
-import org.apache.iotdb.cluster.client.async.AsyncMetaHeartbeatClient;
+import org.apache.iotdb.cluster.client.ClientCategory;
 import org.apache.iotdb.cluster.client.sync.SyncDataClient;
-import org.apache.iotdb.cluster.client.sync.SyncDataHeartbeatClient;
 import org.apache.iotdb.cluster.client.sync.SyncMetaClient;
-import org.apache.iotdb.cluster.client.sync.SyncMetaHeartbeatClient;
-import org.apache.iotdb.cluster.rpc.thrift.RaftService.AsyncClient;
-import org.apache.iotdb.cluster.rpc.thrift.RaftService.Client;
+import org.apache.iotdb.cluster.rpc.thrift.Node;
+import org.apache.iotdb.cluster.rpc.thrift.RaftService;
 
 public class ClientUtils {
 
   private ClientUtils() {
     // util class
   }
 
-  public static boolean isHeartbeatClientReady(AsyncClient client) {
-    if (client instanceof AsyncDataHeartbeatClient) {
-      return ((AsyncDataHeartbeatClient) client).isReady();
-    } else {
-      return ((AsyncMetaHeartbeatClient) client).isReady();
-    }
-  }
-
-  public static void putBackSyncHeartbeatClient(Client client) {
-    if (client instanceof SyncMetaHeartbeatClient) {
-      ((SyncMetaHeartbeatClient) client).putBack();
-    } else {
-      ((SyncDataHeartbeatClient) client).putBack();
-    }
-  }
-
-  public static void putBackSyncClient(Client client) {
-    if (client instanceof SyncDataClient) {
-      ((SyncDataClient) client).putBack();
-    } else if (client instanceof SyncMetaClient) {
-      ((SyncMetaClient) client).putBack();
+  public static int getPort(Node node, ClientCategory category) {
+    int port = -1;
+    if (category == ClientCategory.DATA) {
+      port = node.getDataPort();
+    } else if (ClientCategory.DATA_HEARTBEAT == category) {
+      port = node.getDataPort() + ClusterUtils.DATA_HEARTBEAT_PORT_OFFSET;
+    } else if (ClientCategory.META == category) {
+      port = node.getMetaPort();
+    } else if (ClientCategory.META_HEARTBEAT == category) {
+      port = node.getMetaPort() + ClusterUtils.META_HEARTBEAT_PORT_OFFSET;
+    } else if (ClientCategory.SINGLE_MASTER == category) {
+      // special data port type
+      port = node.getMetaPort();

Review comment:
       Sorry for the wrong comment, SINGLE_MASTER is a special type of meta.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org