Class OpportunisticContainerAllocator

java.lang.Object
org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerAllocator
Direct Known Subclasses:
DistributedOpportunisticContainerAllocator

public abstract class OpportunisticContainerAllocator extends Object

Base abstract class for Opportunistic container allocations, that provides common functions required for Opportunistic container allocation.

  • Constructor Details

    • OpportunisticContainerAllocator

      public OpportunisticContainerAllocator(BaseContainerTokenSecretManager tokenSecretManager)
      Create a new Opportunistic Container Allocator.
      Parameters:
      tokenSecretManager - TokenSecretManager
    • OpportunisticContainerAllocator

      public OpportunisticContainerAllocator(BaseContainerTokenSecretManager tokenSecretManager, int maxAllocationsPerAMHeartbeat)
      Create a new Opportunistic Container Allocator.
      Parameters:
      tokenSecretManager - TokenSecretManager
      maxAllocationsPerAMHeartbeat - max number of containers to be allocated in one AM heartbeat
  • Method Details

    • setMaxAllocationsPerAMHeartbeat

      public void setMaxAllocationsPerAMHeartbeat(int maxAllocationsPerAMHeartbeat)
    • getMaxAllocationsPerAMHeartbeat

      public int getMaxAllocationsPerAMHeartbeat()
      Get the Max Allocations per AM heartbeat.
      Returns:
      maxAllocationsPerAMHeartbeat.
    • allocateContainers

      public abstract List<org.apache.hadoop.yarn.api.records.Container> allocateContainers(org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest blackList, List<org.apache.hadoop.yarn.api.records.ResourceRequest> oppResourceReqs, org.apache.hadoop.yarn.api.records.ApplicationAttemptId applicationAttemptId, OpportunisticContainerContext opportContext, long rmIdentifier, String appSubmitter) throws org.apache.hadoop.yarn.exceptions.YarnException
      Allocate OPPORTUNISTIC containers.
      Parameters:
      blackList - Resource BlackList Request
      oppResourceReqs - Opportunistic Resource Requests
      applicationAttemptId - ApplicationAttemptId
      opportContext - App specific OpportunisticContainerContext
      rmIdentifier - RM Identifier
      appSubmitter - App Submitter
      Returns:
      List of Containers.
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException - YarnException
    • updateBlacklist

      protected void updateBlacklist(org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest blackList, OpportunisticContainerContext oppContext)
    • matchAllocation

      protected void matchAllocation(List<Map<org.apache.hadoop.yarn.api.records.Resource,List<OpportunisticContainerAllocator.Allocation>>> allocations, List<org.apache.hadoop.yarn.api.records.Container> allocatedContainers, OpportunisticContainerContext oppContext)
    • getTotalAllocations

      protected int getTotalAllocations(List<Map<org.apache.hadoop.yarn.api.records.Resource,List<OpportunisticContainerAllocator.Allocation>>> allocations)
    • createContainer

      protected org.apache.hadoop.yarn.api.records.Container createContainer(long rmIdentifier, OpportunisticContainerAllocator.AllocationParams appParams, OpportunisticContainerAllocator.ContainerIdGenerator idCounter, org.apache.hadoop.yarn.api.records.ApplicationAttemptId id, String userName, Map<org.apache.hadoop.yarn.api.records.Resource,List<OpportunisticContainerAllocator.Allocation>> allocations, String location, org.apache.hadoop.yarn.api.records.ResourceRequest anyAsk, RemoteNode rNode) throws org.apache.hadoop.yarn.exceptions.YarnException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
    • partitionAskList

      public OpportunisticContainerAllocator.PartitionedResourceRequests partitionAskList(List<org.apache.hadoop.yarn.api.records.ResourceRequest> askList)
      Partitions a list of ResourceRequest to two separate lists, one for GUARANTEED and one for OPPORTUNISTIC ResourceRequests.
      Parameters:
      askList - the list of ResourceRequests to be partitioned
      Returns:
      the partitioned ResourceRequests
    • getRequestPartition

      protected String getRequestPartition(OpportunisticContainerAllocator.EnrichedResourceRequest enrichedRR)
    • getRemoteNodePartition

      protected String getRemoteNodePartition(RemoteNode node)