|
@@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
|
|
|
import org.apache.hadoop.io.Text;
|
|
|
import org.apache.hadoop.io.Writable;
|
|
|
import org.apache.hadoop.io.WritableUtils;
|
|
|
+import org.apache.hadoop.util.StringUtils;
|
|
|
/**************************************************
|
|
|
* Describes the current status of a task. This is
|
|
|
* not intended to be a comprehensive piece of data.
|
|
@@ -130,12 +131,23 @@ abstract class TaskStatus implements Writable, Cloneable {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Sets finishTime.
|
|
|
+ * Sets finishTime for the task status if and only if the
|
|
|
+ * start time is set and passed finish time is greater than
|
|
|
+ * zero.
|
|
|
+ *
|
|
|
* @param finishTime finish time of task.
|
|
|
*/
|
|
|
void setFinishTime(long finishTime) {
|
|
|
- this.finishTime = finishTime;
|
|
|
+ if(this.getStartTime() > 0 && finishTime > 0) {
|
|
|
+ this.finishTime = finishTime;
|
|
|
+ } else {
|
|
|
+ //Using String utils to get the stack trace.
|
|
|
+ LOG.error("Trying to set finish time for task " + taskid +
|
|
|
+ " when no start time is set, stackTrace is : " +
|
|
|
+ StringUtils.stringifyException(new Exception()));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Get shuffle finish time for the task. If shuffle finish time was
|
|
|
* not set due to shuffle/sort/finish phases ending within same
|
|
@@ -181,12 +193,22 @@ abstract class TaskStatus implements Writable, Cloneable {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Set startTime of the task.
|
|
|
+ * Set startTime of the task if start time is greater than zero.
|
|
|
* @param startTime start time
|
|
|
*/
|
|
|
void setStartTime(long startTime) {
|
|
|
- this.startTime = startTime;
|
|
|
+ //Making the assumption of passed startTime to be a positive
|
|
|
+ //long value explicit.
|
|
|
+ if (startTime > 0) {
|
|
|
+ this.startTime = startTime;
|
|
|
+ } else {
|
|
|
+ //Using String utils to get the stack trace.
|
|
|
+ LOG.error("Trying to set illegal startTime for task : " + taskid +
|
|
|
+ ".Stack trace is : " +
|
|
|
+ StringUtils.stringifyException(new Exception()));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Get current phase of this task. Phase.Map in case of map tasks,
|
|
|
* for reduce one of Phase.SHUFFLE, Phase.SORT or Phase.REDUCE.
|
|
@@ -301,11 +323,11 @@ abstract class TaskStatus implements Writable, Cloneable {
|
|
|
|
|
|
setDiagnosticInfo(status.getDiagnosticInfo());
|
|
|
|
|
|
- if (status.getStartTime() != 0) {
|
|
|
+ if (status.getStartTime() > 0) {
|
|
|
this.startTime = status.getStartTime();
|
|
|
}
|
|
|
- if (status.getFinishTime() != 0) {
|
|
|
- this.finishTime = status.getFinishTime();
|
|
|
+ if (status.getFinishTime() > 0) {
|
|
|
+ setFinishTime(status.getFinishTime());
|
|
|
}
|
|
|
|
|
|
this.phase = status.getPhase();
|
|
@@ -334,8 +356,8 @@ abstract class TaskStatus implements Writable, Cloneable {
|
|
|
setProgress(progress);
|
|
|
setStateString(state);
|
|
|
setPhase(phase);
|
|
|
- if (finishTime != 0) {
|
|
|
- this.finishTime = finishTime;
|
|
|
+ if (finishTime > 0) {
|
|
|
+ setFinishTime(finishTime);
|
|
|
}
|
|
|
}
|
|
|
|