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

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

# Class ContainerId

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

All Implemented Interfaces:
  `Comparable<ContainerId>`

@Public @Stable public abstract class ContainerId extends Object implements Comparable<ContainerId>

`ContainerId` represents a globally unique identifier for a `Container` in the cluster.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `CONTAINER_ID_BITMASK`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ContainerId()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract void`
  `build()`
  `int`
  `compareTo(ContainerId other)`
  `boolean`
  `equals(Object obj)`
  `static ContainerId`
  `fromString(String containerIdStr)`
  `abstract ApplicationAttemptId`
  `getApplicationAttemptId()`
  Get the `ApplicationAttemptId` of the application to which the `Container` was assigned.
  `abstract long`
  `getContainerId()`
  Get the identifier of the `ContainerId`.
  `abstract int`
  `getId()`
  Deprecated.
  `int`
  `hashCode()`
  `static ContainerId`
  `newContainerId(ApplicationAttemptId appAttemptId, long containerId)`
  `static ContainerId`
  `newInstance(ApplicationAttemptId appAttemptId, int containerId)`
  Deprecated.
  `protected abstract void`
  `setApplicationAttemptId(ApplicationAttemptId atId)`
  `protected abstract void`
  `setContainerId(long id)`
  `String`
  `toString()`

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### CONTAINER_ID_BITMASK

    public static final long CONTAINER_ID_BITMASK
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ContainerId

    public ContainerId()

- ## Method Details

  - ### newContainerId

    @Public @Unstable public static ContainerId newContainerId(ApplicationAttemptId appAttemptId, long containerId)

  - ### newInstance

    @Private @Deprecated @Unstable public static ContainerId newInstance(ApplicationAttemptId appAttemptId, int containerId)
    Deprecated.

  - ### getApplicationAttemptId

    @Public @Stable public abstract ApplicationAttemptId getApplicationAttemptId()
    Get the `ApplicationAttemptId` of the application to which the `Container` was assigned.

    Note: If containers are kept alive across application attempts via `ApplicationSubmissionContext.setKeepContainersAcrossApplicationAttempts(boolean)` the `ContainerId` does not necessarily contain the current running application attempt's `ApplicationAttemptId` This container can be allocated by previously exited application attempt and managed by the current running attempt thus have the previous application attempt's `ApplicationAttemptId`.

    Returns:
      `ApplicationAttemptId` of the application to which the `Container` was assigned

  - ### setApplicationAttemptId

    @Private @Unstable protected abstract void setApplicationAttemptId(ApplicationAttemptId atId)

  - ### getId

    @Public @Deprecated @Unstable public abstract int getId()
    Deprecated.
    Get the lower 32 bits of identifier of the `ContainerId`, which doesn't include epoch. Note that this method will be marked as deprecated, so please use `getContainerId` instead.
    Returns:
      lower 32 bits of identifier of the `ContainerId`

  - ### getContainerId

    @Public @Unstable public abstract long getContainerId()
    Get the identifier of the `ContainerId`. Upper 24 bits are reserved as epoch of cluster, and lower 40 bits are reserved as sequential number of containers.
    Returns:
      identifier of the `ContainerId`

  - ### setContainerId

    @Private @Unstable protected abstract void setContainerId(long id)

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### compareTo

    public int compareTo(ContainerId other)
    Specified by:
      `compareTo` in interface `Comparable<ContainerId>`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`
    Returns:
      A string representation of containerId. The format is container_e*epoch*_*clusterTimestamp*_*appId*_*attemptId*_*containerId* when epoch is larger than 0 (e.g. container_e17_1410901177871_0001_01_000005). *epoch* is increased when RM restarts or fails over. When epoch is 0, epoch is omitted (e.g. container_1410901177871_0001_01_000005).

  - ### fromString

    @Public @Stable public static ContainerId fromString(String containerIdStr)

  - ### build

    protected abstract void build()