public void changeDataNodeStatus(
      List<TDataNodeLocation> removedDataNodes, Map<Integer, NodeStatus> nodeStatusMap) {
    LOGGER.info(
        "{}, Begin to change DataNode status, nodeStatusMap: {}",
        REMOVE_DATANODE_PROCESS,
        nodeStatusMap);

    DataNodeAsyncRequestContext<String, TSStatus> changeDataNodeStatusContext =
        new DataNodeAsyncRequestContext<>(CnToDnAsyncRequestType.SET_SYSTEM_STATUS);

    for (TDataNodeLocation dataNode : removedDataNodes) {
      changeDataNodeStatusContext.putRequest(
          dataNode.getDataNodeId(), nodeStatusMap.get(dataNode.getDataNodeId()).getStatus());
      changeDataNodeStatusContext.putNodeLocation(dataNode.getDataNodeId(), dataNode);
    }

    CnToDnInternalServiceAsyncRequestManager.getInstance()
        .sendAsyncRequestWithRetry(changeDataNodeStatusContext);

    for (Map.Entry<Integer, TSStatus> entry :
        changeDataNodeStatusContext.getResponseMap().entrySet()) {
      int dataNodeId = entry.getKey();
      NodeStatus nodeStatus = nodeStatusMap.get(dataNodeId);
      RegionStatus regionStatus = RegionStatus.valueOf(nodeStatus.getStatus());

      if (!isSucceed(entry.getValue())) {
        LOGGER.error(
            "{}, Failed to change DataNode status, dataNodeId={}, nodeStatus={}",
            REMOVE_DATANODE_PROCESS,
            dataNodeId,
            nodeStatus);
        continue;
      }

      // Force updating NodeStatus
      long currentTime = System.nanoTime();
      configManager
          .getLoadManager()
          .forceUpdateNodeCache(
              NodeType.DataNode, dataNodeId, new NodeHeartbeatSample(currentTime, nodeStatus));

      LOGGER.info(
          "{}, Force update NodeCache: dataNodeId={}, nodeStatus={}, currentTime={}",
          REMOVE_DATANODE_PROCESS,
          dataNodeId,
          nodeStatus,
          currentTime);

      // Force update RegionStatus
      if (regionStatus != RegionStatus.Removing) {
        Map<TConsensusGroupId, Map<Integer, RegionHeartbeatSample>> heartbeatSampleMap =
            new TreeMap<>();
        configManager
            .getPartitionManager()
            .getAllReplicaSets(dataNodeId)
            .forEach(
                replicaSet ->
                    heartbeatSampleMap.put(
                        replicaSet.getRegionId(),
                        Collections.singletonMap(
                            dataNodeId, new RegionHeartbeatSample(currentTime, regionStatus))));
        configManager.getLoadManager().forceUpdateRegionGroupCache(heartbeatSampleMap);
      }
    }
  }
Changes the status of a batch of specified DataNodes to the given status. This is done to
prevent the DataNodes from receiving read or write requests when they are being removed or are
in a restricted state.

@param removedDataNodes the locations of the DataNodes whose statuses need to be changed
@param nodeStatusMap a map containing the new status to assign to each DataNode (e.g.,
    Removing, Running, etc.)
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RemoveDataNodeHandler.java