Class ClusterNodeTracker<N extends SchedulerNode>

java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.scheduler.ClusterNodeTracker<N>

@Private public class ClusterNodeTracker<N extends SchedulerNode> extends Object
Helper library that: - tracks the state of all cluster SchedulerNodes - provides convenience methods to filter and sort nodes
  • Constructor Details

    • ClusterNodeTracker

      public ClusterNodeTracker()
  • Method Details

    • addNode

      public void addNode(N node)
    • exists

      public boolean exists(org.apache.hadoop.yarn.api.records.NodeId nodeId)
    • getNode

      public N getNode(org.apache.hadoop.yarn.api.records.NodeId nodeId)
    • getNodeReport

      public SchedulerNodeReport getNodeReport(org.apache.hadoop.yarn.api.records.NodeId nodeId)
    • nodeCount

      public int nodeCount()
    • nodeCount

      public int nodeCount(String rackName)
    • getClusterCapacity

      public org.apache.hadoop.yarn.api.records.Resource getClusterCapacity()
    • removeNode

      public N removeNode(org.apache.hadoop.yarn.api.records.NodeId nodeId)
    • setConfiguredMaxAllocation

      public void setConfiguredMaxAllocation(org.apache.hadoop.yarn.api.records.Resource resource)
    • setConfiguredMaxAllocationWaitTime

      public void setConfiguredMaxAllocationWaitTime(long configuredMaxAllocationWaitTime)
    • getMaxAllowedAllocation

      public org.apache.hadoop.yarn.api.records.Resource getMaxAllowedAllocation()
    • setForceConfiguredMaxAllocation

      @VisibleForTesting public void setForceConfiguredMaxAllocation(boolean flag)
    • getAllNodes

      public List<N> getAllNodes()
    • getNodes

      public List<N> getNodes(NodeFilter nodeFilter)
      Convenience method to filter nodes based on a condition.
      Parameters:
      nodeFilter - A NodeFilter for filtering the nodes
      Returns:
      A list of filtered nodes
    • getAllNodeIds

      public List<org.apache.hadoop.yarn.api.records.NodeId> getAllNodeIds()
    • getNodeIds

      public List<org.apache.hadoop.yarn.api.records.NodeId> getNodeIds(NodeFilter nodeFilter)
      Convenience method to filter nodes based on a condition.
      Parameters:
      nodeFilter - A NodeFilter for filtering the nodes
      Returns:
      A list of filtered nodes
    • sortedNodeSet

      public TreeSet<N> sortedNodeSet(Comparator<N> comparator)
      Convenience method to sort nodes. Nodes can change while being sorted. Using a standard sort will fail without locking each node, the TreeSet handles this without locks.
      Parameters:
      comparator - the comparator to sort the nodes with
      Returns:
      sorted set of nodes in the form of a TreeSet
    • getNodesByResourceName

      public List<N> getNodesByResourceName(String resourceName)
      Convenience method to return list of nodes corresponding to resourceName passed in the ResourceRequest.
      Parameters:
      resourceName - Host/rack name of the resource, or ResourceRequest.ANY
      Returns:
      list of nodes that match the resourceName
    • getNodeIdsByResourceName

      public List<org.apache.hadoop.yarn.api.records.NodeId> getNodeIdsByResourceName(String resourceName)
      Convenience method to return list of NodeId corresponding to resourceName passed in the ResourceRequest.
      Parameters:
      resourceName - Host/rack name of the resource, or ResourceRequest.ANY
      Returns:
      list of NodeId that match the resourceName
    • updateNodesPerPartition

      public void updateNodesPerPartition(String partition, Set<org.apache.hadoop.yarn.api.records.NodeId> nodeIds)
      update cached nodes per partition on a node label change event.
      Parameters:
      partition - nodeLabel
      nodeIds - List of Node IDs
    • getNodesPerPartition

      public List<N> getNodesPerPartition(String partition)
    • getPartitions

      public List<String> getPartitions()