Class Container
- All Implemented Interfaces:
Comparable<Container>
Container represents an allocated resource in the cluster.
The ResourceManager is the sole authority to allocate any
Container to applications. The allocated Container
is always on a single node and has a unique ContainerId. It has
a specific amount of Resource allocated.
It includes details such as:
ContainerIdfor the container, which is globally unique.-
NodeIdof the node on which it is allocated. - HTTP uri of the node.
Resourceallocated to the container.Priorityat which the container was allocated.-
Container
Tokenof the container, used to securely verify authenticity of the allocation.
ApplicationMaster receives the Container
from the ResourceManager during resource-negotiation and then
talks to the NodeManager to start/stop containers.- See Also:
-
ApplicationMasterProtocol.allocate(org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest)ContainerManagementProtocol.startContainers(org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest)ContainerManagementProtocol.stopContainers(org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongGet the optional ID corresponding to the originalResourceRequest{@link #getAllocationRequestId()}s which is satisfied by this allocatedContainer.getAllocationTags()abstract TokenGet theContainerTokenfor the container.abstract ExecutionTypegetExecutionType()Get theExecutionTypefor the container.Get the exposed ports of the node on which the container is allocated.abstract ContainerIdgetId()Get the globally unique identifier for the container.abstract StringGet the http uri of the node on which the container is allocated.abstract NodeIdGet the identifier of the node on which the container is allocated.abstract PriorityGet thePriorityat which theContainerwas allocated.abstract ResourceGet theResourceallocated to the container.intgetVersion()Get the version of this container.static ContainernewInstance(ContainerId containerId, NodeId nodeId, String nodeHttpAddress, Resource resource, Priority priority, Token containerToken) static ContainernewInstance(ContainerId containerId, NodeId nodeId, String nodeHttpAddress, Resource resource, Priority priority, Token containerToken, ExecutionType executionType) voidsetAllocationRequestId(long allocationRequestID) Set the optional ID corresponding to the originalResourceRequest{@link #setAllocationRequestId(long)} etAllocationRequestId()}s which is satisfied by this allocatedContainer.voidabstract voidsetContainerToken(Token containerToken) abstract voidsetExecutionType(ExecutionType executionType) Set theExecutionTypefor the container.abstract voidabstract voidsetId(ContainerId id) abstract voidsetNodeHttpAddress(String nodeHttpAddress) abstract voidsetNodeId(NodeId nodeId) abstract voidsetPriority(Priority priority) abstract voidsetResource(Resource resource) voidsetVersion(int version) Set the version of this container.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareTo
-
Constructor Details
-
Container
public Container()
-
-
Method Details
-
newInstance
-
newInstance
@Private @Unstable public static Container newInstance(ContainerId containerId, NodeId nodeId, String nodeHttpAddress, Resource resource, Priority priority, Token containerToken, ExecutionType executionType) -
getId
Get the globally unique identifier for the container.- Returns:
- globally unique identifier for the container
-
setId
-
getNodeId
Get the identifier of the node on which the container is allocated.- Returns:
- identifier of the node on which the container is allocated
-
setNodeId
-
getNodeHttpAddress
Get the http uri of the node on which the container is allocated.- Returns:
- http uri of the node on which the container is allocated
-
setNodeHttpAddress
-
getExposedPorts
Get the exposed ports of the node on which the container is allocated.- Returns:
- exposed ports of the node on which the container is allocated
-
setExposedPorts
-
getResource
Get theResourceallocated to the container.- Returns:
Resourceallocated to the container
-
setResource
-
getPriority
Get thePriorityat which theContainerwas allocated.- Returns:
Priorityat which theContainerwas allocated
-
setPriority
-
getContainerToken
Get theContainerTokenfor the container.ContainerTokenis the security token used by the framework to verify authenticity of anyContainer.The
ResourceManager, on container allocation provides a secure token which is verified by theNodeManageron container launch.Applications do not need to care about
ContainerToken, they are transparently handled by the framework - the allocatedContainerincludes theContainerToken.- Returns:
ContainerTokenfor the container- See Also:
-
setContainerToken
-
getExecutionType
Get theExecutionTypefor the container.- Returns:
ExecutionTypefor the container.
-
setExecutionType
Set theExecutionTypefor the container.- Parameters:
executionType- ExecutionType
-
getAllocationRequestId
@Public @Evolving public long getAllocationRequestId()Get the optional ID corresponding to the originalResourceRequest{@link #getAllocationRequestId()}s which is satisfied by this allocatedContainer.The scheduler may return multiple
AllocateResponses corresponding to the same ID as and when scheduler allocatesContainers. Applications can continue to completely ignore the returned ID in the response and use the allocation for any of their outstanding requests.- Returns:
- the ID corresponding to the original allocation request which is satisfied by this allocation.
-
setAllocationRequestId
@Private @Unstable public void setAllocationRequestId(long allocationRequestID) Set the optional ID corresponding to the originalResourceRequest{@link #setAllocationRequestId(long)} etAllocationRequestId()}s which is satisfied by this allocatedContainer.The scheduler may return multiple
AllocateResponses corresponding to the same ID as and when scheduler allocatesContainers. Applications can continue to completely ignore the returned ID in the response and use the allocation for any of their outstanding requests. If the ID is not set, scheduler will continue to work as previously and all allocatedContainer(s) will have the default ID, -1.- Parameters:
allocationRequestID- the ID corresponding to the original allocation request which is satisfied by this allocation.
-
getVersion
@Private @Unstable public int getVersion()Get the version of this container. The version will be incremented when a container is updated.- Returns:
- version of this container.
-
setVersion
@Private @Unstable public void setVersion(int version) Set the version of this container.- Parameters:
version- of this container.
-
getAllocationTags
-
setAllocationTags
-