/** * Test of isMap method, of class TaskID. */ @Test public void testIsMap() { JobID jobId = new JobID("1234", 0); for (TaskType type : TaskType.values()) { TaskID taskId = new TaskID(jobId, type, 0); if (type == TaskType.MAP) { assertTrue("TaskID for map task did not correctly identify itself " + "as a map task", taskId.isMap()); } else { assertFalse("TaskID for " + type + " task incorrectly identified " + "itself as a map task", taskId.isMap()); } } TaskID taskId = new TaskID(); assertFalse("TaskID of default type incorrectly identified itself as a " + "map task", taskId.isMap()); }
/**Returns whether this TaskAttemptID is a map ID */ public boolean isMap() { return taskId.isMap(); }
/**Returns whether this TaskID is a map ID */ @Deprecated public boolean isMap() { return taskId.isMap(); }
/**Returns whether this TaskID is a map ID */ @Deprecated public boolean isMap() { return taskId.isMap(); }
/**Returns whether this TaskID is a map ID */ @Deprecated public boolean isMap() { return taskId.isMap(); }
/**Returns whether this TaskID is a map ID */ @Deprecated public boolean isMap() { return taskId.isMap(); }
/** * Generate a unique filename, based on the task id, name, and extension * @param context the task that is calling this * @param name the base filename * @param extension the filename extension * @return a string like $name-[mr]-$id$extension */ public synchronized static String getUniqueFile(TaskAttemptContext context, String name, String extension) { TaskID taskId = context.getTaskAttemptID().getTaskID(); int partition = taskId.getId(); StringBuilder result = new StringBuilder(); result.append(name); result.append('-'); result.append(taskId.isMap() ? 'm' : 'r'); result.append('-'); result.append(NUMBER_FORMAT.format(partition)); result.append(extension); return result.toString(); }
/** * Downgrade a new TaskID to an old one * @param old a new or old TaskID * @return either old or a new TaskID build to match old */ public static TaskID downgrade(org.apache.hadoop.mapreduce.TaskID old) { if (old instanceof TaskID) { return (TaskID) old; } else { return new TaskID(JobID.downgrade(old.getJobID()), old.isMap(), old.getId()); } }