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 Details

  • 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()