java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.nodemanager.containermanager.scheduler.ContainerScheduler
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.service.Service, org.apache.hadoop.yarn.event.EventHandler<ContainerSchedulerEvent>

public class ContainerScheduler extends org.apache.hadoop.service.AbstractService implements org.apache.hadoop.yarn.event.EventHandler<ContainerSchedulerEvent>
The ContainerScheduler manages a collection of runnable containers. It ensures that a container is launched only if all its launch criteria are met. It also ensures that OPPORTUNISTIC containers are killed to make room for GUARANTEED containers.
  • Constructor Details

    • ContainerScheduler

      public ContainerScheduler(Context context, org.apache.hadoop.yarn.event.AsyncDispatcher dispatcher, NodeManagerMetrics metrics)
      Instantiate a Container Scheduler.
      Parameters:
      context - NodeManager Context.
      dispatcher - AsyncDispatcher.
      metrics - NodeManagerMetrics.
    • ContainerScheduler

      @VisibleForTesting public ContainerScheduler(Context context, org.apache.hadoop.yarn.event.AsyncDispatcher dispatcher, NodeManagerMetrics metrics, int qLength)
    • ContainerScheduler

      @VisibleForTesting public ContainerScheduler(Context context, org.apache.hadoop.yarn.event.AsyncDispatcher dispatcher, NodeManagerMetrics metrics, OpportunisticContainersQueuePolicy oppContainersQueuePolicy, int qLength)
  • Method Details

    • serviceInit

      public void serviceInit(org.apache.hadoop.conf.Configuration conf) throws Exception
      Overrides:
      serviceInit in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • handle

      public void handle(ContainerSchedulerEvent event)
      Handle ContainerSchedulerEvents.
      Specified by:
      handle in interface org.apache.hadoop.yarn.event.EventHandler<ContainerSchedulerEvent>
      Parameters:
      event - ContainerSchedulerEvent.
    • recoverActiveContainer

      public void recoverActiveContainer(Container container, NMStateStoreService.RecoveredContainerState rcs)
      Populates auxiliary data structures used by the ContainerScheduler on recovery.
      Parameters:
      container - container recovered
      rcs - Recovered Container status
    • getNumQueuedContainers

      public int getNumQueuedContainers()
      Return number of queued containers.
      Returns:
      Number of queued containers.
    • getOpportunisticQueueCapacity

      public int getOpportunisticQueueCapacity()
      Return the capacity of the queue for opportunistic containers on this node.
      Returns:
      queue capacity.
    • getNumQueuedGuaranteedContainers

      @VisibleForTesting public int getNumQueuedGuaranteedContainers()
    • getNumQueuedOpportunisticContainers

      @VisibleForTesting public int getNumQueuedOpportunisticContainers()
    • getNumRunningContainers

      @VisibleForTesting public int getNumRunningContainers()
    • setUsePauseEventForPreemption

      @VisibleForTesting public void setUsePauseEventForPreemption(boolean usePauseEventForPreemption)
    • getOpportunisticContainersStatus

      public org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus getOpportunisticContainersStatus()
    • scheduleContainer

      @VisibleForTesting protected void scheduleContainer(Container container)
    • updateQueuingLimit

      public void updateQueuingLimit(org.apache.hadoop.yarn.server.api.records.ContainerQueuingLimit limit)
    • getContainersMonitor

      public ContainersMonitor getContainersMonitor()
    • getCurrentUtilization

      @VisibleForTesting public org.apache.hadoop.yarn.api.records.ResourceUtilization getCurrentUtilization()