liyuheng55555 commented on code in PR #12667:
URL: https://github.com/apache/iotdb/pull/12667#discussion_r1638027713


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ClusterManager.java:
##########
@@ -79,4 +104,195 @@ private void generateClusterId() {
       LOGGER.warn(CONSENSUS_WRITE_ERROR, e);
     }
   }
+
+  public TTestConnectionResp submitTestConnectionTaskToEveryNode() {
+    TTestConnectionResp resp = new TTestConnectionResp();
+    resp.resultList = new ArrayList<>();
+    resp.setStatus(new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()));
+    TNodeLocations nodeLocations = new TNodeLocations();
+    
nodeLocations.setConfigNodeLocations(configManager.getNodeManager().getRegisteredConfigNodes());
+    nodeLocations.setDataNodeLocations(
+        configManager.getNodeManager().getRegisteredDataNodes().stream()
+            .map(TDataNodeConfiguration::getLocation)
+            .collect(Collectors.toList()));
+    // For ConfigNode
+    Map<Integer, TConfigNodeLocation> configNodeLocationMap =
+        configManager.getNodeManager().getRegisteredConfigNodes().stream()
+            .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, 
location -> location));
+    ConfigNodeAsyncRequestContext<TNodeLocations, TTestConnectionResp>
+        configNodeAsyncRequestContext =
+            new ConfigNodeAsyncRequestContext<>(
+                ConfigNodeToConfigNodeRequestType.SUBMIT_TEST_CONNECTION_TASK,
+                nodeLocations,
+                configNodeLocationMap);
+    ConfigNodeToConfigNodeInternalServiceAsyncRequestManager.getInstance()
+        .sendAsyncRequest(configNodeAsyncRequestContext);
+    Map<Integer, TConfigNodeLocation> anotherConfigNodeLocationMap =
+        configManager.getNodeManager().getRegisteredConfigNodes().stream()
+            .collect(Collectors.toMap(TConfigNodeLocation::getConfigNodeId, 
location -> location));
+    configNodeAsyncRequestContext
+        .getResponseMap()
+        .forEach(
+            (nodeId, configNodeResp) -> {
+              if (configNodeResp.isSetResultList()) {
+                resp.getResultList().addAll(configNodeResp.getResultList());
+              } else {
+                resp.getResultList()
+                    .addAll(
+                        badConfigNodeConnectionResult(
+                            anotherConfigNodeLocationMap.get(nodeId), 
nodeLocations));
+              }
+            });
+    // For DataNode

Review Comment:
   seems not very easy



-- 
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-unsubscr...@iotdb.apache.org

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

Reply via email to