Class SchedulerNode
java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode
- Direct Known Subclasses:
FiCaSchedulerNode,FSSchedulerNode
Represents a YARN Cluster Node from the viewpoint of the scheduler.
-
Constructor Summary
ConstructorsConstructorDescriptionSchedulerNode(RMNode node, boolean usePortForNodeName) SchedulerNode(RMNode node, boolean usePortForNodeName, Set<String> labels) -
Method Summary
Modifier and TypeMethodDescriptionvoidallocateContainer(RMContainer rmContainer) The Scheduler has allocated containers on this node to the given application.protected voidallocateContainer(RMContainer rmContainer, boolean launchedOnNode) The Scheduler has allocated containers on this node to the given application.voidcontainerStarted(org.apache.hadoop.yarn.api.records.ContainerId containerId) Inform the node that a container has launched.voiddeductUnallocatedResource(org.apache.hadoop.yarn.api.records.Resource resource) Deduct unallocated resources from the node.booleanorg.apache.hadoop.yarn.api.records.ResourceUtilizationGet the resource utilization of the containers in the node.org.apache.hadoop.yarn.api.records.ResourceGet allocated resources on the node.protected RMContainergetContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Get the container for the specified container ID.Get the containers running on the node ordered by which to kill first.Get the containers running on the node.Get HTTP address for the node.Get the labels for the node.longprotected List<RMContainer>Get the launched containers in the node.Set<org.apache.hadoop.yarn.api.records.NodeAttribute>org.apache.hadoop.yarn.api.records.NodeIdGet the ID of the node which contains both its hostname and port.Get the name of the node for scheduling matching decisions.org.apache.hadoop.yarn.api.records.ResourceUtilizationGet the resource utilization of the node.intGet number of active containers on the node.Get partition of which the node belongs to, if node-labels of this node is empty or null, it belongs to NO_LABEL partition.Get rackname.Get the reserved container in the node.Get the containers running on the node with AM containers at the end.org.apache.hadoop.yarn.api.records.ResourceGet total resources on the node.org.apache.hadoop.yarn.api.records.ResourceGet unallocated resources on the node.inthashCode()booleanCheck if the time out has passed.booleanCheck if the node has a time out for overcommit resources.booleanisValidContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Check if a container is launched by this node.voidThis will be called for each node heartbeat.voidrecoverContainer(RMContainer rmContainer) Recover a container.voidreleaseContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId, boolean releasedByNode) Release an allocated container on this node.abstract voidreserveResource(SchedulerApplicationAttempt attempt, org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, RMContainer container) Reserve container for the attempt on this node.voidsetAggregatedContainersUtilization(org.apache.hadoop.yarn.api.records.ResourceUtilization containersUtilization) Set the resource utilization of the containers in the node.voidsetNodeUtilization(org.apache.hadoop.yarn.api.records.ResourceUtilization nodeUtilization) Set the resource utilization of the node.voidsetOvercommitTimeOut(long timeOut) Set the timeout for the node to stop overcommitting the resources.voidsetReservedContainer(RMContainer reservedContainer) Set the reserved container in the node.toString()abstract voidUnreserve resources on this node.voidupdateLabels(Set<String> labels) Update the labels for the node.voidupdateNodeAttributes(Set<org.apache.hadoop.yarn.api.records.NodeAttribute> attributes) protected voidupdateResourceForReleasedContainer(org.apache.hadoop.yarn.api.records.Container container) Update the resources of the node when releasing a container.voidupdateTotalResource(org.apache.hadoop.yarn.api.records.Resource resource) Set total resources on the node.
-
Constructor Details
-
SchedulerNode
-
SchedulerNode
-
-
Method Details
-
getRMNode
-
updateTotalResource
public void updateTotalResource(org.apache.hadoop.yarn.api.records.Resource resource) Set total resources on the node.- Parameters:
resource- Total resources on the node.
-
setOvercommitTimeOut
public void setOvercommitTimeOut(long timeOut) Set the timeout for the node to stop overcommitting the resources. After this time the scheduler will start killing containers until the resources are not overcommitted anymore. This may reset a previous timeout.- Parameters:
timeOut- Time out in milliseconds.
-
isOvercommitTimedOut
public boolean isOvercommitTimedOut()Check if the time out has passed.- Returns:
- If the node is overcommitted.
-
isOvercommitTimeOutSet
public boolean isOvercommitTimeOutSet()Check if the node has a time out for overcommit resources.- Returns:
- If the node has a time out for overcommit resources.
-
getNodeID
public org.apache.hadoop.yarn.api.records.NodeId getNodeID()Get the ID of the node which contains both its hostname and port.- Returns:
- The ID of the node.
-
getHttpAddress
Get HTTP address for the node.- Returns:
- HTTP address for the node.
-
getNodeName
Get the name of the node for scheduling matching decisions.Typically this is the 'hostname' reported by the node, but it could be configured to be 'hostname:port' reported by the node via the
YarnConfiguration.RM_SCHEDULER_INCLUDE_PORT_IN_NODE_NAMEconstant. The main usecase of this is YARN minicluster to be able to differentiate node manager instances by their port number.- Returns:
- Name of the node for scheduling matching decisions.
-
getRackName
Get rackname.- Returns:
- rackname
-
allocateContainer
The Scheduler has allocated containers on this node to the given application.- Parameters:
rmContainer- Allocated container
-
allocateContainer
The Scheduler has allocated containers on this node to the given application.- Parameters:
rmContainer- Allocated containerlaunchedOnNode- True if the container has been launched
-
getUnallocatedResource
public org.apache.hadoop.yarn.api.records.Resource getUnallocatedResource()Get unallocated resources on the node.- Returns:
- Unallocated resources on the node
-
getAllocatedResource
public org.apache.hadoop.yarn.api.records.Resource getAllocatedResource()Get allocated resources on the node.- Returns:
- Allocated resources on the node
-
getTotalResource
public org.apache.hadoop.yarn.api.records.Resource getTotalResource()Get total resources on the node.- Returns:
- Total resources on the node.
-
isValidContainer
public boolean isValidContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Check if a container is launched by this node.- Parameters:
containerId- containerId.- Returns:
- If the container is launched by the node.
-
updateResourceForReleasedContainer
protected void updateResourceForReleasedContainer(org.apache.hadoop.yarn.api.records.Container container) Update the resources of the node when releasing a container.- Parameters:
container- Container to release.
-
releaseContainer
public void releaseContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId, boolean releasedByNode) Release an allocated container on this node.- Parameters:
containerId- ID of container to be released.releasedByNode- whether the release originates from a node update.
-
containerStarted
public void containerStarted(org.apache.hadoop.yarn.api.records.ContainerId containerId) Inform the node that a container has launched.- Parameters:
containerId- ID of the launched container
-
deductUnallocatedResource
@VisibleForTesting public void deductUnallocatedResource(org.apache.hadoop.yarn.api.records.Resource resource) Deduct unallocated resources from the node. This is used when allocating a container.- Parameters:
resource- Resources to deduct.
-
reserveResource
public abstract void reserveResource(SchedulerApplicationAttempt attempt, org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey schedulerKey, RMContainer container) Reserve container for the attempt on this node.- Parameters:
attempt- Application attempt asking for the reservation.schedulerKey- Priority of the reservation.container- Container reserving resources for.
-
unreserveResource
Unreserve resources on this node.- Parameters:
attempt- Application attempt that had done the reservation.
-
toString
-
getNumContainers
public int getNumContainers()Get number of active containers on the node.- Returns:
- Number of active containers on the node.
-
getCopiedListOfRunningContainers
Get the containers running on the node.- Returns:
- A copy of containers running on the node.
-
getRunningContainersWithAMsAtTheEnd
Get the containers running on the node with AM containers at the end.- Returns:
- A copy of running containers with AM containers at the end.
-
getContainersToKill
Get the containers running on the node ordered by which to kill first. It tries to kill AMs last, then GUARANTEED containers, and it kills OPPORTUNISTIC first. If the same time, it uses the creation time.- Returns:
- A copy of the running containers ordered by which to kill first.
-
getLaunchedContainers
Get the launched containers in the node.- Returns:
- List of launched containers.
-
getContainer
Get the container for the specified container ID.- Parameters:
containerId- The container ID- Returns:
- The container for the specified container ID
-
getReservedContainer
Get the reserved container in the node.- Returns:
- Reserved container in the node.
-
setReservedContainer
Set the reserved container in the node.- Parameters:
reservedContainer- Reserved container in the node.
-
recoverContainer
Recover a container.- Parameters:
rmContainer- Container to recover.
-
getLabels
Get the labels for the node.- Returns:
- Set of labels for the node.
-
updateLabels
Update the labels for the node.- Parameters:
labels- Set of labels for the node.
-
getPartition
Get partition of which the node belongs to, if node-labels of this node is empty or null, it belongs to NO_LABEL partition. And since we only support one partition for each node (YARN-2694), first label will be its partition.- Returns:
- Partition for the node.
-
setAggregatedContainersUtilization
public void setAggregatedContainersUtilization(org.apache.hadoop.yarn.api.records.ResourceUtilization containersUtilization) Set the resource utilization of the containers in the node.- Parameters:
containersUtilization- Resource utilization of the containers.
-
getAggregatedContainersUtilization
public org.apache.hadoop.yarn.api.records.ResourceUtilization getAggregatedContainersUtilization()Get the resource utilization of the containers in the node.- Returns:
- Resource utilization of the containers.
-
setNodeUtilization
public void setNodeUtilization(org.apache.hadoop.yarn.api.records.ResourceUtilization nodeUtilization) Set the resource utilization of the node. This includes the containers.- Parameters:
nodeUtilization- Resource utilization of the node.
-
getNodeUtilization
public org.apache.hadoop.yarn.api.records.ResourceUtilization getNodeUtilization()Get the resource utilization of the node.- Returns:
- Resource utilization of the node.
-
getLastHeartbeatMonotonicTime
public long getLastHeartbeatMonotonicTime() -
notifyNodeUpdate
public void notifyNodeUpdate()This will be called for each node heartbeat. -
equals
-
hashCode
public int hashCode() -
getNodeAttributes
-
updateNodeAttributes
-