public void stopDataNodes(List<TDataNodeLocation> removedDataNodes) {

    LOGGER.info(
        "{}, Begin to stop DataNodes and kill the DataNode process: {}",
        REMOVE_DATANODE_PROCESS,
        removedDataNodes);

    DataNodeAsyncRequestContext<TDataNodeLocation, TSStatus> stopDataNodesContext =
        new DataNodeAsyncRequestContext<>(CnToDnAsyncRequestType.STOP_AND_CLEAR_DATA_NODE);

    for (TDataNodeLocation dataNode : removedDataNodes) {
      stopDataNodesContext.putRequest(dataNode.getDataNodeId(), dataNode);
      stopDataNodesContext.putNodeLocation(dataNode.getDataNodeId(), dataNode);
    }

    CnToDnInternalServiceAsyncRequestManager.getInstance()
        .sendAsyncRequestWithRetry(stopDataNodesContext);

    for (Map.Entry<Integer, TSStatus> entry : stopDataNodesContext.getResponseMap().entrySet()) {
      int dataNodeId = entry.getKey();
      configManager.getLoadManager().removeNodeCache(dataNodeId);
      if (!isSucceed(entry.getValue())) {
        LOGGER.error(
            "{}, Stop Data Node meets error, error datanode: {}",
            REMOVE_DATANODE_PROCESS,
            entry.getValue());
      } else {
        LOGGER.info("{}, Stop Data Node {} success.", REMOVE_DATANODE_PROCESS, dataNodeId);
      }
    }
  }
Stops the specified old DataNodes.

@param removedDataNodes the list of DataNodeLocations to be stopped
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RemoveDataNodeHandler.java