Package org.apache.hadoop.mapreduce
Class TaskID
java.lang.Object
org.apache.hadoop.mapreduce.ID
org.apache.hadoop.mapred.ID
org.apache.hadoop.mapreduce.TaskID
- All Implemented Interfaces:
Comparable<ID>,Writable,WritableComparable<ID>
- Direct Known Subclasses:
TaskID
TaskID represents the immutable and unique identifier for
a Map or Reduce Task. Each TaskID encompasses multiple attempts made to
execute the Map or Reduce Task, each of which are uniquely indentified by
their TaskAttemptID.
TaskID consists of 3 parts. First part is the
An example TaskID is :
JobID, that this
TaskInProgress belongs to. Second part of the TaskID is either 'm' or 'r'
representing whether the task is a map task or a reduce task.
And the third part is the task number. An example TaskID is :
task_200707121733_0003_m_000005 , which represents the
fifth map task in the third job running at the jobtracker
started at 200707121733.
Applications should never construct or parse TaskID strings
, but rather use appropriate constructors or forName(String)
method.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final NumberFormatprotected static final Stringstatic final Stringstatic final Pattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringBuilderappendTo(StringBuilder builder) Add the unique string to the given builder.intCompare TaskInProgressIds by first jobIds, then by tip numbers.booleanstatic TaskIDConstruct a TaskID object from given string.static StringReturns a string of characters describing all possibleTaskTypevaluesgetJobID()Returns theJobIDobject that this tip belongs to.static charGets the character representing theTaskType.Get the type of the task.static TaskTypegetTaskType(char c) Gets theTaskTypecorresponding to the character.inthashCode()booleanisMap()Deprecated.voidreadFields(DataInput in) Deserialize the fields of this object fromin.toString()voidwrite(DataOutput out) Serialize the fields of this object toout.
-
Field Details
-
TASK
- See Also:
-
idFormat
-
TASK_ID_REGEX
-
taskIdPattern
-
-
Constructor Details
-
TaskID
Constructs a TaskID object from givenJobID.- Parameters:
jobId- JobID that this tip belongs totype- theTaskTypeof the taskid- the tip number
-
TaskID
Constructs a TaskInProgressId object from given parts.- Parameters:
jtIdentifier- jobTracker identifierjobId- job numbertype- the TaskTypeid- the tip number
-
TaskID
Deprecated.Constructs a TaskID object from givenJobID.- Parameters:
jobId- JobID that this tip belongs toisMap- whether the tip is a mapid- the tip number
-
TaskID
Deprecated.Constructs a TaskInProgressId object from given parts.- Parameters:
jtIdentifier- jobTracker identifierjobId- job numberisMap- whether the tip is a mapid- the tip number
-
TaskID
public TaskID()Default constructor for Writable. Sets the task type toTaskType.REDUCE, the ID to 0, and the job ID to an empty job ID.
-
-
Method Details
-
getJobID
Returns theJobIDobject that this tip belongs to.- Returns:
- the JobID object
-
isMap
Deprecated.Returns whether this TaskID is a map ID.- Returns:
- whether this TaskID is a map ID
-
getTaskType
Get the type of the task.- Returns:
- the type of the task
-
equals
-
compareTo
Compare TaskInProgressIds by first jobIds, then by tip numbers. Reducers are defined as greater than mappers.- Specified by:
compareToin interfaceComparable<ID>- Overrides:
compareToin classID- Parameters:
o- the TaskID against which to compare- Returns:
- 0 if equal, positive if this TaskID is greater, and negative if this TaskID is less
-
toString
-
appendTo
Add the unique string to the given builder.- Parameters:
builder- the builder to append to- Returns:
- the builder that was passed in
-
hashCode
public int hashCode() -
readFields
Description copied from interface:WritableDeserialize the fields of this object fromin.For efficiency, implementations should attempt to re-use storage in the existing object where possible.
- Specified by:
readFieldsin interfaceWritable- Overrides:
readFieldsin classID- Parameters:
in-DataInputto deseriablize this object from.- Throws:
IOException- any other problem for readFields.
-
write
Description copied from interface:WritableSerialize the fields of this object toout.- Specified by:
writein interfaceWritable- Overrides:
writein classID- Parameters:
out-DataOuputto serialize this object into.- Throws:
IOException- any other problem for write.
-
forName
Construct a TaskID object from given string.- Parameters:
str- the target string- Returns:
- constructed TaskID object or null if the given String is null
- Throws:
IllegalArgumentException- if the given string is malformed
-
getRepresentingCharacter
Gets the character representing theTaskType.- Parameters:
type- the TaskType- Returns:
- the character
-
getTaskType
Gets theTaskTypecorresponding to the character.- Parameters:
c- the character- Returns:
- the TaskType
-
getAllTaskTypes
Returns a string of characters describing all possibleTaskTypevalues- Returns:
- a string of all task type characters
-