/** * Log the task failure * * @param taskId the task that failed * @param taskType the type of the task * @param time the time of the failure * @param error the error the task failed with * @param failedDueToAttempt The attempt that caused the failure, if any */ public void logTaskFailed( TaskID taskId, String taskType, long time, String error, TaskAttemptID failedDueToAttempt) { if (disableHistory) { return; } JobID id = taskId.getJobID(); if (!this.jobId.equals(id)) { throw new RuntimeException("JobId from task: " + id + " does not match expected: " + jobId); } if (null != writers) { String failedAttempt = failedDueToAttempt == null ? "" : failedDueToAttempt.toString(); log( writers, RecordTypes.Task, new Keys[] { Keys.TASKID, Keys.TASK_TYPE, Keys.TASK_STATUS, Keys.FINISH_TIME, Keys.ERROR, Keys.TASK_ATTEMPT_ID }, new String[] { taskId.toString(), taskType, Values.FAILED.name(), String.valueOf(time), error, failedAttempt }); } }
/** * Log finish time of task. * * @param taskId task id * @param taskType MAP or REDUCE * @param finishTime finish timeof task in ms */ public void logTaskFinished(TaskID taskId, String taskType, long finishTime, Counters counters) { if (disableHistory) { return; } JobID id = taskId.getJobID(); if (!this.jobId.equals(id)) { throw new RuntimeException("JobId from task: " + id + " does not match expected: " + jobId); } if (null != writers) { log( writers, RecordTypes.Task, new Keys[] { Keys.TASKID, Keys.TASK_TYPE, Keys.TASK_STATUS, Keys.FINISH_TIME, Keys.COUNTERS }, new String[] { taskId.toString(), taskType, Values.SUCCESS.name(), String.valueOf(finishTime), counters.makeEscapedCompactString() }); } }
/** * Downgrade a new TaskAttemptID to an old one * * @param old the new id * @return either old or a new TaskAttemptID constructed to match old */ public static TaskAttemptID downgrade(org.apache.hadoop.mapreduce.TaskAttemptID old) { if (old instanceof TaskAttemptID) { return (TaskAttemptID) old; } else { return new TaskAttemptID(TaskID.downgrade(old.getTaskID()), old.getId()); } }
/** * Update the finish time of task. * * @param taskId task id * @param finishTime finish time of task in ms */ public void logTaskUpdates(TaskID taskId, long finishTime) { if (disableHistory) { return; } JobID id = taskId.getJobID(); if (!this.jobId.equals(id)) { throw new RuntimeException("JobId from task: " + id + " does not match expected: " + jobId); } if (null != writers) { log( writers, RecordTypes.Task, new Keys[] {Keys.TASKID, Keys.FINISH_TIME}, new String[] {taskId.toString(), String.valueOf(finishTime)}); } }
@Deprecated static StringBuilder getTaskAttemptIDsPatternWOPrefix( String jtIdentifier, Integer jobId, Boolean isMap, Integer taskId, Integer attemptId) { StringBuilder builder = new StringBuilder(); builder .append(TaskID.getTaskIDsPatternWOPrefix(jtIdentifier, jobId, isMap, taskId)) .append(SEPARATOR) .append(attemptId != null ? attemptId : "[0-9]*"); return builder; }
/** * Log start time of task (TIP). * * @param taskId task id * @param taskType MAP or REDUCE * @param startTime startTime of tip. */ public void logTaskStarted( TaskID taskId, String taskType, long startTime, String splitLocations) { if (disableHistory) { return; } JobID id = taskId.getJobID(); if (!this.jobId.equals(id)) { throw new RuntimeException("JobId from task: " + id + " does not match expected: " + jobId); } if (null != writers) { log( writers, RecordTypes.Task, new Keys[] { Keys.TASKID, Keys.TASK_TYPE, Keys.START_TIME, Keys.SPLITS }, new String[] {taskId.toString(), taskType, String.valueOf(startTime), splitLocations}); } }
public boolean isDone(Operation operation) { Task task; try { task = scheduler.getTaskByName(operation.getName()); } catch (ScheduleException se) { return false; } if (task.getStatus() == TaskStatus.SUSPEND) { return false; } TaskIDCounter counter = taskIdMapper.selectByPrimaryKey(task.getTaskid()); if (counter == null || counter.getCounter() < operation.getNumber()) { return false; } InstanceID instanceID = new InstanceID( TaskID.forName(task.getTaskid()), counter.getCounter() - operation.getNumber() + 1); List<TaskAttempt> recentAttempts = getTaskAttemptByInstanceID(instanceID); if (recentAttempts == null || recentAttempts.size() == 0) { return false; } TaskAttempt history = recentAttempts.get(0); if (LOG.isDebugEnabled()) { LOG.debug("attempt : " + history.getAttemptid() + " status : " + history.getStatus()); } int status = history.getStatus(); // TODO bugs. if ((status == AttemptStatus.SUCCEEDED || status == AttemptStatus.FAILED || status == AttemptStatus.KILLED)) { if (history.getReturnvalue() != null && history.getReturnvalue() == operation.getValue()) { return true; } else { return false; } } else { return false; } }
////////////////////////////////////////////// // Writable ////////////////////////////////////////////// public void write(DataOutput out) throws IOException { taskid.write(out); out.writeFloat(progress); Text.writeString(out, state); out.writeLong(startTime); out.writeLong(finishTime); WritableUtils.writeStringArray(out, diagnostics); counters.write(out); WritableUtils.writeEnum(out, currentStatus); if (currentStatus == TIPStatus.RUNNING) { WritableUtils.writeVInt(out, runningAttempts.size()); TaskAttemptID t[] = new TaskAttemptID[0]; t = runningAttempts.toArray(t); for (int i = 0; i < t.length; i++) { t[i].write(out); } } else if (currentStatus == TIPStatus.COMPLETE) { successfulAttempt.write(out); } }
/** @deprecated use {@link #getTaskID()} instead */ @Deprecated public String getTaskId() { return taskid.toString(); }