AllocateResponse (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.yarn.api.protocolrecords, class: AllocateResponse

Package org.apache.hadoop.yarn.api.protocolrecords

# Class AllocateResponse

java.lang.Object
org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse

@Public @Stable public abstract class AllocateResponse extends Object
The response sent by the `ResourceManager` the `ApplicationMaster` during resource negotiation.

The response, includes:

- Response ID to track duplicate responses.
- An AMCommand sent by ResourceManager to let the `ApplicationMaster` take some actions (resync, shutdown etc.).
- A list of newly allocated `Container`.
- A list of completed `Container`s' statuses.
- The available headroom for resources in the cluster for the application.
- A list of nodes whose status has been updated.
- The number of available nodes in a cluster.
- A description of resources requested back by the cluster
- AMRMToken, if AMRMToken has been rolled over
- A list of `Container` representing the containers whose resource has been increased.
- A list of `Container` representing the containers whose resource has been decreased.

See Also:
  - `ApplicationMasterProtocol.allocate(AllocateRequest)`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse.AllocateResponseBuilder`
  Class to construct instances of `AllocateResponse` with specific options.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AllocateResponse()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract List<Container>`
  `getAllocatedContainers()`
  Get the list of newly allocated `Container` by the `ResourceManager`.
  `abstract AMCommand`
  `getAMCommand()`
  If the `ResourceManager` needs the `ApplicationMaster` to take some action then it will send an AMCommand to the `ApplicationMaster`.
  `abstract Token`
  `getAMRMToken()`
  The AMRMToken that belong to this attempt
  `abstract Priority`
  `getApplicationPriority()`
  Priority of the application
  `abstract Resource`
  `getAvailableResources()`
  Get the available headroom for resources in the cluster for the application.
  `abstract CollectorInfo`
  `getCollectorInfo()`
  The data associated with the collector that belongs to this app.
  `abstract List<ContainerStatus>`
  `getCompletedContainersStatuses()`
  Get the list of completed containers' statuses.
  `abstract List<Container>`
  `getContainersFromPreviousAttempts()`
  Get the list of running containers as viewed by `ResourceManager` from previous application attempts which have not been reported to the Application Master yet.
  `abstract org.apache.hadoop.yarn.api.records.EnhancedHeadroom`
  `getEnhancedHeadroom()`
  `abstract List<NMToken>`
  `getNMTokens()`
  Get the list of NMTokens required for communicating with NM.
  `abstract int`
  `getNumClusterNodes()`
  Get the number of hosts available on the cluster.
  `abstract PreemptionMessage`
  `getPreemptionMessage()`
  Get the description of containers owned by the AM, but requested back by the cluster.
  `List<RejectedSchedulingRequest>`
  `getRejectedSchedulingRequests()`
  Get a list of all SchedulingRequests that the RM has rejected between this allocate call and the previous one.
  `abstract int`
  `getResponseId()`
  Get the last response id.
  `abstract List<UpdatedContainer>`
  `getUpdatedContainers()`
  Get the list of newly updated containers by `ResourceManager`.
  `abstract List<NodeReport>`
  `getUpdatedNodes()`
  Get the list of updated `NodeReport`s.
  `List<UpdateContainerError>`
  `getUpdateErrors()`
  Get the list of container update errors to inform the Application Master about the container updates that could not be satisfied due to error.
  `static org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse.AllocateResponseBuilder`
  `newBuilder()`
  `static AllocateResponse`
  `newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens)`
  `static AllocateResponse`
  `newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, CollectorInfo collectorInfo)`
  `static AllocateResponse`
  `newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, Token amRMToken, List<UpdatedContainer> updatedContainers)`
  `static AllocateResponse`
  `newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, Token amRMToken, List<UpdatedContainer> updatedContainers, CollectorInfo collectorInfo)`
  `static AllocateResponse`
  `newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, Token amRMToken, List<UpdatedContainer> updatedContainers, CollectorInfo collectorInfo, org.apache.hadoop.yarn.api.records.EnhancedHeadroom enhancedHeadroom)`
  `abstract void`
  `setAllocatedContainers(List<Container> containers)`
  Set the list of newly allocated `Container` by the `ResourceManager`.
  `abstract void`
  `setAMCommand(AMCommand command)`
  `abstract void`
  `setAMRMToken(Token amRMToken)`
  `abstract void`
  `setApplicationPriority(Priority priority)`
  `abstract void`
  `setAvailableResources(Resource limit)`
  `abstract void`
  `setCollectorInfo(CollectorInfo info)`
  `abstract void`
  `setCompletedContainersStatuses(List<ContainerStatus> containers)`
  `abstract void`
  `setContainersFromPreviousAttempts(List<Container> containersFromPreviousAttempt)`
  Set the list of running containers as viewed by `ResourceManager` from previous application attempts which have not been reported to the Application Master yet.
  `abstract void`
  `setEnhancedHeadroom(org.apache.hadoop.yarn.api.records.EnhancedHeadroom enhancedHeadroom)`
  `abstract void`
  `setNMTokens(List<NMToken> nmTokens)`
  `abstract void`
  `setNumClusterNodes(int numNodes)`
  `abstract void`
  `setPreemptionMessage(PreemptionMessage request)`
  `void`
  `setRejectedSchedulingRequests(List<RejectedSchedulingRequest> rejectedRequests)`
  Add a list of rejected SchedulingRequests to the AllocateResponse.
  `abstract void`
  `setResponseId(int responseId)`
  `abstract void`
  `setUpdatedContainers(List<UpdatedContainer> updatedContainers)`
  Set the list of newly updated containers by `ResourceManager`.
  `abstract void`
  `setUpdatedNodes(List<NodeReport> updatedNodes)`
  `void`
  `setUpdateErrors(List<UpdateContainerError> updateErrors)`
  Set the list of container update errors to inform the Application Master about the container updates that could not be satisfied due to error.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AllocateResponse

    public AllocateResponse()

- ## Method Details

  - ### newInstance

    @Public @Stable public static AllocateResponse newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens)

  - ### newInstance

    @Private @Unstable public static AllocateResponse newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, CollectorInfo collectorInfo)

  - ### newInstance

    @Private @Unstable public static AllocateResponse newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, Token amRMToken, List<UpdatedContainer> updatedContainers)

  - ### newInstance

    @Public @Unstable public static AllocateResponse newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, Token amRMToken, List<UpdatedContainer> updatedContainers, CollectorInfo collectorInfo)

  - ### newInstance

    @Private @Unstable public static AllocateResponse newInstance(int responseId, List<ContainerStatus> completedContainers, List<Container> allocatedContainers, List<NodeReport> updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List<NMToken> nmTokens, Token amRMToken, List<UpdatedContainer> updatedContainers, CollectorInfo collectorInfo, org.apache.hadoop.yarn.api.records.EnhancedHeadroom enhancedHeadroom)

  - ### getAMCommand

    @Public @Stable public abstract AMCommand getAMCommand()
    If the `ResourceManager` needs the `ApplicationMaster` to take some action then it will send an AMCommand to the `ApplicationMaster`. See `AMCommand` for details on commands and actions for them.
    Returns:
      `AMCommand` if the `ApplicationMaster` should take action, `null` otherwise
    See Also:
      - `AMCommand`

  - ### setAMCommand

    @Private @Unstable public abstract void setAMCommand(AMCommand command)

  - ### getResponseId

    @Public @Stable public abstract int getResponseId()
    Get the last response id.
    Returns:
      last response id

  - ### setResponseId

    @Private @Unstable public abstract void setResponseId(int responseId)

  - ### getAllocatedContainers

    @Public @Stable public abstract List<Container> getAllocatedContainers()
    Get the list of newly allocated `Container` by the `ResourceManager`.
    Returns:
      list of newly allocated `Container`

  - ### setAllocatedContainers

    @Private @Unstable public abstract void setAllocatedContainers(List<Container> containers)
    Set the list of newly allocated `Container` by the `ResourceManager`.
    Parameters:
      `containers` - list of newly allocated `Container`

  - ### getAvailableResources

    @Public @Stable public abstract Resource getAvailableResources()
    Get the available headroom for resources in the cluster for the application.
    Returns:
      limit of available headroom for resources in the cluster for the application

  - ### setAvailableResources

    @Private @Unstable public abstract void setAvailableResources(Resource limit)

  - ### getCompletedContainersStatuses

    @Public @Stable public abstract List<ContainerStatus> getCompletedContainersStatuses()
    Get the list of completed containers' statuses.
    Returns:
      the list of completed containers' statuses

  - ### setCompletedContainersStatuses

    @Private @Unstable public abstract void setCompletedContainersStatuses(List<ContainerStatus> containers)

  - ### getUpdatedNodes

    @Public @Stable public abstract List<NodeReport> getUpdatedNodes()
    Get the list of updated `NodeReport`s. Updates could be changes in health, availability etc of the nodes.
    Returns:
      The delta of updated nodes since the last response

  - ### setUpdatedNodes

    @Private @Unstable public abstract void setUpdatedNodes(List<NodeReport> updatedNodes)

  - ### getNumClusterNodes

    @Public @Stable public abstract int getNumClusterNodes()
    Get the number of hosts available on the cluster.
    Returns:
      the available host count.

  - ### setNumClusterNodes

    @Private @Unstable public abstract void setNumClusterNodes(int numNodes)

  - ### getPreemptionMessage

    @Public @Evolving public abstract PreemptionMessage getPreemptionMessage()
    Get the description of containers owned by the AM, but requested back by the cluster. Note that the RM may have an inconsistent view of the resources owned by the AM. These messages are advisory, and the AM may elect to ignore them.

    The message is a snapshot of the resources the RM wants back from the AM. While demand persists, the RM will repeat its request; applications should not interpret each message as a request for additional resources on top of previous messages. Resources requested consistently over some duration may be forcibly killed by the RM.

    Returns:
      A specification of the resources to reclaim from this AM.

  - ### setPreemptionMessage

    @Private @Unstable public abstract void setPreemptionMessage(PreemptionMessage request)

  - ### getNMTokens

    @Public @Stable public abstract List<NMToken> getNMTokens()
    Get the list of NMTokens required for communicating with NM. New NMTokens issued only if

    1) AM is receiving first container on underlying NodeManager.
    OR
    2) NMToken master key rolled over in ResourceManager and AM is getting new container on the same underlying NodeManager.

    AM will receive one NMToken per NM irrespective of the number of containers issued on same NM. AM is expected to store these tokens until issued a new token for the same NM.

    Returns:
      list of NMTokens required for communicating with NM

  - ### setNMTokens

    @Private @Unstable public abstract void setNMTokens(List<NMToken> nmTokens)

  - ### getUpdatedContainers

    @Public @Unstable public abstract List<UpdatedContainer> getUpdatedContainers()
    Get the list of newly updated containers by `ResourceManager`.
    Returns:
      list of newly increased containers

  - ### setUpdatedContainers

    @Private @Unstable public abstract void setUpdatedContainers(List<UpdatedContainer> updatedContainers)
    Set the list of newly updated containers by `ResourceManager`.
    Parameters:
      `updatedContainers` - List of Updated Containers.

  - ### getAMRMToken

    @Public @Unstable public abstract Token getAMRMToken()
    The AMRMToken that belong to this attempt
    Returns:
      The AMRMToken that belong to this attempt

  - ### setAMRMToken

    @Private @Unstable public abstract void setAMRMToken(Token amRMToken)

  - ### getApplicationPriority

    @Public @Unstable public abstract Priority getApplicationPriority()
    Priority of the application
    Returns:
      get application priority

  - ### setApplicationPriority

    @Private @Unstable public abstract void setApplicationPriority(Priority priority)

  - ### getCollectorInfo

    @Public @Unstable public abstract CollectorInfo getCollectorInfo()
    The data associated with the collector that belongs to this app. Contains address and token alongwith identification information.
    Returns:
      The data of collector that belong to this attempt

  - ### setCollectorInfo

    @Private @Unstable public abstract void setCollectorInfo(CollectorInfo info)

  - ### getUpdateErrors

    @Public @Unstable public List<UpdateContainerError> getUpdateErrors()
    Get the list of container update errors to inform the Application Master about the container updates that could not be satisfied due to error.
    Returns:
      List of Update Container Errors.

  - ### setUpdateErrors

    @Public @Unstable public void setUpdateErrors(List<UpdateContainerError> updateErrors)
    Set the list of container update errors to inform the Application Master about the container updates that could not be satisfied due to error.
    Parameters:
      `updateErrors` - list of `UpdateContainerError` for containers updates requests that were in error

  - ### getContainersFromPreviousAttempts

    @Public @Unstable public abstract List<Container> getContainersFromPreviousAttempts()
    Get the list of running containers as viewed by `ResourceManager` from previous application attempts which have not been reported to the Application Master yet.
    These containers were recovered by the RM after the application master had already registered. This may happen after RM restart when some NMs get delayed in connecting to the RM and reporting the active containers. Since they were not reported in the registration response, they are reported in the response to the AM heartbeat.
    Returns:
      the list of running containers as viewed by `ResourceManager` from previous application attempts.

  - ### setContainersFromPreviousAttempts

    @Private @Unstable public abstract void setContainersFromPreviousAttempts(List<Container> containersFromPreviousAttempt)
    Set the list of running containers as viewed by `ResourceManager` from previous application attempts which have not been reported to the Application Master yet.
    These containers were recovered by the RM after the application master had already registered. This may happen after RM restart when some NMs get delayed in connecting to the RM and reporting the active containers. Since they were not reported in the registration response, they are reported in the response to the AM heartbeat.
    Parameters:
      `containersFromPreviousAttempt` - the list of running containers as viewed by `ResourceManager` from previous application attempts.

  - ### getRejectedSchedulingRequests

    @Public @Unstable public List<RejectedSchedulingRequest> getRejectedSchedulingRequests()
    Get a list of all SchedulingRequests that the RM has rejected between this allocate call and the previous one.
    Returns:
      List of RejectedSchedulingRequests.

  - ### setRejectedSchedulingRequests

    @Private @Unstable public void setRejectedSchedulingRequests(List<RejectedSchedulingRequest> rejectedRequests)
    Add a list of rejected SchedulingRequests to the AllocateResponse.
    Parameters:
      `rejectedRequests` - List of Rejected Scheduling Requests.

  - ### newBuilder

    @Private @Unstable public static org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse.AllocateResponseBuilder newBuilder()

  - ### getEnhancedHeadroom

    @Public @Unstable public abstract org.apache.hadoop.yarn.api.records.EnhancedHeadroom getEnhancedHeadroom()

  - ### setEnhancedHeadroom

    @Private @Unstable public abstract void setEnhancedHeadroom(org.apache.hadoop.yarn.api.records.EnhancedHeadroom enhancedHeadroom)