}
}
// update job history
// get taskStatus from tip
TaskStatus taskStatus = tip.getTaskStatus(taskid);
String taskTrackerName = taskStatus.getTaskTracker();
String taskTrackerHostName = convertTrackerNameToHostName(taskTrackerName);
int taskTrackerPort = -1;
if (taskTrackerStatus != null) {
taskTrackerPort = taskTrackerStatus.getHttpPort();
}
long startTime = taskStatus.getStartTime();
long finishTime = taskStatus.getFinishTime();
List<String> taskDiagnosticInfo = tip.getDiagnosticInfo(taskid);
String diagInfo = taskDiagnosticInfo == null ? "" :
StringUtils.arrayToString(taskDiagnosticInfo.toArray(new String[0]));
String taskType = getTaskType(tip);
if (taskStatus.getIsMap()) {
jobHistory.logMapTaskStarted(taskid, startTime,
taskTrackerName, taskTrackerPort, taskType);
if (taskStatus.getRunState() == TaskStatus.State.FAILED) {
jobHistory.logMapTaskFailed(taskid, finishTime,
taskTrackerHostName, diagInfo, taskType);
} else {
jobHistory.logMapTaskKilled(taskid, finishTime,
taskTrackerHostName, diagInfo, taskType);
}
} else {
jobHistory.logReduceTaskStarted(taskid, startTime,
taskTrackerName, taskTrackerPort, taskType);
if (taskStatus.getRunState() == TaskStatus.State.FAILED) {
jobHistory.logReduceTaskFailed(taskid, finishTime,
taskTrackerHostName, diagInfo, taskType);
} else {
jobHistory.logReduceTaskKilled(taskid, finishTime,
taskTrackerHostName, diagInfo, taskType);
}
}
// After this, try to assign tasks with the one after this, so that
// the failed task goes to the end of the list.
if (!tip.isJobCleanupTask() && !tip.isJobSetupTask()) {
if (tip.isMapTask()) {
failedMapTasks++;
if (taskStatus.getRunState() != TaskStatus.State.FAILED) {
killedMapTasks++;
}
} else {
failedReduceTasks++;
if (taskStatus.getRunState() != TaskStatus.State.FAILED) {
killedReduceTasks++;
}
}
}