mychaow commented on a change in pull request #1854:
URL: https://github.com/apache/iotdb/pull/1854#discussion_r511362737



##########
File path: 
cluster/src/main/java/org/apache/iotdb/cluster/server/member/MetaGroupMember.java
##########
@@ -1505,6 +1511,48 @@ private TSStatus forwardPlan(Map<PhysicalPlan, 
PartitionGroup> planGroupMap, Phy
     return status;
   }
 
+  /**
+   * Forward each sub-plan to its belonging data group, and combine responses 
from the groups.
+   *
+   * @param planGroupMap sub-plan -> data group pairs
+   */
+  private TSStatus forwardCreateMultiTimeSeriesPlan(Map<PhysicalPlan, 
PartitionGroup> planGroupMap,
+                                           CreateMultiTimeSeriesPlan plan) {
+    List<String> errorCodePartitionGroups = new ArrayList<>();
+    TSStatus tmpStatus;
+    CreateMultiTimeSeriesPlan subPlan;
+    Map<Integer, Exception> results = new HashMap<>();
+    boolean noFailure = true;
+    boolean isBatchFailure = false;
+    // send sub-plans to each belonging data group and collect results
+    for (Map.Entry<PhysicalPlan, PartitionGroup> entry : 
planGroupMap.entrySet()) {
+      tmpStatus = forwardToSingleGroup(entry);
+      subPlan = (CreateMultiTimeSeriesPlan) entry.getKey();
+      logger.debug("{}: from {},{},{}", name, entry.getKey(), 
entry.getValue(), tmpStatus);
+      noFailure =
+        (tmpStatus.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) 
&& noFailure;
+      isBatchFailure = (tmpStatus.getCode() == 
TSStatusCode.MULTIPLE_ERROR.getStatusCode())
+        || isBatchFailure;
+      if (tmpStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) {
+        results.putAll(subPlan.getResults());
+      }
+      if (tmpStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+        // execution failed, record the error message
+        errorCodePartitionGroups.add(String.format("[%s@%s:%s:%s]",
+          tmpStatus.getCode(), entry.getValue().getHeader(),
+          tmpStatus.getMessage(), tmpStatus.subStatus));
+      }
+    }
+
+    plan.setResults(results);
+    if (noFailure || isBatchFailure) {
+      return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);

Review comment:
       got it!




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to