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

Package org.apache.hadoop.yarn.api.records

# Class PreemptionMessage

java.lang.Object
org.apache.hadoop.yarn.api.records.PreemptionMessage

@Public @Evolving public abstract class PreemptionMessage extends Object
A `PreemptionMessage` is part of the RM-AM protocol, and it is used by the RM to specify resources that the RM wants to reclaim from this `ApplicationMaster` (AM). The AM receives a `StrictPreemptionContract` message encoding which containers the platform may forcibly kill, granting it an opportunity to checkpoint state or adjust its execution plan. The message may also include a `PreemptionContract` granting the AM more latitude in selecting which resources to return to the cluster.

The AM should decode both parts of the message. The `StrictPreemptionContract` specifies particular allocations that the RM requires back. The AM can checkpoint containers' state, adjust its execution plan to move the computation, or take no action and hope that conditions that caused the RM to ask for the container will change.

In contrast, the `PreemptionContract` also includes a description of resources with a set of containers. If the AM releases containers matching that profile, then the containers enumerated in `PreemptionContract.getContainers()` may not be killed.

Each preemption message reflects the RM's current understanding of the cluster state, so a request to return N containers may not reflect containers the AM is releasing, recently exited containers the RM has yet to learn about, or new containers allocated before the message was generated. Conversely, an RM may request a different profile of containers in subsequent requests.

The policy enforced by the RM is part of the scheduler. Generally, only containers that have been requested consistently should be killed, but the details are not specified.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PreemptionMessage()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract PreemptionContract`
  `getContract()`
  `abstract StrictPreemptionContract`
  `getStrictContract()`
  `static PreemptionMessage`
  `newInstance(StrictPreemptionContract set, PreemptionContract contract)`
  `abstract void`
  `setContract(PreemptionContract contract)`
  `abstract void`
  `setStrictContract(StrictPreemptionContract set)`

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

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

- ## Constructor Details

  - ### PreemptionMessage

    public PreemptionMessage()

- ## Method Details

  - ### newInstance

    @Private @Unstable public static PreemptionMessage newInstance(StrictPreemptionContract set, PreemptionContract contract)

  - ### getStrictContract

    @Public @Evolving public abstract StrictPreemptionContract getStrictContract()
    Returns:
      Specific resources that may be killed by the `ResourceManager`

  - ### setStrictContract

    @Private @Unstable public abstract void setStrictContract(StrictPreemptionContract set)

  - ### getContract

    @Public @Evolving public abstract PreemptionContract getContract()
    Returns:
      Contract describing resources to return to the cluster.

  - ### setContract

    @Private @Unstable public abstract void setContract(PreemptionContract contract)