public List<RegionMigrationPlan> selectedRegionMigrationPlans(
      List<TDataNodeLocation> removedDataNodes) {

    Set<Integer> removedDataNodesSet = new HashSet<>();
    for (TDataNodeLocation removedDataNode : removedDataNodes) {
      removedDataNodesSet.add(removedDataNode.dataNodeId);
    }

    final List<TDataNodeConfiguration> availableDataNodes =
        configManager
            .getNodeManager()
            .filterDataNodeThroughStatus(NodeStatus.Running, NodeStatus.Unknown)
            .stream()
            .filter(node -> !removedDataNodesSet.contains(node.getLocation().getDataNodeId()))
            .collect(Collectors.toList());

    List<RegionMigrationPlan> regionMigrationPlans = new ArrayList<>();

    regionMigrationPlans.addAll(
        selectMigrationPlans(availableDataNodes, TConsensusGroupType.DataRegion, removedDataNodes));

    regionMigrationPlans.addAll(
        selectMigrationPlans(
            availableDataNodes, TConsensusGroupType.SchemaRegion, removedDataNodes));

    return regionMigrationPlans;
  }
Retrieves all region migration plans for the specified removed DataNodes and selects the
destination.

@param removedDataNodes the list of DataNodes from which to obtain migration plans
@return a list of region migration plans associated with the removed DataNodes
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RemoveDataNodeHandler.java