TaskAttemptID (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.mapreduce, class: TaskAttemptID

Package org.apache.hadoop.mapreduce

# Class TaskAttemptID

java.lang.Object
org.apache.hadoop.mapreduce.ID
org.apache.hadoop.mapred.ID
org.apache.hadoop.mapreduce.TaskAttemptID

All Implemented Interfaces:
  `Comparable<ID>`, `Writable`, `WritableComparable<ID>`

Direct Known Subclasses:
  `TaskAttemptID`

@Public @Stable public class TaskAttemptID extends ID
TaskAttemptID represents the immutable and unique identifier for a task attempt. Each task attempt is one particular instance of a Map or Reduce Task identified by its TaskID. TaskAttemptID consists of 2 parts. First part is the `TaskID`, that this TaskAttemptID belongs to. Second part is the task attempt number.
An example TaskAttemptID is : `attempt_200707121733_0003_m_000005_0` , which represents the zeroth task attempt for the fifth map task in the third job running at the jobtracker started at `200707121733`.

Applications should never construct or parse TaskAttemptID strings , but rather use appropriate constructors or `forName(String)` method.

See Also:
  - `JobID`
  - `TaskID`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final String`
  `ATTEMPT`

  ### Fields inherited from class org.apache.hadoop.mapreduce.ID

  `id, SEPARATOR`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TaskAttemptID()`
  `TaskAttemptID(String jtIdentifier, int jobId, boolean isMap, int taskId, int id)`
  Deprecated.
  `TaskAttemptID(String jtIdentifier, int jobId, TaskType type, int taskId, int id)`
  Constructs a TaskId object from given parts.
  `TaskAttemptID(TaskID taskId, int id)`
  Constructs a TaskAttemptID object from given `TaskID`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected StringBuilder`
  `appendTo(StringBuilder builder)`
  Add the unique string to the StringBuilder
  `int`
  `compareTo(ID o)`
  Compare TaskIds by first tipIds, then by task numbers.
  `boolean`
  `equals(Object o)`
  `static TaskAttemptID`
  `forName(String str)`
  Construct a TaskAttemptID object from given string
  `JobID`
  `getJobID()`
  Returns the `JobID` object that this task attempt belongs to
  `TaskID`
  `getTaskID()`
  Returns the `TaskID` object that this task attempt belongs to
  `TaskType`
  `getTaskType()`
  Returns the TaskType of the TaskAttemptID
  `int`
  `hashCode()`
  `boolean`
  `isMap()`
  Deprecated.
  `void`
  `readFields(DataInput in)`
  Deserialize the fields of this object from `in`.
  `String`
  `toString()`
  `void`
  `write(DataOutput out)`
  Serialize the fields of this object to `out`.

  ### Methods inherited from class org.apache.hadoop.mapreduce.ID

  `getId`

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

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

- ## Field Details

  - ### ATTEMPT

    protected static final String ATTEMPT
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### TaskAttemptID

    public TaskAttemptID(TaskID taskId, int id)
    Constructs a TaskAttemptID object from given `TaskID`.
    Parameters:
      `taskId` - TaskID that this task belongs to
      `id` - the task attempt number

  - ### TaskAttemptID

    public TaskAttemptID(String jtIdentifier, int jobId, TaskType type, int taskId, int id)
    Constructs a TaskId object from given parts.
    Parameters:
      `jtIdentifier` - jobTracker identifier
      `jobId` - job number
      `type` - the TaskType
      `taskId` - taskId number
      `id` - the task attempt number

  - ### TaskAttemptID

    @Deprecated public TaskAttemptID(String jtIdentifier, int jobId, boolean isMap, int taskId, int id)
    Deprecated.
    Constructs a TaskId object from given parts.
    Parameters:
      `jtIdentifier` - jobTracker identifier
      `jobId` - job number
      `isMap` - whether the tip is a map
      `taskId` - taskId number
      `id` - the task attempt number

  - ### TaskAttemptID

    public TaskAttemptID()

- ## Method Details

  - ### getJobID

    public JobID getJobID()
    Returns the `JobID` object that this task attempt belongs to

  - ### getTaskID

    public TaskID getTaskID()
    Returns the `TaskID` object that this task attempt belongs to

  - ### isMap

    @Deprecated public boolean isMap()
    Deprecated.
    Returns whether this TaskID is a map ID

  - ### getTaskType

    public TaskType getTaskType()
    Returns the TaskType of the TaskAttemptID

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `ID`

  - ### appendTo

    protected StringBuilder appendTo(StringBuilder builder)
    Add the unique string to the StringBuilder
    Parameters:
      `builder` - the builder to append ot
    Returns:
      the builder that was passed in.

  - ### readFields

    public void readFields(DataInput in) throws IOException
    Description copied from interface: `Writable`
    Deserialize the fields of this object from `in`.

    For efficiency, implementations should attempt to re-use storage in the existing object where possible.

    Specified by:
      `readFields` in interface `Writable`
    Overrides:
      `readFields` in class `ID`
    Parameters:
      `in` - `DataInput` to deseriablize this object from.
    Throws:
      `IOException` - any other problem for readFields.

  - ### write

    public void write(DataOutput out) throws IOException
    Description copied from interface: `Writable`
    Serialize the fields of this object to `out`.
    Specified by:
      `write` in interface `Writable`
    Overrides:
      `write` in class `ID`
    Parameters:
      `out` - `DataOuput` to serialize this object into.
    Throws:
      `IOException` - any other problem for write.

  - ### hashCode

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

  - ### compareTo

    public int compareTo(ID o)
    Compare TaskIds by first tipIds, then by task numbers.
    Specified by:
      `compareTo` in interface `Comparable<ID>`
    Overrides:
      `compareTo` in class `ID`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `ID`

  - ### forName

    public static TaskAttemptID forName(String str) throws IllegalArgumentException
    Construct a TaskAttemptID object from given string
    Returns:
      constructed TaskAttemptID object or null if the given String is null
    Throws:
      `IllegalArgumentException` - if the given string is malformed