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/08/10 03:03:32 UTC

[GitHub] [iotdb] wangchao316 commented on a diff in pull request #6938: [IOTDB-4044] Remove a DataNode from the cluster, when this node stopped.

wangchao316 commented on code in PR #6938:
URL: https://github.com/apache/iotdb/pull/6938#discussion_r941964974


##########
confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/DataNodeRemoveHandler.java:
##########
@@ -135,29 +136,99 @@ public TDataNodeLocation findDestDataNode(TConsensusGroupId regionId) {
   }
 
   /**
-   * Send to DataNode, migrate region from originalDataNode to destDataNode
+   * Send to DataNode, add region peer
    *
    * @param originalDataNode old location data node
    * @param destDataNode dest data node
    * @param regionId region id
    * @return migrate status
    */
-  public TSStatus migrateRegion(
+  public TSStatus addRegionPeer(
       TDataNodeLocation originalDataNode,
       TDataNodeLocation destDataNode,
       TConsensusGroupId regionId) {
     TSStatus status;
-    List<TDataNodeLocation> regionReplicaNodes = findRegionReplicaNodes(regionId);
-    if (regionReplicaNodes.isEmpty()) {
-      LOGGER.warn("Not find region replica nodes, region: {}", regionId);
+    Optional<TDataNodeLocation> newLeaderNode = findNewLeader(regionId, originalDataNode);
+    if (!newLeaderNode.isPresent()) {
+      LOGGER.warn(
+          "No other Node to change region leader, check by show regions, region: {}", regionId);
       status = new TSStatus(TSStatusCode.MIGRATE_REGION_ERROR.getStatusCode());
-      status.setMessage("not find region replica nodes, region: " + regionId);
+      status.setMessage("No other Node to change region leader, check by show regions");
       return status;
     }
 
-    // TODO if region replica is 1, the new leader is null, it also need to migrate
-    Optional<TDataNodeLocation> newLeaderNode =
-        regionReplicaNodes.stream().filter(e -> !e.equals(originalDataNode)).findAny();
+    TMigrateRegionReq migrateRegionReq =
+        new TMigrateRegionReq(regionId, destDataNode, destDataNode);

Review Comment:
   this does not need originalDataNode, and can not be null. so use destDataNode fills.



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