Class AbstractYarnScheduler<T extends SchedulerApplicationAttempt,N extends SchedulerNode>
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler<T,N>
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service,org.apache.hadoop.yarn.event.EventHandler<SchedulerEvent>,Recoverable,ResourceScheduler,YarnScheduler
- Direct Known Subclasses:
CapacityScheduler,FairScheduler,FifoScheduler
@Private
@Unstable
public abstract class AbstractYarnScheduler<T extends SchedulerApplicationAttempt,N extends SchedulerNode>
extends org.apache.hadoop.service.AbstractService
implements ResourceScheduler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classContainerObjectType is a container object with the following properties.Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ActivitiesManagerprotected ConcurrentMap<org.apache.hadoop.yarn.api.records.ApplicationId,SchedulerApplication<T>> protected static final Allocationprotected longprotected org.apache.hadoop.yarn.api.records.Resourceprotected intprotected longprotected final ClusterNodeTracker<N>protected final ReentrantReadWriteLock.ReadLockprotected RMContextprotected SchedulerHealthprotected SchedulingMonitorManagerprotected final longprotected longTo enable the update thread, subclasses should set updateInterval to a positive value duringserviceInit(Configuration).protected final ReentrantReadWriteLock.WriteLock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd to the scheduler a new Queue.voidasyncContainerRelease(RMContainer container) To be used to release a container via a Scheduler Event rather than in the same thread.booleanattemptAllocationOnNode(SchedulerApplicationAttempt appAttempt, org.apache.hadoop.yarn.api.records.SchedulingRequest schedulingRequest, SchedulerNode schedulerNode) Default implementation.protected voidautoCorrectContainerAllocation(List<org.apache.hadoop.yarn.api.records.ResourceRequest> resourceRequests, SchedulerApplicationAttempt application) Autocorrect container resourceRequests by decrementing the number of newly allocated containers from the current container request.longcheckAndGetApplicationLifetime(String queueName, long lifetime, RMAppImpl app) Verify whether a submitted application lifetime is valid as per configured Queue lifetime.org.apache.hadoop.yarn.api.records.PrioritycheckAndGetApplicationPriority(org.apache.hadoop.yarn.api.records.Priority priorityRequestedByApp, org.apache.hadoop.security.UserGroupInformation user, String queuePath, org.apache.hadoop.yarn.api.records.ApplicationId applicationId) Verify whether a submitted application priority is valid as per configured QueuevoidvoidcompletedContainer(RMContainer rmContainer, org.apache.hadoop.yarn.api.records.ContainerStatus containerStatus, RMContainerEventType event) protected abstract voidcompletedContainerInternal(RMContainer rmContainer, org.apache.hadoop.yarn.api.records.ContainerStatus containerStatus, RMContainerEventType event) protected voidcontainerIncreasedOnNode(org.apache.hadoop.yarn.api.records.ContainerId containerId, SchedulerNode node, org.apache.hadoop.yarn.api.records.Container increasedContainerReportedByNM) protected voidcontainerLaunchedOnNode(org.apache.hadoop.yarn.api.records.ContainerId containerId, SchedulerNode node) protected voidprotected List<SchedContainerChangeRequest>createSchedContainerChangeRequests(List<org.apache.hadoop.yarn.api.records.UpdateContainerRequest> changeRequests, boolean increase) getApplicationAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId applicationAttemptId) org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReportgetAppResourceUsageReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId) Get a resource usage report from a given app attempt ID.Add blacklisted NodeIds to the list that is passed.org.apache.hadoop.yarn.util.ClockgetClock()org.apache.hadoop.yarn.api.records.ResourceGet the whole resource capacity of the cluster.getCurrentAttemptForContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) longorg.apache.hadoop.yarn.api.records.PriorityGet cluster max priority.org.apache.hadoop.yarn.api.records.ResourceGet a Resource object with for the maximum allocation possible.longgetMaximumApplicationLifetime(String queueName) Get maximum lifetime for a queue.org.apache.hadoop.yarn.api.records.ResourceGet maximum allocatableResourceat the cluster level.org.apache.hadoop.yarn.api.records.ResourcegetMaximumResourceCapability(String queueName) Get maximum allocatableResourcefor the queue specified.org.apache.hadoop.yarn.api.records.Resourceorg.apache.hadoop.yarn.api.records.ResourceGet minimum allocatableResource.getNode(org.apache.hadoop.yarn.api.records.NodeId nodeId) List<org.apache.hadoop.yarn.api.records.NodeId>getNodeIds(String resourceName) Get theNodeIdavailable in the cluster by resource name.getNodeReport(org.apache.hadoop.yarn.api.records.NodeId nodeId) Get node resource usage report.getNodes(NodeFilter filter) org.apache.hadoop.yarn.api.records.ResourcegetNormalizedResource(org.apache.hadoop.yarn.api.records.Resource requestedResource, org.apache.hadoop.yarn.api.records.Resource maxResourceCapability) Normalize a resource request using scheduler level maximum resource or queue based maximum resource.List<org.apache.hadoop.yarn.api.records.ResourceRequest>getPendingResourceRequestsForAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId) Get pending resource request for specified application attempt.List<org.apache.hadoop.yarn.api.records.SchedulingRequest>getPendingSchedulingRequestsForAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId) Get pending scheduling request for specified application attempt.Gets the list of names for queues managed by the Reservation System.getRMContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Get the container for the given containerId.getSchedulerAppInfo(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId) Get the Scheduler app for a given app attempt Id.Map<org.apache.hadoop.yarn.api.records.ApplicationId,SchedulerApplication<T>> getSchedulerNode(org.apache.hadoop.yarn.api.records.NodeId nodeId) Get SchedulerNode corresponds to nodeId.EnumSet<org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes>Return a collection of the resource types that are considered when schedulinglongList<org.apache.hadoop.yarn.api.records.Container>getTransferredContainers(org.apache.hadoop.yarn.api.records.ApplicationAttemptId currentAttempt) Get previous attempts' live containers for work-preserving AM restart.protected voidhandleContainerUpdates(SchedulerApplicationAttempt appAttempt, ContainerUpdates updates) protected voidinitMaximumResourceCapability(org.apache.hadoop.yarn.api.records.Resource maximumAllocation) voidkillAllAppsInQueue(String queueName) Terminate all applications in the specified queue.abstract voidkillContainer(RMContainer container) Kill a RMContainer.voidmoveAllApps(String sourceQueue, String destQueue) Completely drain sourceQueue of applications, by moving all of them to destQueue.moveApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId, String newQueue) Moves the given application to the given queue.protected voidnodeUpdate(RMNode nm) Process a heartbeat update from a node.protected voidnormalizeResourceRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> asks) Normalize a list of resource requests.protected voidnormalizeResourceRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> asks, String queueName) Normalize a list of resource requests using queue maximum resource allocations.booleanBy default placement constraint is disabled.voidpreValidateMoveApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId, String newQueue) voidrecoverContainersOnNode(List<org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus> containerReports, RMNode nm) protected voidrefreshMaximumAllocation(org.apache.hadoop.yarn.api.records.Resource newMaxAlloc) voidreinitialize(org.apache.hadoop.conf.Configuration conf, RMContext rmContext) Re-initialize theResourceScheduler.protected voidreleaseContainers(List<org.apache.hadoop.yarn.api.records.ContainerId> containers, SchedulerApplicationAttempt attempt) voidremoveQueue(String queueName) Remove an existing queue.voidReset scheduler metrics.protected voidrollbackContainerUpdate(org.apache.hadoop.yarn.api.records.ContainerId containerId) Rollback container update after expiry.voidserviceInit(org.apache.hadoop.conf.Configuration conf) protected voidprotected voidvoidsetClock(org.apache.hadoop.yarn.util.Clock clock) voidsetClusterMaxPriority(org.apache.hadoop.conf.Configuration conf) Set the cluster max priority.voidsetEntitlement(String queue, QueueEntitlement entitlement) This method increase the entitlement for current queue (must respect invariants, e.g., no overcommit of parents, non negative, etc.).protected voidsetLastNodeUpdateTime(long time) booleanprotected voidAllowsAbstractYarnScheduler<T extends SchedulerApplicationAttempt,to start processing without waiting tillN extends SchedulerNode>.org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler.UpdateThread updateInterval.voidupdate()Update internal state of the scheduler.org.apache.hadoop.yarn.api.records.PriorityupdateApplicationPriority(org.apache.hadoop.yarn.api.records.Priority newPriority, org.apache.hadoop.yarn.api.records.ApplicationId applicationId, org.apache.hadoop.thirdparty.com.google.common.util.concurrent.SettableFuture<Object> future, org.apache.hadoop.security.UserGroupInformation user) Change application priority of a submitted application at runtimevoidupdateNodeResource(RMNode nm, org.apache.hadoop.yarn.api.records.ResourceOption resourceOption) Process resource update on a node.protected voidupdateNodeResourceUtilization(RMNode nm, SchedulerNode schedulerNode) Update container and utilization information on the NodeManager.protected voidupdateSchedulerHealthInformation(org.apache.hadoop.yarn.api.records.Resource releasedResources, int releasedContainers) Update schedulerHealth information.Methods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.yarn.event.EventHandler
handleMethods inherited from interface org.apache.hadoop.yarn.server.resourcemanager.recovery.Recoverable
recoverMethods inherited from interface org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler
setRMContextMethods inherited from interface org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler
allocate, checkAccess, getAppsInQueue, getNumClusterNodes, getQueueInfo, getQueueUserAclInfo, getResourceCalculator, getRootQueueMetrics
-
Field Details
-
nodeTracker
-
minimumAllocation
protected org.apache.hadoop.yarn.api.records.Resource minimumAllocation -
rmContext
-
activitiesManager
-
schedulerHealth
-
lastNodeUpdateTime
protected volatile long lastNodeUpdateTime -
THREAD_JOIN_TIMEOUT_MS
protected final long THREAD_JOIN_TIMEOUT_MS- See Also:
-
updateInterval
protected long updateIntervalTo enable the update thread, subclasses should set updateInterval to a positive value duringserviceInit(Configuration). -
applications
protected ConcurrentMap<org.apache.hadoop.yarn.api.records.ApplicationId,SchedulerApplication<T extends SchedulerApplicationAttempt>> applications -
nmExpireInterval
protected int nmExpireInterval -
nmHeartbeatInterval
protected long nmHeartbeatInterval -
EMPTY_ALLOCATION
-
readLock
-
writeLock
-
schedulingMonitorManager
-
-
Constructor Details
-
AbstractYarnScheduler
Construct the service.- Parameters:
name- service name
-
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
getNodeTracker
-
getSchedulingMonitorManager
-
getTransferredContainers
public List<org.apache.hadoop.yarn.api.records.Container> getTransferredContainers(org.apache.hadoop.yarn.api.records.ApplicationAttemptId currentAttempt) Description copied from interface:YarnSchedulerGet previous attempts' live containers for work-preserving AM restart.- Specified by:
getTransferredContainersin interfaceYarnScheduler- Parameters:
currentAttempt- the id of the application attempt- Returns:
- list of live containers for the given attempt
-
getSchedulerApplications
public Map<org.apache.hadoop.yarn.api.records.ApplicationId,SchedulerApplication<T>> getSchedulerApplications() -
getBlacklistedNodes
Add blacklisted NodeIds to the list that is passed.- Parameters:
app- application attempt.- Returns:
- blacklisted NodeIds.
-
getNodes
-
shouldContainersBeAutoUpdated
public boolean shouldContainersBeAutoUpdated() -
getClusterResource
public org.apache.hadoop.yarn.api.records.Resource getClusterResource()Description copied from interface:YarnSchedulerGet the whole resource capacity of the cluster.- Specified by:
getClusterResourcein interfaceYarnScheduler- Returns:
- the whole resource capacity of the cluster.
-
getMinimumResourceCapability
public org.apache.hadoop.yarn.api.records.Resource getMinimumResourceCapability()Description copied from interface:YarnSchedulerGet minimum allocatableResource.- Specified by:
getMinimumResourceCapabilityin interfaceYarnScheduler- Returns:
- minimum allocatable resource
-
getMaximumResourceCapability
public org.apache.hadoop.yarn.api.records.Resource getMaximumResourceCapability()Description copied from interface:YarnSchedulerGet maximum allocatableResourceat the cluster level.- Specified by:
getMaximumResourceCapabilityin interfaceYarnScheduler- Returns:
- maximum allocatable resource
-
getMaximumResourceCapability
Description copied from interface:YarnSchedulerGet maximum allocatableResourcefor the queue specified.- Specified by:
getMaximumResourceCapabilityin interfaceYarnScheduler- Parameters:
queueName- queue name- Returns:
- maximum allocatable resource
-
initMaximumResourceCapability
protected void initMaximumResourceCapability(org.apache.hadoop.yarn.api.records.Resource maximumAllocation) -
getSchedulerHealth
-
setLastNodeUpdateTime
protected void setLastNodeUpdateTime(long time) -
getLastNodeUpdateTime
public long getLastNodeUpdateTime() -
getSkipNodeInterval
public long getSkipNodeInterval() -
containerLaunchedOnNode
protected void containerLaunchedOnNode(org.apache.hadoop.yarn.api.records.ContainerId containerId, SchedulerNode node) -
containerIncreasedOnNode
protected void containerIncreasedOnNode(org.apache.hadoop.yarn.api.records.ContainerId containerId, SchedulerNode node, org.apache.hadoop.yarn.api.records.Container increasedContainerReportedByNM) -
getApplicationAttempt
public T getApplicationAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId applicationAttemptId) -
getSchedulerAppInfo
public SchedulerAppReport getSchedulerAppInfo(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId) Description copied from interface:YarnSchedulerGet the Scheduler app for a given app attempt Id.- Specified by:
getSchedulerAppInfoin interfaceYarnScheduler- Parameters:
appAttemptId- the id of the application attempt- Returns:
- SchedulerApp for this given attempt.
-
getAppResourceUsageReport
public org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport getAppResourceUsageReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptId appAttemptId) Description copied from interface:YarnSchedulerGet a resource usage report from a given app attempt ID.- Specified by:
getAppResourceUsageReportin interfaceYarnScheduler- Parameters:
appAttemptId- the id of the application attempt- Returns:
- resource usage report for this given attempt
-
getCurrentAttemptForContainer
-
getRMContainer
Description copied from interface:YarnSchedulerGet the container for the given containerId.- Specified by:
getRMContainerin interfaceYarnScheduler- Parameters:
containerId- the given containerId.- Returns:
- the container for the given containerId.
-
getNodeReport
Description copied from interface:YarnSchedulerGet node resource usage report.- Specified by:
getNodeReportin interfaceYarnScheduler- Parameters:
nodeId- nodeId.- Returns:
- the
SchedulerNodeReportfor the node or null if nodeId does not point to a defined node.
-
moveApplication
public String moveApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId, String newQueue) throws org.apache.hadoop.yarn.exceptions.YarnException Description copied from interface:YarnSchedulerMoves the given application to the given queue.- Specified by:
moveApplicationin interfaceYarnScheduler- Parameters:
appId- application IdnewQueue- the given queue.- Returns:
- the name of the queue the application was placed into
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if the move cannot be carried out
-
preValidateMoveApplication
public void preValidateMoveApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId, String newQueue) throws org.apache.hadoop.yarn.exceptions.YarnException - Specified by:
preValidateMoveApplicationin interfaceYarnScheduler- Parameters:
appId- Application IDnewQueue- Target QueueName- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if the pre-validation for move cannot be carried out
-
removeQueue
Description copied from interface:YarnSchedulerRemove an existing queue. Implementations might limit when a queue could be removed (e.g., must have zero entitlement, and no applications running, or must be a leaf, etc..).- Specified by:
removeQueuein interfaceYarnScheduler- Parameters:
queueName- name of the queue to remove- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when yarn exception occur.
-
addQueue
public void addQueue(Queue newQueue) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException Description copied from interface:YarnSchedulerAdd to the scheduler a new Queue. Implementations might limit what type of queues can be dynamically added (e.g., Queue must be a leaf, must be attached to existing parent, must have zero entitlement).- Specified by:
addQueuein interfaceYarnScheduler- Parameters:
newQueue- the queue being added.- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when yarn exception occur.IOException- when io exception occur.
-
setEntitlement
public void setEntitlement(String queue, QueueEntitlement entitlement) throws org.apache.hadoop.yarn.exceptions.YarnException Description copied from interface:YarnSchedulerThis method increase the entitlement for current queue (must respect invariants, e.g., no overcommit of parents, non negative, etc.). Entitlement is a general term for weights in FairScheduler, capacity for the CapacityScheduler, etc.- Specified by:
setEntitlementin interfaceYarnScheduler- Parameters:
queue- the queue for which we change entitlemententitlement- the new entitlement for the queue (capacity, maxCapacity, etc..)- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when yarn exception occur.
-
recoverContainersOnNode
-
autoCorrectContainerAllocation
@VisibleForTesting protected void autoCorrectContainerAllocation(List<org.apache.hadoop.yarn.api.records.ResourceRequest> resourceRequests, SchedulerApplicationAttempt application) Autocorrect container resourceRequests by decrementing the number of newly allocated containers from the current container request. This also updates the newlyAllocatedContainers to be within the limits of the current container resourceRequests. ResourceRequests locality/resourceName is not considered while autocorrecting the container request, hence when there are two types of resourceRequest which is same except for the locality/resourceName, it is counted as sameAbstractYarnScheduler<T extends SchedulerApplicationAttempt,and the container ask and number of newly allocated container is decremented accordingly. For example when a client requests for 4 containers with locality/resourceName as "node1", AMRMClientaugments the resourceRequest into two where R1(numContainer=4,locality=*) and R2(numContainer=4,locality=node1), if Yarn allocated 6 containers previously, it will release 2 containers as well as update the container ask to 0. If there is a client which directly calls Yarn (without AMRMClient) with two where R1(numContainer=4,locality=*) and R2(numContainer=4,locality=node1) the autocorrection may not work as expected. The use case of such client is very rare.N extends SchedulerNode>.ContainerObjectType This method is called from
YarnScheduler.allocate(org.apache.hadoop.yarn.api.records.ApplicationAttemptId, java.util.List<org.apache.hadoop.yarn.api.records.ResourceRequest>, java.util.List<org.apache.hadoop.yarn.api.records.SchedulingRequest>, java.util.List<org.apache.hadoop.yarn.api.records.ContainerId>, java.util.List<java.lang.String>, java.util.List<java.lang.String>, org.apache.hadoop.yarn.server.resourcemanager.scheduler.ContainerUpdates)method. It is package private to be used within the scheduler package only.- Parameters:
resourceRequests- List of resources to be allocatedapplication- ApplicationAttempt
-
createReleaseCache
protected void createReleaseCache() -
clearPendingContainerCache
@VisibleForTesting public void clearPendingContainerCache() -
completedContainer
@VisibleForTesting @Private public void completedContainer(RMContainer rmContainer, org.apache.hadoop.yarn.api.records.ContainerStatus containerStatus, RMContainerEventType event) -
completedContainerInternal
protected abstract void completedContainerInternal(RMContainer rmContainer, org.apache.hadoop.yarn.api.records.ContainerStatus containerStatus, RMContainerEventType event) -
releaseContainers
protected void releaseContainers(List<org.apache.hadoop.yarn.api.records.ContainerId> containers, SchedulerApplicationAttempt attempt) -
getSchedulerNode
Description copied from interface:YarnSchedulerGet SchedulerNode corresponds to nodeId.- Specified by:
getSchedulerNodein interfaceYarnScheduler- Parameters:
nodeId- the node id of RMNode- Returns:
- SchedulerNode corresponds to nodeId
-
moveAllApps
public void moveAllApps(String sourceQueue, String destQueue) throws org.apache.hadoop.yarn.exceptions.YarnException Description copied from interface:YarnSchedulerCompletely drain sourceQueue of applications, by moving all of them to destQueue.- Specified by:
moveAllAppsin interfaceYarnScheduler- Parameters:
sourceQueue- sourceQueue.destQueue- destQueue.- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when yarn exception occur.
-
killAllAppsInQueue
public void killAllAppsInQueue(String queueName) throws org.apache.hadoop.yarn.exceptions.YarnException Description copied from interface:YarnSchedulerTerminate all applications in the specified queue.- Specified by:
killAllAppsInQueuein interfaceYarnScheduler- Parameters:
queueName- the name of queue to be drained- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when yarn exception occur.
-
updateNodeResource
public void updateNodeResource(RMNode nm, org.apache.hadoop.yarn.api.records.ResourceOption resourceOption) Process resource update on a node.- Parameters:
nm- RMNode.resourceOption- resourceOption.
-
getSchedulingResourceTypes
public EnumSet<org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes> getSchedulingResourceTypes()Return a collection of the resource types that are considered when scheduling- Specified by:
getSchedulingResourceTypesin interfaceYarnScheduler- Returns:
- an EnumSet containing the resource types
-
getPlanQueues
Description copied from interface:YarnSchedulerGets the list of names for queues managed by the Reservation System.- Specified by:
getPlanQueuesin interfaceYarnScheduler- Returns:
- the list of queues which support reservations
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when yarn exception occur.
-
placementConstraintEnabled
public boolean placementConstraintEnabled()By default placement constraint is disabled. Schedulers which support placement constraint can override this value.- Returns:
- enabled or not
-
refreshMaximumAllocation
protected void refreshMaximumAllocation(org.apache.hadoop.yarn.api.records.Resource newMaxAlloc) -
getPendingResourceRequestsForAttempt
public List<org.apache.hadoop.yarn.api.records.ResourceRequest> getPendingResourceRequestsForAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId) Description copied from interface:YarnSchedulerGet pending resource request for specified application attempt.- Specified by:
getPendingResourceRequestsForAttemptin interfaceYarnScheduler- Parameters:
attemptId- the id of the application attempt- Returns:
- pending resource requests.
-
getPendingSchedulingRequestsForAttempt
public List<org.apache.hadoop.yarn.api.records.SchedulingRequest> getPendingSchedulingRequestsForAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId) Description copied from interface:YarnSchedulerGet pending scheduling request for specified application attempt.- Specified by:
getPendingSchedulingRequestsForAttemptin interfaceYarnScheduler- Parameters:
attemptId- the id of the application attempt- Returns:
- pending scheduling requests
-
checkAndGetApplicationPriority
public org.apache.hadoop.yarn.api.records.Priority checkAndGetApplicationPriority(org.apache.hadoop.yarn.api.records.Priority priorityRequestedByApp, org.apache.hadoop.security.UserGroupInformation user, String queuePath, org.apache.hadoop.yarn.api.records.ApplicationId applicationId) throws org.apache.hadoop.yarn.exceptions.YarnException Description copied from interface:YarnSchedulerVerify whether a submitted application priority is valid as per configured Queue- Specified by:
checkAndGetApplicationPriorityin interfaceYarnScheduler- Parameters:
priorityRequestedByApp- Submitted Application priority.user- User who submitted the ApplicationqueuePath- Name of the QueueapplicationId- Application ID- Returns:
- Updated Priority from scheduler
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when yarn exception occur.
-
updateApplicationPriority
public org.apache.hadoop.yarn.api.records.Priority updateApplicationPriority(org.apache.hadoop.yarn.api.records.Priority newPriority, org.apache.hadoop.yarn.api.records.ApplicationId applicationId, org.apache.hadoop.thirdparty.com.google.common.util.concurrent.SettableFuture<Object> future, org.apache.hadoop.security.UserGroupInformation user) throws org.apache.hadoop.yarn.exceptions.YarnException Description copied from interface:YarnSchedulerChange application priority of a submitted application at runtime- Specified by:
updateApplicationPriorityin interfaceYarnScheduler- Parameters:
newPriority- Submitted Application priority.applicationId- Application IDfuture- Sets any type of exception happened from StateStoreuser- who submitted the application- Returns:
- updated priority
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when yarn exception occur.
-
getMaxClusterLevelAppPriority
public org.apache.hadoop.yarn.api.records.Priority getMaxClusterLevelAppPriority()Description copied from interface:YarnSchedulerGet cluster max priority.- Specified by:
getMaxClusterLevelAppPriorityin interfaceYarnScheduler- Returns:
- maximum priority of cluster
-
setClusterMaxPriority
public void setClusterMaxPriority(org.apache.hadoop.conf.Configuration conf) throws org.apache.hadoop.yarn.exceptions.YarnException Description copied from interface:YarnSchedulerSet the cluster max priority.- Specified by:
setClusterMaxPriorityin interfaceYarnScheduler- Parameters:
conf- Configuration.- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when yarn exception occur.
-
createSchedContainerChangeRequests
protected List<SchedContainerChangeRequest> createSchedContainerChangeRequests(List<org.apache.hadoop.yarn.api.records.UpdateContainerRequest> changeRequests, boolean increase) -
getActivitiesManager
-
getClock
public org.apache.hadoop.yarn.util.Clock getClock() -
setClock
@VisibleForTesting public void setClock(org.apache.hadoop.yarn.util.Clock clock) -
getNode
@Lock(org.apache.hadoop.yarn.server.utils.Lock.NoLock.class) public SchedulerNode getNode(org.apache.hadoop.yarn.api.records.NodeId nodeId) -
updateSchedulerHealthInformation
protected void updateSchedulerHealthInformation(org.apache.hadoop.yarn.api.records.Resource releasedResources, int releasedContainers) Update schedulerHealth information.- Parameters:
releasedResources- Reference resource object for completed containersreleasedContainers- Count of released containers
-
updateNodeResourceUtilization
Update container and utilization information on the NodeManager.- Parameters:
nm- The NodeManager to updateschedulerNode- schedulerNode
-
nodeUpdate
Process a heartbeat update from a node.- Parameters:
nm- The RMNode corresponding to the NodeManager
-
getNormalizedResource
public org.apache.hadoop.yarn.api.records.Resource getNormalizedResource(org.apache.hadoop.yarn.api.records.Resource requestedResource, org.apache.hadoop.yarn.api.records.Resource maxResourceCapability) Description copied from interface:YarnSchedulerNormalize a resource request using scheduler level maximum resource or queue based maximum resource.- Specified by:
getNormalizedResourcein interfaceYarnScheduler- Parameters:
requestedResource- the resource to be normalizedmaxResourceCapability- Maximum container allocation value, if null or empty scheduler level maximum container allocation value will be used- Returns:
- the normalized resource
-
normalizeResourceRequests
protected void normalizeResourceRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> asks) Normalize a list of resource requests.- Parameters:
asks- resource requests
-
normalizeResourceRequests
protected void normalizeResourceRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> asks, String queueName) Normalize a list of resource requests using queue maximum resource allocations.- Parameters:
asks- resource requestsqueueName- queue Name.
-
handleContainerUpdates
protected void handleContainerUpdates(SchedulerApplicationAttempt appAttempt, ContainerUpdates updates) -
rollbackContainerUpdate
protected void rollbackContainerUpdate(org.apache.hadoop.yarn.api.records.ContainerId containerId) Rollback container update after expiry.- Parameters:
containerId- ContainerId.
-
getNodeIds
Description copied from interface:ResourceSchedulerGet theNodeIdavailable in the cluster by resource name.- Specified by:
getNodeIdsin interfaceResourceScheduler- Parameters:
resourceName- resource name- Returns:
- the number of available
NodeIdby resource name.
-
asyncContainerRelease
To be used to release a container via a Scheduler Event rather than in the same thread.- Parameters:
container- Container.
-
getMinimumAllocation
public org.apache.hadoop.yarn.api.records.Resource getMinimumAllocation() -
getMaximumAllocation
public org.apache.hadoop.yarn.api.records.Resource getMaximumAllocation()Get a Resource object with for the maximum allocation possible.- Returns:
- a Resource object with the maximum allocation for the scheduler
-
checkAndGetApplicationLifetime
Description copied from interface:YarnSchedulerVerify whether a submitted application lifetime is valid as per configured Queue lifetime.- Specified by:
checkAndGetApplicationLifetimein interfaceYarnScheduler- Parameters:
queueName- Name of the Queuelifetime- configured application lifetimeapp- details of app- Returns:
- valid lifetime as per queue
-
getMaximumApplicationLifetime
Description copied from interface:YarnSchedulerGet maximum lifetime for a queue.- Specified by:
getMaximumApplicationLifetimein interfaceYarnScheduler- Parameters:
queueName- to get lifetime- Returns:
- maximum lifetime in seconds
-
killContainer
Kill a RMContainer. This is meant to be called in tests only to simulate AM container failures.- Parameters:
container- the container to kill
-
update
@VisibleForTesting public void update()Update internal state of the scheduler. This can be useful for scheduler implementations that maintain some state that needs to be periodically updated; for example, metrics or queue resources. It will be called by theAbstractYarnScheduler<T extends SchedulerApplicationAttempt,everyN extends SchedulerNode>.org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler.UpdateThread updateInterval. By default, it will not run; subclasses should setupdateIntervalto a positive value duringserviceInit(Configuration)if they want to enable the thread. -
triggerUpdate
protected void triggerUpdate()AllowsAbstractYarnScheduler<T extends SchedulerApplicationAttempt,to start processing without waiting tillN extends SchedulerNode>.org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler.UpdateThread updateInterval. -
reinitialize
public void reinitialize(org.apache.hadoop.conf.Configuration conf, RMContext rmContext) throws IOException Description copied from interface:ResourceSchedulerRe-initialize theResourceScheduler.- Specified by:
reinitializein interfaceResourceScheduler- Parameters:
conf- configurationrmContext- RMContext.- Throws:
IOException- an I/O exception has occurred.
-
attemptAllocationOnNode
public boolean attemptAllocationOnNode(SchedulerApplicationAttempt appAttempt, org.apache.hadoop.yarn.api.records.SchedulingRequest schedulingRequest, SchedulerNode schedulerNode) Default implementation. Always returns false.- Specified by:
attemptAllocationOnNodein interfaceResourceScheduler- Parameters:
appAttempt- ApplicationAttempt.schedulingRequest- SchedulingRequest.schedulerNode- SchedulerNode.- Returns:
- Success or not.
-
resetSchedulerMetrics
public void resetSchedulerMetrics()Description copied from interface:ResourceSchedulerReset scheduler metrics.- Specified by:
resetSchedulerMetricsin interfaceResourceScheduler
-