@Override public void cleanUpPartialOutputForTask(TaskAttemptContext context) throws IOException { // we double check this is never invoked from a non-preemptable subclass. // This should never happen, since the invoking codes is checking it too, // but it is safer to double check. Errors handling this would produce // inconsistent output. if (!this.getClass().isAnnotationPresent(Checkpointable.class)) { throw new IllegalStateException("Invoking cleanUpPartialOutputForTask() " + "from non @Preemptable class"); } FileSystem fs = fsFor(getTaskAttemptPath(context), context.getConfiguration()); LOG.info("cleanUpPartialOutputForTask: removing everything belonging to " + context.getTaskAttemptID().getTaskID() + " in: " + getCommittedTaskPath(context).getParent()); final TaskAttemptID taid = context.getTaskAttemptID(); final TaskID tid = taid.getTaskID(); Path pCommit = getCommittedTaskPath(context).getParent(); // remove any committed output for (int i = 0; i < taid.getId(); ++i) { TaskAttemptID oldId = new TaskAttemptID(tid, i); Path pTask = new Path(pCommit, oldId.toString()); if (fs.exists(pTask) && !fs.delete(pTask, true)) { throw new IOException("Failed to delete " + pTask); } } }