org.apache.hadoop.yarn.api.records

## Class ContainerId

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

- All Implemented Interfaces:
    Comparable<ContainerId>

      @InterfaceAudience.Public
       @InterfaceStability.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 and Description
    --- | ---
    `static long` | `CONTAINER_ID_BITMASK`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ContainerId()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and 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)`
    `String` | `toString()`

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

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

- - ### Field Detail

    - #### CONTAINER_ID_BITMASK

          public static final long CONTAINER_ID_BITMASK

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ContainerId

          public ContainerId()

  - ### Method Detail

    - #### newContainerId

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

    - #### getApplicationAttemptId

          @InterfaceAudience.Public
           @InterfaceStability.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

    - #### getId

          @InterfaceAudience.Public
           @Deprecated
           @InterfaceStability.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

          @InterfaceAudience.Public
           @InterfaceStability.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`

    - #### 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

          @InterfaceAudience.Public
           @InterfaceStability.Stable
          public static ContainerId fromString(String containerIdStr)

    - #### build

          protected abstract void build()

Copyright © 2022 Apache Software Foundation. All rights reserved.