Class SchedulerApplicationAttempt
java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt
- All Implemented Interfaces:
SchedulableEntity
- Direct Known Subclasses:
FiCaSchedulerApp,FSAppAttempt
@Private
@Unstable
public class SchedulerApplicationAttempt
extends Object
implements SchedulableEntity
Represents an application attempt from the viewpoint of the scheduler.
Each running app attempt in the RM corresponds to one instance
of this class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDifferent state for Application Master, user can see this state from web UI -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected final AppSchedulingInfoprotected org.apache.hadoop.yarn.api.records.ApplicationAttemptIdprotected ResourceUsageResource usage of opportunistic containers.protected ResourceUsageprotected ResourceUsageScheduled by a remote scheduler.protected booleanprotected longprotected Map<org.apache.hadoop.yarn.api.records.ContainerId,RMContainer> protected List<RMContainer>protected Map<org.apache.hadoop.yarn.api.records.ContainerId,RMContainer> protected Map<org.apache.hadoop.yarn.api.records.ContainerId,RMContainer> protected Map<org.apache.hadoop.yarn.api.records.ContainerId,RMContainer> protected Map<org.apache.hadoop.yarn.api.records.ContainerId,RMContainer> protected Queueprotected ReentrantReadWriteLock.ReadLockprotected final Map<org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey,Map<org.apache.hadoop.yarn.api.records.NodeId, RMContainer>> protected final RMContextprotected List<RMContainer>protected List<org.apache.hadoop.yarn.api.records.UpdateContainerError>protected Set<org.apache.hadoop.yarn.api.records.NMToken>protected ReentrantReadWriteLock.WriteLock -
Constructor Summary
ConstructorsConstructorDescriptionSchedulerApplicationAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId applicationAttemptId, String user, Queue queue, AbstractUsersManager abstractUsersManager, RMContext rmContext) -
Method Summary
Modifier and TypeMethodDescriptionintaddMissedNonPartitionedRequestSchedulingOpportunity(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) protected voidaddReReservation(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) voidaddRMContainer(org.apache.hadoop.yarn.api.records.ContainerId id, RMContainer rmContainer) voidaddSchedulingOpportunity(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) voidaddToNewlyAllocatedContainers(SchedulerNode node, RMContainer rmContainer) voidaddToNewlyDecreasedContainers(org.apache.hadoop.yarn.api.records.ContainerId containerId, RMContainer rmContainer) voidaddToNewlyDemotedContainers(org.apache.hadoop.yarn.api.records.ContainerId containerId, RMContainer rmContainer) protected voidaddToUpdateContainerErrors(org.apache.hadoop.yarn.api.records.UpdateContainerError error) intCompare the passed SchedulableEntity to this one for input order.voidcontainerLaunchedOnNode(org.apache.hadoop.yarn.api.records.ContainerId containerId, org.apache.hadoop.yarn.api.records.NodeId nodeId) voiddecUnconfirmedRes(org.apache.hadoop.yarn.api.records.Resource res) booleanprotected voidgetActivedAppDiagnosticMessage(StringBuilder diagnosticMessage) org.apache.hadoop.yarn.api.records.Resourceorg.apache.hadoop.yarn.api.records.ResourcegetAMResource(String label) org.apache.hadoop.yarn.api.records.ApplicationAttemptIdGetApplicationAttemptIdof the application master.org.apache.hadoop.yarn.api.records.ApplicationId<N extends SchedulerNode>
AppPlacementAllocator<N>getAppPlacementAllocator(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerRequestKey) org.apache.hadoop.yarn.api.records.Resourceorg.apache.hadoop.yarn.api.records.ResourceGet total current reservations.org.apache.hadoop.yarn.api.records.ResourceGet available headroom in terms of resources for the application's user.getId()Id - each entity must have a unique id.Get the live containers of the application.Map<org.apache.hadoop.yarn.api.records.ContainerId,RMContainer> longintgetNumReservedContainers(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerContextintgetOutstandingAsksCount(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) intgetOutstandingAsksCount(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, String resourceName) Get partition corresponding to this entity.protected voidgetPendingAppDiagnosticMessage(StringBuilder diagnosticMessage) getPendingAsk(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, String resourceName) Set<org.apache.hadoop.yarn.api.records.ContainerId>org.apache.hadoop.yarn.api.records.PriorityGet the priority of the application.getQueue()intgetReReservations(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) Get the list of reserved containersorg.apache.hadoop.yarn.api.records.ApplicationResourceUsageReportgetRMContainer(org.apache.hadoop.yarn.api.records.ContainerId id) Collection<org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey>intgetSchedulingOpportunities(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) Return the number of times the application has been given an opportunity to schedule a task at the given priority since the last time it successfully did so.View of Resources wanted and consumed by the entity.longStart time of the job.booleangetUser()inthashCode()booleanhasPendingResourceRequest(String nodePartition, SchedulingMode schedulingMode) voidincNumAllocatedContainers(NodeType containerType, NodeType requestType) voidincUnconfirmedRes(org.apache.hadoop.yarn.api.records.Resource res) booleanbooleanIs this application pending?booleanisPlaceBlacklisted(String resourceName) booleanWhether application was running before RM restart.booleanbooleanvoidList<org.apache.hadoop.yarn.api.records.Container>List<org.apache.hadoop.yarn.api.records.Container>List<org.apache.hadoop.yarn.api.records.Container>List<org.apache.hadoop.yarn.api.records.Container>List<org.apache.hadoop.yarn.api.records.Container>List<org.apache.hadoop.yarn.api.records.Container>Called when AM heartbeats.List<org.apache.hadoop.yarn.api.records.UpdateContainerError>List<org.apache.hadoop.yarn.api.records.NMToken>voidrecordContainerAllocationTime(long value) voidrecordContainerRequestTime(long value) booleanrecoverContainer(SchedulerNode node, RMContainer rmContainer) voidrecoverResourceRequestsForContainer(ContainerRequest containerRequest) booleanremoveRMContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Removes an RM container from the map of live containers related to this application attempt.reserve(SchedulerNode node, org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, RMContainer rmContainer, org.apache.hadoop.yarn.api.records.Container container) booleanreserveIncreasedContainer(SchedulerNode node, org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, RMContainer rmContainer, org.apache.hadoop.yarn.api.records.Resource reservedResource) voidresetMissedNonPartitionedRequestSchedulingOpportunity(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) protected voidresetReReservations(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) voidresetSchedulingOpportunities(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) Should be called when an application has successfully scheduled a container, or when the scheduling locality threshold is relaxed.voidresetSchedulingOpportunities(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, long currentTimeMs) voidsetAMResource(String label, org.apache.hadoop.yarn.api.records.Resource amResource) voidsetAMResource(org.apache.hadoop.yarn.api.records.Resource amResource) voidsetAmRunning(boolean bool) voidsetAppAMNodePartitionName(String partitionName) voidsetApplicationHeadroomForMetrics(org.apache.hadoop.yarn.api.records.Resource headroom) protected voidsetAttemptRecovering(boolean isRecovering) voidsetHeadroom(org.apache.hadoop.yarn.api.records.Resource globalLimit) voidsetOpportunisticContainerContext(org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerContext oppContext) voidsetPriority(org.apache.hadoop.yarn.api.records.Priority appPriority) voidvoidstop(RMAppAttemptState rmAppAttemptFinalState) voidsubtractSchedulingOpportunity(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) voidvoidupdateAMContainerDiagnostics(SchedulerApplicationAttempt.AMState state, String diagnosticMessage) voidupdateBlacklist(List<String> blacklistAdditions, List<String> blacklistRemovals) voidupdateNMTokens(Collection<org.apache.hadoop.yarn.api.records.Container> containers) booleanupdateResourceRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> requests) booleanupdateSchedulingRequests(List<org.apache.hadoop.yarn.api.records.SchedulingRequest> requests)
-
Field Details
-
lastMemoryAggregateAllocationUpdateTime
protected long lastMemoryAggregateAllocationUpdateTime -
appSchedulingInfo
-
attemptId
protected org.apache.hadoop.yarn.api.records.ApplicationAttemptId attemptId -
liveContainers
-
reservedContainers
protected final Map<org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey,Map<org.apache.hadoop.yarn.api.records.NodeId, reservedContainersRMContainer>> -
attemptResourceUsage
-
attemptOpportunisticResourceUsage
Resource usage of opportunistic containers. -
attemptResourceUsageAllocatedRemotely
Scheduled by a remote scheduler. -
newlyAllocatedContainers
-
tempContainerToKill
-
newlyPromotedContainers
-
newlyDemotedContainers
-
newlyDecreasedContainers
-
newlyIncreasedContainers
-
updatedNMTokens
-
updateContainerErrors
-
lastScheduledContainer
-
queue
-
isStopped
protected volatile boolean isStopped -
appAMNodePartitionName
-
rmContext
-
readLock
-
writeLock
-
-
Constructor Details
-
SchedulerApplicationAttempt
public SchedulerApplicationAttempt(org.apache.hadoop.yarn.api.records.ApplicationAttemptId applicationAttemptId, String user, Queue queue, AbstractUsersManager abstractUsersManager, RMContext rmContext)
-
-
Method Details
-
setOpportunisticContainerContext
public void setOpportunisticContainerContext(org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerContext oppContext) -
getOpportunisticContainerContext
public org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerContext getOpportunisticContainerContext() -
getLiveContainers
Get the live containers of the application.- Returns:
- live containers of the application
-
getAppSchedulingInfo
-
getUpdateContext
-
isPending
public boolean isPending()Is this application pending?- Returns:
- true if it is else false.
-
getApplicationAttemptId
public org.apache.hadoop.yarn.api.records.ApplicationAttemptId getApplicationAttemptId()GetApplicationAttemptIdof the application master.- Returns:
ApplicationAttemptIdof the application master
-
getApplicationId
public org.apache.hadoop.yarn.api.records.ApplicationId getApplicationId() -
getUser
-
getPendingRelease
-
getNewContainerId
public long getNewContainerId() -
getSchedulerKeys
-
getPendingAsk
public PendingAsk getPendingAsk(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, String resourceName) -
getOutstandingAsksCount
public int getOutstandingAsksCount(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) -
getOutstandingAsksCount
public int getOutstandingAsksCount(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, String resourceName) -
getQueueName
-
getAMResource
public org.apache.hadoop.yarn.api.records.Resource getAMResource() -
getAMResource
-
setAMResource
public void setAMResource(org.apache.hadoop.yarn.api.records.Resource amResource) -
setAMResource
-
isAmRunning
public boolean isAmRunning() -
setAmRunning
public void setAmRunning(boolean bool) -
getUnmanagedAM
public boolean getUnmanagedAM() -
getRMContainer
-
addRMContainer
public void addRMContainer(org.apache.hadoop.yarn.api.records.ContainerId id, RMContainer rmContainer) -
removeRMContainer
public boolean removeRMContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Removes an RM container from the map of live containers related to this application attempt.- Parameters:
containerId- The container ID of the RMContainer to remove- Returns:
- true if the container is in the map
-
resetReReservations
protected void resetReReservations(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) -
addReReservation
protected void addReReservation(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) -
getReReservations
public int getReReservations(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) -
getCurrentReservation
@Stable @Private public org.apache.hadoop.yarn.api.records.Resource getCurrentReservation()Get total current reservations. Used only by unit tests- Returns:
- total current reservations
-
getQueue
-
updateResourceRequests
public boolean updateResourceRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> requests) -
updateSchedulingRequests
public boolean updateSchedulingRequests(List<org.apache.hadoop.yarn.api.records.SchedulingRequest> requests) -
recoverResourceRequestsForContainer
-
stop
-
isStopped
public boolean isStopped() -
getReservedContainers
Get the list of reserved containers- Returns:
- All of the reserved containers.
-
reserveIncreasedContainer
public boolean reserveIncreasedContainer(SchedulerNode node, org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, RMContainer rmContainer, org.apache.hadoop.yarn.api.records.Resource reservedResource) -
reserve
public RMContainer reserve(SchedulerNode node, org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, RMContainer rmContainer, org.apache.hadoop.yarn.api.records.Container container) -
setHeadroom
public void setHeadroom(org.apache.hadoop.yarn.api.records.Resource globalLimit) -
getHeadroom
public org.apache.hadoop.yarn.api.records.Resource getHeadroom()Get available headroom in terms of resources for the application's user.- Returns:
- available resource headroom
-
getNumReservedContainers
public int getNumReservedContainers(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) -
containerLaunchedOnNode
public void containerLaunchedOnNode(org.apache.hadoop.yarn.api.records.ContainerId containerId, org.apache.hadoop.yarn.api.records.NodeId nodeId) -
showRequests
public void showRequests() -
getCurrentConsumption
public org.apache.hadoop.yarn.api.records.Resource getCurrentConsumption() -
updateNMTokens
-
pullPreviousAttemptContainers
Called when AM heartbeats. These containers were recovered by the RM after the AM had registered. They are reported to the AM in theAllocateResponse#containersFromPreviousAttempts.- Returns:
- Container List.
-
pullNewlyAllocatedContainers
-
addToNewlyDemotedContainers
public void addToNewlyDemotedContainers(org.apache.hadoop.yarn.api.records.ContainerId containerId, RMContainer rmContainer) -
addToNewlyDecreasedContainers
public void addToNewlyDecreasedContainers(org.apache.hadoop.yarn.api.records.ContainerId containerId, RMContainer rmContainer) -
addToUpdateContainerErrors
protected void addToUpdateContainerErrors(org.apache.hadoop.yarn.api.records.UpdateContainerError error) -
addToNewlyAllocatedContainers
@VisibleForTesting public void addToNewlyAllocatedContainers(SchedulerNode node, RMContainer rmContainer) -
pullNewlyPromotedContainers
-
pullNewlyDemotedContainers
-
pullNewlyIncreasedContainers
-
pullNewlyDecreasedContainers
-
pullUpdateContainerErrors
-
pullUpdatedNMTokens
-
isWaitingForAMContainer
public boolean isWaitingForAMContainer() -
updateBlacklist
-
isPlaceBlacklisted
-
addMissedNonPartitionedRequestSchedulingOpportunity
public int addMissedNonPartitionedRequestSchedulingOpportunity(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) -
resetMissedNonPartitionedRequestSchedulingOpportunity
public void resetMissedNonPartitionedRequestSchedulingOpportunity(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) -
addSchedulingOpportunity
public void addSchedulingOpportunity(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) -
subtractSchedulingOpportunity
public void subtractSchedulingOpportunity(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) -
getSchedulingOpportunities
public int getSchedulingOpportunities(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) Return the number of times the application has been given an opportunity to schedule a task at the given priority since the last time it successfully did so.- Parameters:
schedulerKey- Scheduler Key- Returns:
- number of scheduling opportunities
-
resetSchedulingOpportunities
public void resetSchedulingOpportunities(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey) Should be called when an application has successfully scheduled a container, or when the scheduling locality threshold is relaxed. Reset various internal counters which affect delay scheduling- Parameters:
schedulerKey- The priority of the container scheduled.
-
resetSchedulingOpportunities
public void resetSchedulingOpportunities(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, long currentTimeMs) -
getResourceUsageReport
public org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport getResourceUsageReport() -
getLiveContainersMap
@VisibleForTesting public Map<org.apache.hadoop.yarn.api.records.ContainerId,RMContainer> getLiveContainersMap() -
getLastScheduledContainer
-
transferStateFromPreviousAttempt
-
move
-
recoverContainer
-
incNumAllocatedContainers
-
setApplicationHeadroomForMetrics
public void setApplicationHeadroomForMetrics(org.apache.hadoop.yarn.api.records.Resource headroom) -
recordContainerRequestTime
public void recordContainerRequestTime(long value) -
recordContainerAllocationTime
public void recordContainerAllocationTime(long value) -
getBlacklistedNodes
-
hasPendingResourceRequest
@Private public boolean hasPendingResourceRequest(String nodePartition, SchedulingMode schedulingMode) -
getAppAttemptResourceUsage
-
getPriority
public org.apache.hadoop.yarn.api.records.Priority getPriority()Description copied from interface:SchedulableEntityGet the priority of the application.- Specified by:
getPriorityin interfaceSchedulableEntity- Returns:
- priority of the application.
-
setPriority
public void setPriority(org.apache.hadoop.yarn.api.records.Priority appPriority) -
getId
Description copied from interface:SchedulableEntityId - each entity must have a unique id.- Specified by:
getIdin interfaceSchedulableEntity- Returns:
- id.
-
compareInputOrderTo
Description copied from interface:SchedulableEntityCompare the passed SchedulableEntity to this one for input order. Input order is implementation defined and should reflect the correct ordering for first-in first-out processing.- Specified by:
compareInputOrderToin interfaceSchedulableEntity- Parameters:
other- SchedulableEntity.- Returns:
- correct ordering.
-
getSchedulingResourceUsage
Description copied from interface:SchedulableEntityView of Resources wanted and consumed by the entity.- Specified by:
getSchedulingResourceUsagein interfaceSchedulableEntity- Returns:
- ResourceUsage.
-
setAppAMNodePartitionName
-
getAppAMNodePartitionName
-
updateAMContainerDiagnostics
public void updateAMContainerDiagnostics(SchedulerApplicationAttempt.AMState state, String diagnosticMessage) -
getPendingAppDiagnosticMessage
-
getActivedAppDiagnosticMessage
-
getWriteLock
-
isRecovering
public boolean isRecovering()Description copied from interface:SchedulableEntityWhether application was running before RM restart.- Specified by:
isRecoveringin interfaceSchedulableEntity- Returns:
- true, application was running before RM restart; otherwise false.
-
setAttemptRecovering
protected void setAttemptRecovering(boolean isRecovering) -
getAppPlacementAllocator
public <N extends SchedulerNode> AppPlacementAllocator<N> getAppPlacementAllocator(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerRequestKey) -
incUnconfirmedRes
public void incUnconfirmedRes(org.apache.hadoop.yarn.api.records.Resource res) -
decUnconfirmedRes
public void decUnconfirmedRes(org.apache.hadoop.yarn.api.records.Resource res) -
hashCode
public int hashCode() -
equals
-
getApplicationSchedulingEnvs
-
getPartition
Description copied from interface:SchedulableEntityGet partition corresponding to this entity.- Specified by:
getPartitionin interfaceSchedulableEntity- Returns:
- partition node label.
-
getStartTime
public long getStartTime()Description copied from interface:SchedulableEntityStart time of the job.- Specified by:
getStartTimein interfaceSchedulableEntity- Returns:
- start time
-