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 2022/07/22 04:04:17 UTC

[GitHub] [iotdb] CRZbulabula commented on a diff in pull request #6735: [IOTDB-3880] Optimize asyncclientpool retry logic

CRZbulabula commented on code in PR #6735:
URL: https://github.com/apache/iotdb/pull/6735#discussion_r927268169


##########
confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/AbstractRetryHandler.java:
##########
@@ -27,15 +27,15 @@
 
 public abstract class AbstractRetryHandler {
 
-  protected final int index;
-
   protected CountDownLatch countDownLatch;
+
   /**
-   * Map<Index, TDataNodeLocation> The DataNode that successfully execute the request will be
-   * removed from this map
+   * The DataNode that successfully execute the request will be removed from this list Because
+   * different requests will be sent to the same node when createRegions,so for CreateRegions ->
+   * Map<index, TDataNodeLocation> for others -> Map<dataNodeId, TDataNodeLocation>

Review Comment:
   ```suggestion
      * Map<DataNodeId, TDataNodeLocation> The DataNode that successfully execute the request 
      * will be remoed from this map.
   ```
   
   We can keep this annotation remains the same since the CreateRegionHandler is a particular case. And we can move this part of special comment into the CreateRegionHandler



##########
confignode/src/main/java/org/apache/iotdb/confignode/client/async/datanode/AsyncDataNodeClientPool.java:
##########
@@ -72,38 +71,63 @@ private AsyncDataNodeClientPool() {
    * receive the requests
    *
    * @param req request
-   * @param handlerMap Map<index, Handler>
-   * @param dataNodeLocations ConcurrentHashMap<index, TDataNodeLocation> The specific DataNodes
+   * @param dataNodeLocationMap Map<DataNodeId, TDataNodeLocation>
+   * @param requestType DataNodeRequestType
+   * @param dataNodeResponseStatus response list.Used by CREATE_FUNCTION,DROP_FUNCTION and FLUSH
    */
   public void sendAsyncRequestToDataNodeWithRetry(
       Object req,
-      Map<Integer, AbstractRetryHandler> handlerMap,
-      Map<Integer, TDataNodeLocation> dataNodeLocations) {
-    CountDownLatch countDownLatch = new CountDownLatch(dataNodeLocations.size());
-    if (dataNodeLocations.isEmpty()) {
+      Map<Integer, TDataNodeLocation> dataNodeLocationMap,
+      DataNodeRequestType requestType,
+      List<TSStatus> dataNodeResponseStatus) {
+    if (dataNodeLocationMap.isEmpty()) {
       return;
     }
     for (int retry = 0; retry < retryNum; retry++) {
-      AbstractRetryHandler handler = null;
-      for (Map.Entry<Integer, TDataNodeLocation> entry : dataNodeLocations.entrySet()) {
-        handler = handlerMap.get(entry.getKey());
-        // If it is not the first request, then prove that this operation is a retry.
-        // The count of countDownLatch needs to be updated
-        if (retry != 0) {
-          handler.setCountDownLatch(countDownLatch);
+      CountDownLatch countDownLatch = new CountDownLatch(dataNodeLocationMap.size());
+      AbstractRetryHandler handler;
+      for (TDataNodeLocation targetDataNode : dataNodeLocationMap.values()) {

Review Comment:
   It seems that this handler can be defined inside the following loop



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