Class OpportunisticContainerAllocator
java.lang.Object
org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerAllocator
- Direct Known Subclasses:
DistributedOpportunisticContainerAllocator
Base abstract class for Opportunistic container allocations, that provides common functions required for Opportunistic container allocation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class encapsulates container and resourceName for an allocation.static classThis class encapsulates application specific parameters used to build a Container.static classA Container Id Generator.static classThis class encapsulates Resource Request and provides requests per node and rack.static classClass that includes two lists ofResourceRequests: one for GUARANTEED and one for OPPORTUNISTICResourceRequests. -
Constructor Summary
ConstructorsConstructorDescriptionOpportunisticContainerAllocator(BaseContainerTokenSecretManager tokenSecretManager) Create a new Opportunistic Container Allocator.OpportunisticContainerAllocator(BaseContainerTokenSecretManager tokenSecretManager, int maxAllocationsPerAMHeartbeat) Create a new Opportunistic Container Allocator. -
Method Summary
Modifier and TypeMethodDescriptionabstract 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) Allocate OPPORTUNISTIC containers.protected org.apache.hadoop.yarn.api.records.ContainercreateContainer(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) intGet the Max Allocations per AM heartbeat.protected Stringprotected Stringprotected intgetTotalAllocations(List<Map<org.apache.hadoop.yarn.api.records.Resource, List<OpportunisticContainerAllocator.Allocation>>> allocations) protected voidmatchAllocation(List<Map<org.apache.hadoop.yarn.api.records.Resource, List<OpportunisticContainerAllocator.Allocation>>> allocations, List<org.apache.hadoop.yarn.api.records.Container> allocatedContainers, OpportunisticContainerContext oppContext) 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.voidsetMaxAllocationsPerAMHeartbeat(int maxAllocationsPerAMHeartbeat) protected voidupdateBlacklist(org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest blackList, OpportunisticContainerContext oppContext)
-
Constructor Details
-
OpportunisticContainerAllocator
Create a new Opportunistic Container Allocator.- Parameters:
tokenSecretManager- TokenSecretManager
-
OpportunisticContainerAllocator
public OpportunisticContainerAllocator(BaseContainerTokenSecretManager tokenSecretManager, int maxAllocationsPerAMHeartbeat) Create a new Opportunistic Container Allocator.- Parameters:
tokenSecretManager- TokenSecretManagermaxAllocationsPerAMHeartbeat- 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 RequestoppResourceReqs- Opportunistic Resource RequestsapplicationAttemptId- ApplicationAttemptIdopportContext- App specific OpportunisticContainerContextrmIdentifier- RM IdentifierappSubmitter- 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
-