Class LocalityAppPlacementAllocator<N extends SchedulerNode>
java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.AppPlacementAllocator<N>
org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.LocalityAppPlacementAllocator<N>
public class LocalityAppPlacementAllocator<N extends SchedulerNode>
extends AppPlacementAllocator<N>
This is an implementation of the
AppPlacementAllocator that takes
into account locality preferences (node, rack, any) when allocating
containers.-
Field Summary
Fields inherited from class org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.AppPlacementAllocator
appSchedulingInfo, rmContext, schedulerRequestKey -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocate(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, NodeType type, SchedulerNode node) Notify container allocated.booleancanAllocate(NodeType type, SchedulerNode node) We can still have pending requirement for a given NodeType and nodebooleancanDelayTo(String resourceName) Can delay to give locality?org.apache.hadoop.yarn.api.records.ResourceRequestcloneResourceRequest(org.apache.hadoop.yarn.api.records.ResourceRequest request) intgetOutstandingAsksCount(String resourceName) Get #pending-allocations for given resourceName.getPendingAsk(String resourceName) Get pending ask for given resourceName.It is possible that one request can accept multiple node partition, So this method returns primary node partition for pending resource / headroom calculation.Get pending ResourceRequests by given schedulerRequestKeyorg.apache.hadoop.yarn.api.records.SchedulingRequestGet pending SchedulingRequest.intvoidinitialize(AppSchedulingInfo appSchedulingInfo, org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerRequestKey, RMContext rmContext) Initialize this allocator, this will be called by Factory automatically.booleanprecheckNode(SchedulerNode schedulerNode, SchedulingMode schedulingMode) booleanprecheckNode(SchedulerNode schedulerNode, SchedulingMode schedulingMode, Optional<DiagnosticsCollector> dcOpt) Does thisAppPlacementAllocatoraccept resources on given node?voidPrint human-readable requests to LOG debug.updatePendingAsk(Collection<org.apache.hadoop.yarn.api.records.ResourceRequest> requests, boolean recoverPreemptedRequestForAContainer) Replace existing pending asks by the new requestsupdatePendingAsk(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerRequestKey, org.apache.hadoop.yarn.api.records.SchedulingRequest schedulingRequest, boolean recoverPreemptedRequestForAContainer) Replace existing pending asks by the new SchedulingRequestMethods inherited from class org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.AppPlacementAllocator
getPlacementAttempt, getPreferredNodeIterator, incrementPlacementAttempt
-
Constructor Details
-
LocalityAppPlacementAllocator
public LocalityAppPlacementAllocator()
-
-
Method Details
-
initialize
public void initialize(AppSchedulingInfo appSchedulingInfo, org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerRequestKey, RMContext rmContext) Description copied from class:AppPlacementAllocatorInitialize this allocator, this will be called by Factory automatically.- Overrides:
initializein classAppPlacementAllocator<N extends SchedulerNode>- Parameters:
appSchedulingInfo- appSchedulingInfoschedulerRequestKey- schedulerRequestKeyrmContext- rmContext
-
updatePendingAsk
public PendingAskUpdateResult updatePendingAsk(Collection<org.apache.hadoop.yarn.api.records.ResourceRequest> requests, boolean recoverPreemptedRequestForAContainer) Description copied from class:AppPlacementAllocatorReplace existing pending asks by the new requests- Specified by:
updatePendingAskin classAppPlacementAllocator<N extends SchedulerNode>- Parameters:
requests- new asksrecoverPreemptedRequestForAContainer- if we're recovering resource requests for preempted container- Returns:
- true if total pending resource changed
-
updatePendingAsk
public PendingAskUpdateResult updatePendingAsk(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerRequestKey, org.apache.hadoop.yarn.api.records.SchedulingRequest schedulingRequest, boolean recoverPreemptedRequestForAContainer) throws org.apache.hadoop.yarn.exceptions.SchedulerInvalidResourceRequestException Description copied from class:AppPlacementAllocatorReplace existing pending asks by the new SchedulingRequest- Specified by:
updatePendingAskin classAppPlacementAllocator<N extends SchedulerNode>- Parameters:
schedulerRequestKey- scheduler request keyschedulingRequest- new asksrecoverPreemptedRequestForAContainer- if we're recovering resource requests for preempted container- Returns:
- true if total pending resource changed
- Throws:
org.apache.hadoop.yarn.exceptions.SchedulerInvalidResourceRequestException
-
getResourceRequests
Description copied from class:AppPlacementAllocatorGet pending ResourceRequests by given schedulerRequestKey- Specified by:
getResourceRequestsin classAppPlacementAllocator<N extends SchedulerNode>- Returns:
- Map of resourceName to ResourceRequest
-
getPendingAsk
Description copied from class:AppPlacementAllocatorGet pending ask for given resourceName. If there's no such pendingAsk, returnsPendingAsk.ZERO- Specified by:
getPendingAskin classAppPlacementAllocator<N extends SchedulerNode>- Parameters:
resourceName- resourceName- Returns:
- PendingAsk
-
getOutstandingAsksCount
Description copied from class:AppPlacementAllocatorGet #pending-allocations for given resourceName. If there's no such pendingAsk, returns 0- Specified by:
getOutstandingAsksCountin classAppPlacementAllocator<N extends SchedulerNode>- Parameters:
resourceName- resourceName- Returns:
- #pending-allocations
-
cloneResourceRequest
public org.apache.hadoop.yarn.api.records.ResourceRequest cloneResourceRequest(org.apache.hadoop.yarn.api.records.ResourceRequest request) -
canAllocate
Description copied from class:AppPlacementAllocatorWe can still have pending requirement for a given NodeType and node- Specified by:
canAllocatein classAppPlacementAllocator<N extends SchedulerNode>- Parameters:
type- Locality Typenode- which node we will allocate on- Returns:
- true if we has pending requirement
-
canDelayTo
Description copied from class:AppPlacementAllocatorCan delay to give locality? TODO: This should be moved out of AppPlacementAllocator and should belong to specific delay scheduling policy impl. See YARN-7457 for more details.- Specified by:
canDelayToin classAppPlacementAllocator<N extends SchedulerNode>- Parameters:
resourceName- resourceName- Returns:
- can/cannot
-
precheckNode
public boolean precheckNode(SchedulerNode schedulerNode, SchedulingMode schedulingMode, Optional<DiagnosticsCollector> dcOpt) Description copied from class:AppPlacementAllocatorDoes thisAppPlacementAllocatoraccept resources on given node?- Specified by:
precheckNodein classAppPlacementAllocator<N extends SchedulerNode>- Parameters:
schedulerNode- schedulerNodeschedulingMode- schedulingModedcOpt- optional diagnostics collector- Returns:
- accepted/not
-
precheckNode
- Specified by:
precheckNodein classAppPlacementAllocator<N extends SchedulerNode>
-
getPrimaryRequestedNodePartition
Description copied from class:AppPlacementAllocatorIt is possible that one request can accept multiple node partition, So this method returns primary node partition for pending resource / headroom calculation.- Specified by:
getPrimaryRequestedNodePartitionin classAppPlacementAllocator<N extends SchedulerNode>- Returns:
- primary requested node partition
-
getUniqueLocationAsks
public int getUniqueLocationAsks()- Specified by:
getUniqueLocationAsksin classAppPlacementAllocator<N extends SchedulerNode>- Returns:
- number of unique location asks with #pending greater than 0, (like /rack1, host1, etc.). TODO: This should be moved out of AppPlacementAllocator and should belong to specific delay scheduling policy impl. See YARN-7457 for more details.
-
showRequests
public void showRequests()Description copied from class:AppPlacementAllocatorPrint human-readable requests to LOG debug.- Specified by:
showRequestsin classAppPlacementAllocator<N extends SchedulerNode>
-
allocate
public ContainerRequest allocate(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, NodeType type, SchedulerNode node) Description copied from class:AppPlacementAllocatorNotify container allocated.- Specified by:
allocatein classAppPlacementAllocator<N extends SchedulerNode>- Parameters:
schedulerKey- SchedulerRequestKey for this ResourceRequesttype- Type of the allocationnode- Which node this container allocated on- Returns:
- ContainerRequest which include resource requests associated with
the container. This will be used by scheduler to recover requests.
Please refer to
ContainerRequestfor more details.
-
getSchedulingRequest
public org.apache.hadoop.yarn.api.records.SchedulingRequest getSchedulingRequest()Description copied from class:AppPlacementAllocatorGet pending SchedulingRequest.- Specified by:
getSchedulingRequestin classAppPlacementAllocator<N extends SchedulerNode>- Returns:
- SchedulingRequest
-