2021SC@SDUSC
研究内容简略介绍
上周我们在学习了RecordReader的基础上分析了RecordWriter的源码,并对mapreduce中最关键的几个类之一Reducer进行了深入分析,了解了其函数以及工作流程,并结合之前学习的mapper分析了mapreduce的粗略过程。本次我们从org.apache.hadoop.mapreduce.TaskAttemptID
开始,完成最后一部分的分析。
org.apache.hadoop.mapreduce.TaskAttemptID源码分析
首先附上TaskAttemptID源码:
/**
* Constructs a TaskAttemptID object from given {@link TaskID}.
* @param taskId TaskID that this task belongs to
* @param id the task attempt number
*/
public TaskAttemptID(TaskID taskId, int id) {
super(id);
if(taskId == null) {
throw new IllegalArgumentException("taskId cannot be null");
}
this.taskId = taskId;
}
/**
* Constructs a TaskId object from given parts.
* @param jtIdentifier jobTracker identifier
* @param jobId job number
* @param type the TaskType
* @param taskId taskId number
* @param id the task attempt number
*/
public TaskAttemptID(String jtIdentifier, int jobId, TaskType type,
int taskId, int id) {
this(new TaskID(jtIdentifier, jobId, type, taskId), id);
}
/**
* Constructs a TaskId object from given parts.
* @param jtIdentifier jobTracker identifier
* @param jobId job number
* @param isMap whether the tip is a map
* @param taskId taskId number
* @param id the task attempt number
*/
@Deprecated
public TaskAttemptID(String jtIdentifier, int jobId, boolean isMap,
int taskId, int id) {
this(new TaskID(jtIdentifier, jobId, isMap, taskId), id);
}
public TaskAttemptID() {
taskId = new TaskID();
}
/** Returns the {@link JobID} object that this task attempt belongs to */
public JobID getJobID() {
return taskId.getJobID();
}
/** Returns the {@link TaskID} object that this task attempt belongs to */
public TaskID getTaskID() {
return taskId;
}
/**Returns whether this TaskID is a map ID */
@Deprecated
public boolean isMap() {
return taskId.isMap();
}
/**Returns the TaskType of the TaskAttemptID */
public TaskType getTaskType() {
return taskId.getTaskType();
}
@Override
public boolean equals(Object o) {
if (!super.equals(o))
return false;
TaskAttemptID that = (TaskAttemptID)o;
return this.taskId.equals(that.taskId);
}
/**
* Add the unique string to the StringBuilder
* @param builder the builder to append ot
* @return the builder that was passed in.
*/
protected StringBuilder appendTo(StringBuilder builder) {
return taskId.appendTo(builder).append(SEPARATOR).append(id);
}
@Override
public void readFields(DataInput in) throws IOException {
super.readFields(in);
taskId.readFields(in);
}
@Override
public void write(