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/02/26 13:38:33 UTC

[GitHub] [iotdb] yuqi1129 commented on a change in pull request #2662: Fix statistics value in SyncClientPool/AsyncClientPool have concurren…

yuqi1129 commented on a change in pull request #2662:
URL: https://github.com/apache/iotdb/pull/2662#discussion_r583643342



##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/client/async/AsyncClientPool.java
##########
@@ -81,19 +82,19 @@ public AsyncClient getClient(Node node, boolean activatedOnly) throws IOExceptio
 
     AsyncClient client;
     // As clientCaches is ConcurrentHashMap, computeIfAbsent is thread safety.
-    Deque<AsyncClient> clientStack =
+    Deque<AsyncClient> clientDeque =
         clientCaches.computeIfAbsent(clusterNode, n -> new ArrayDeque<>());
     synchronized (this) {
-      if (clientStack.isEmpty()) {
+      if (clientDeque.isEmpty()) {
         int nodeClientNum = nodeClientNumMap.getOrDefault(clusterNode, 0);
         if (nodeClientNum >= maxConnectionForEachNode) {
-          client = waitForClient(clientStack, clusterNode, nodeClientNum);
+          client = waitForClient(clientDeque, clusterNode);
         } else {
           nodeClientNumMap.put(clusterNode, nodeClientNum + 1);
           client = asyncClientFactory.getAsyncClient(clusterNode, this);
         }
       } else {
-        client = clientStack.pop();
+        client = clientDeque.getFirst();

Review comment:
       Sorry, this is a mistake i make here, `getFirst()` will not remove element from queue




----------------------------------------------------------------
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.

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