public TRegionMigrateResult waitTaskFinish(long taskId, TDataNodeLocation dataNodeLocation) {
    final long MAX_DISCONNECTION_TOLERATE_MS = 600_000;
    final long INITIAL_DISCONNECTION_TOLERATE_MS = 60_000;
    long startTime = System.nanoTime();
    long lastReportTime = System.nanoTime();
    while (true) {
      try (SyncDataNodeInternalServiceClient dataNodeClient =
          dataNodeClientManager.borrowClient(dataNodeLocation.getInternalEndPoint())) {
        TRegionMigrateResult report = dataNodeClient.getRegionMaintainResult(taskId);
        lastReportTime = System.nanoTime();
        if (report.getTaskStatus() != TRegionMaintainTaskStatus.PROCESSING) {
          return report;
        }
      } catch (Exception ignore) {

      }
      long waitTime =
          Math.min(
              INITIAL_DISCONNECTION_TOLERATE_MS
                  + TimeUnit.NANOSECONDS.toMillis(lastReportTime - startTime) / 60,
              MAX_DISCONNECTION_TOLERATE_MS);
      long disconnectionTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastReportTime);
      if (disconnectionTime > waitTime) {
        LOGGER.warn(
            "{} task {} cannot get task report from DataNode {}, last report time is {} ago",
            REGION_MIGRATE_PROCESS,
            taskId,
            dataNodeLocation,
            CommonDateTimeUtils.convertMillisecondToDurationStr(
                TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastReportTime)));
        TRegionMigrateResult report = new TRegionMigrateResult();
        report.setTaskStatus(TRegionMaintainTaskStatus.FAIL);
        report.setFailedNodeAndReason(new HashMap<>());
        report.getFailedNodeAndReason().put(dataNodeLocation, TRegionMigrateFailedType.Disconnect);
        return report;
      }
      try {
        TimeUnit.SECONDS.sleep(1);
      } catch (InterruptedException ignore) {
        Thread.currentThread().interrupt();
        return new TRegionMigrateResult(TRegionMaintainTaskStatus.PROCESSING);
      }
    }
  }
Delete a Region peer in the given ConsensusGroup and all of its data on the specified DataNode

<p>If the originalDataNode is down, we should delete local data and do other cleanup works
manually.

@param originalDataNode The DataNodeLocation who contains the original RegionReplica
@param regionId region id
@return TSStatus
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java