Class Container

java.lang.Object
org.apache.hadoop.yarn.api.records.Container
All Implemented Interfaces:
Comparable<Container>

@Public @Stable public abstract class Container extends Object implements 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:

  • ContainerId for the container, which is globally unique.
  • NodeId of the node on which it is allocated.
  • HTTP uri of the node.
  • Resource allocated to the container.
  • Priority at which the container was allocated.
  • Container Token of the container, used to securely verify authenticity of the allocation.
Typically, an ApplicationMaster receives the Container from the ResourceManager during resource-negotiation and then talks to the NodeManager to start/stop containers.
See Also:
  • Constructor Details

    • Container

      public Container()
  • Method Details

    • newInstance

      @Private @Unstable public static Container newInstance(ContainerId containerId, NodeId nodeId, String nodeHttpAddress, Resource resource, Priority priority, Token containerToken)
    • newInstance

      @Private @Unstable public static Container newInstance(ContainerId containerId, NodeId nodeId, String nodeHttpAddress, Resource resource, Priority priority, Token containerToken, ExecutionType executionType)
    • getId

      @Public @Stable public abstract ContainerId getId()
      Get the globally unique identifier for the container.
      Returns:
      globally unique identifier for the container
    • setId

      @Private @Unstable public abstract void setId(ContainerId id)
    • getNodeId

      @Public @Stable public abstract NodeId 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

      @Private @Unstable public abstract void setNodeId(NodeId nodeId)
    • getNodeHttpAddress

      @Public @Stable public abstract String 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

      @Private @Unstable public abstract void setNodeHttpAddress(String nodeHttpAddress)
    • getExposedPorts

      @Public @Stable public abstract Map<String,List<Map<String,String>>> 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

      @Private @Unstable public abstract void setExposedPorts(Map<String,List<Map<String,String>>> ports)
    • getResource

      @Public @Stable public abstract Resource getResource()
      Get the Resource allocated to the container.
      Returns:
      Resource allocated to the container
    • setResource

      @Private @Unstable public abstract void setResource(Resource resource)
    • getPriority

      @Public @Stable public abstract Priority getPriority()
      Get the Priority at which the Container was allocated.
      Returns:
      Priority at which the Container was allocated
    • setPriority

      @Private @Unstable public abstract void setPriority(Priority priority)
    • getContainerToken

      @Public @Stable public abstract Token getContainerToken()
      Get the ContainerToken for the container.

      ContainerToken is the security token used by the framework to verify authenticity of any Container.

      The ResourceManager, on container allocation provides a secure token which is verified by the NodeManager on container launch.

      Applications do not need to care about ContainerToken, they are transparently handled by the framework - the allocated Container includes the ContainerToken.

      Returns:
      ContainerToken for the container
      See Also:
    • setContainerToken

      @Private @Unstable public abstract void setContainerToken(Token containerToken)
    • getExecutionType

      @Private @Unstable public abstract ExecutionType getExecutionType()
      Get the ExecutionType for the container.
      Returns:
      ExecutionType for the container.
    • setExecutionType

      @Private @Unstable public abstract void setExecutionType(ExecutionType executionType)
      Set the ExecutionType for the container.
      Parameters:
      executionType - ExecutionType
    • getAllocationRequestId

      @Public @Evolving public long getAllocationRequestId()
      Get the optional ID corresponding to the original ResourceRequest{@link #getAllocationRequestId()}s which is satisfied by this allocated Container.

      The scheduler may return multiple AllocateResponses corresponding to the same ID as and when scheduler allocates Containers. 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 original ResourceRequest{@link #setAllocationRequestId(long)} etAllocationRequestId()}s which is satisfied by this allocated Container.

      The scheduler may return multiple AllocateResponses corresponding to the same ID as and when scheduler allocates Containers. 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 allocated Container(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

      @Private @Unstable public Set<String> getAllocationTags()
    • setAllocationTags

      @Private @Unstable public void setAllocationTags(Set<String> allocationTags)