private TSStatus checkMigrateRegion(
      TMigrateRegionReq migrateRegionReq,
      TConsensusGroupId regionGroupId,
      TDataNodeLocation originalDataNode,
      TDataNodeLocation destDataNode,
      TDataNodeLocation coordinatorForAddPeer) {
    String failMessage;
    if ((failMessage =
            regionOperationCommonCheck(
                regionGroupId,
                destDataNode,
                Arrays.asList(
                    new Pair<>("Original DataNode", originalDataNode),
                    new Pair<>("Destination DataNode", destDataNode),
                    new Pair<>("Coordinator for add peer", coordinatorForAddPeer)),
                migrateRegionReq.getModel()))
        != null) {
      // do nothing
    } else if (configManager
        .getPartitionManager()
        .getAllReplicaSets(originalDataNode.getDataNodeId())
        .stream()
        .noneMatch(replicaSet -> replicaSet.getRegionId().equals(regionGroupId))) {
      failMessage =
          String.format(
              "Submit RegionMigrateProcedure failed, because the original DataNode %s doesn't contain Region %s",
              migrateRegionReq.getFromId(), migrateRegionReq.getRegionId());
    } else if (configManager
        .getPartitionManager()
        .getAllReplicaSets(destDataNode.getDataNodeId())
        .stream()
        .anyMatch(replicaSet -> replicaSet.getRegionId().equals(regionGroupId))) {
      failMessage =
          String.format(
              "Submit RegionMigrateProcedure failed, because the target DataNode %s already contains Region %s",
              migrateRegionReq.getToId(), migrateRegionReq.getRegionId());
    }

    if (failMessage != null) {
      LOGGER.warn(failMessage);
      TSStatus failStatus = new TSStatus(TSStatusCode.MIGRATE_REGION_ERROR.getStatusCode());
      failStatus.setMessage(failMessage);
      return failStatus;
    }
    return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
  }
Checks whether region migration is allowed.

@param migrateRegionReq the migration request details
@param regionGroupId the ID of the consensus group for the region
@param originalDataNode the original DataNode location from which the region is being migrated
@param destDataNode the destination DataNode location to which the region is being migrated
@param coordinatorForAddPeer the DataNode location acting as the coordinator for adding a peer
@return the status of the migration request (TSStatus)
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ProcedureManager.java