Class RemoveDataNodeHandler

java.lang.Object
org.apache.iotdb.confignode.procedure.env.RemoveDataNodeHandler

public class RemoveDataNodeHandler extends Object
  • Constructor Details

    • RemoveDataNodeHandler

      public RemoveDataNodeHandler(ConfigManager configManager)
  • Method Details

    • checkEnoughDataNodeAfterRemoving

      public boolean checkEnoughDataNodeAfterRemoving(List<TDataNodeLocation> removedDataNodes)
      Check if the data nodes are sufficient after removing.
      Parameters:
      removedDataNodes - List
      Returns:
      true if the number of DataNodes is enough, false otherwise
    • changeDataNodeStatus

      public void changeDataNodeStatus(List<TDataNodeLocation> removedDataNodes, Map<Integer,NodeStatus> nodeStatusMap)
      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.
      Parameters:
      removedDataNodes - the locations of the DataNodes whose statuses need to be changed
      nodeStatusMap - a map containing the new status to assign to each DataNode (e.g., Removing, Running, etc.)
    • getRegionMigrationPlans

      public List<RegionMigrationPlan> getRegionMigrationPlans(List<TDataNodeLocation> removedDataNodes)
      Retrieves all region migration plans for the specified removed DataNodes.
      Parameters:
      removedDataNodes - the list of DataNodes from which to obtain migration plans
      Returns:
      a list of region migration plans associated with the removed DataNodes
    • broadcastDataNodeStatusChange

      public void broadcastDataNodeStatusChange(List<TDataNodeLocation> dataNodes)
      Broadcasts DataNodes' status change, preventing disabled DataNodes from accepting read or write requests.
      Parameters:
      dataNodes - the list of DataNodes that require broadcast status changes
    • removeDataNodePersistence

      public void removeDataNodePersistence(List<TDataNodeLocation> removedDataNodes)
      Removes a batch of DataNodes from the node information.
      Parameters:
      removedDataNodes - the list of DataNodeLocations to be removed
    • stopDataNodes

      public void stopDataNodes(List<TDataNodeLocation> removedDataNodes)
      Stops the specified old DataNodes.
      Parameters:
      removedDataNodes - the list of DataNodeLocations to be stopped
    • checkRemoveDataNodeRequest

      public DataNodeToStatusResp checkRemoveDataNodeRequest(RemoveDataNodePlan removeDataNodePlan)
      Checks if the RemoveDataNode request is valid.
      Parameters:
      removeDataNodePlan - the RemoveDataNodeReq to be validated
      Returns:
      SUCCEED_STATUS if the request is valid
    • checkRegionReplication

      public TSStatus checkRegionReplication(RemoveDataNodePlan removeDataNodePlan)
      Checks whether the cluster has enough DataNodes to maintain the required number of RegionReplicas.
      Parameters:
      removeDataNodePlan - the RemoveDataNodeReq to be evaluated
      Returns:
      SUCCEED_STATUS if the number of DataNodes is sufficient, LACK_REPLICATION otherwise
    • checkAllowRemoveDataNodes

      public TSStatus checkAllowRemoveDataNodes(RemoveDataNodePlan removeDataNodePlan)
      Checks if it is allowed to remove the specified DataNodes from the cluster.
      Parameters:
      removeDataNodePlan - the RemoveDataNodeReq to be evaluated
      Returns:
      SUCCEED_STATUS if the request is valid, otherwise an appropriate error status
    • getRemovedDataNodesRegionSet

      public Set<TConsensusGroupId> getRemovedDataNodesRegionSet(List<TDataNodeLocation> removedDataNodes)
      Retrieves all consensus group IDs from the specified removed DataNodes.
      Parameters:
      removedDataNodes - the list of removed DataNodes
      Returns:
      a set of TConsensusGroupId representing the consensus groups associated with the removed DataNodes
    • getMigratedDataNodeRegions

      public List<TConsensusGroupId> getMigratedDataNodeRegions(TDataNodeLocation removedDataNode)
      Retrieves all consensus group IDs from the specified DataNode.
      Parameters:
      removedDataNode - the DataNode to be removed
      Returns:
      a list of group IDs that need to be migrated
    • getRelatedDataNodeLocations

      public Set<TDataNodeLocation> getRelatedDataNodeLocations(TDataNodeLocation removedDataNode)
      Retrieves all DataNodes related to the specified DataNode.
      Parameters:
      removedDataNode - the DataNode to be removed
      Returns:
      a set of TDataNodeLocation representing the DataNodes associated with the specified DataNode