/** * Test of getRepresentingCharacter method, of class TaskID. */ @Test public void testGetRepresentingCharacter() { assertEquals("The getRepresentingCharacter() method did not return the " + "expected character", 'm', TaskID.getRepresentingCharacter(TaskType.MAP)); assertEquals("The getRepresentingCharacter() method did not return the " + "expected character", 'r', TaskID.getRepresentingCharacter(TaskType.REDUCE)); assertEquals("The getRepresentingCharacter() method did not return the " + "expected character", 's', TaskID.getRepresentingCharacter(TaskType.JOB_SETUP)); assertEquals("The getRepresentingCharacter() method did not return the " + "expected character", 'c', TaskID.getRepresentingCharacter(TaskType.JOB_CLEANUP)); assertEquals("The getRepresentingCharacter() method did not return the " + "expected character", 't', TaskID.getRepresentingCharacter(TaskType.TASK_CLEANUP)); }
/** * Test of toString method, of class TaskID. */ @Test public void testToString() { JobID jobId = new JobID("1234", 1); for (TaskType type : TaskType.values()) { TaskID taskId = new TaskID(jobId, type, 0); String str = String.format("task_1234_0001_%c_000000", TaskID.getRepresentingCharacter(type)); assertEquals("The toString() method returned the wrong value", str, taskId.toString()); } }
/** * Test of appendTo method, of class TaskID. */ @Test public void testAppendTo() { JobID jobId = new JobID("1234", 1); StringBuilder builder = new StringBuilder(); for (TaskType type : TaskType.values()) { builder.setLength(0); TaskID taskId = new TaskID(jobId, type, 0); String str = String.format("_1234_0001_%c_000000", TaskID.getRepresentingCharacter(type)); assertEquals("The appendTo() method appended the wrong value", str, taskId.appendTo(builder).toString()); } try { new TaskID().appendTo(null); fail("The appendTo() method allowed a null builder"); } catch (NullPointerException ex) { // Expected } }
@Deprecated static StringBuilder getTaskIDsPatternWOPrefix(String jtIdentifier , Integer jobId, TaskType type, Integer taskId) { StringBuilder builder = new StringBuilder(); builder.append(JobID.getJobIDsPatternWOPrefix(jtIdentifier, jobId)) .append(SEPARATOR) .append(type != null ? (org.apache.hadoop.mapreduce.TaskID.getRepresentingCharacter(type)) : org.apache.hadoop.mapreduce.TaskID.getAllTaskTypes()). append(SEPARATOR) .append(taskId != null ? idFormat.format(taskId) : "[0-9]*"); return builder; }
@Deprecated static StringBuilder getTaskIDsPatternWOPrefix(String jtIdentifier , Integer jobId, TaskType type, Integer taskId) { StringBuilder builder = new StringBuilder(); builder.append(JobID.getJobIDsPatternWOPrefix(jtIdentifier, jobId)) .append(SEPARATOR) .append(type != null ? (org.apache.hadoop.mapreduce.TaskID.getRepresentingCharacter(type)) : org.apache.hadoop.mapreduce.TaskID.getAllTaskTypes()). append(SEPARATOR) .append(taskId != null ? idFormat.format(taskId) : "[0-9]*"); return builder; }
@Deprecated static StringBuilder getTaskIDsPatternWOPrefix(String jtIdentifier , Integer jobId, TaskType type, Integer taskId) { StringBuilder builder = new StringBuilder(); builder.append(JobID.getJobIDsPatternWOPrefix(jtIdentifier, jobId)) .append(SEPARATOR) .append(type != null ? (org.apache.hadoop.mapreduce.TaskID.getRepresentingCharacter(type)) : org.apache.hadoop.mapreduce.TaskID.getAllTaskTypes()). append(SEPARATOR) .append(taskId != null ? idFormat.format(taskId) : "[0-9]*"); return builder; }
@Deprecated static StringBuilder getTaskIDsPatternWOPrefix(String jtIdentifier , Integer jobId, TaskType type, Integer taskId) { StringBuilder builder = new StringBuilder(); builder.append(JobID.getJobIDsPatternWOPrefix(jtIdentifier, jobId)) .append(SEPARATOR) .append(type != null ? (org.apache.hadoop.mapreduce.TaskID.getRepresentingCharacter(type)) : org.apache.hadoop.mapreduce.TaskID.getAllTaskTypes()). append(SEPARATOR) .append(taskId != null ? idFormat.format(taskId) : "[0-9]*"); return builder; }
@Deprecated static StringBuilder getTaskIDsPatternWOPrefix(String jtIdentifier , Integer jobId, TaskType type, Integer taskId) { StringBuilder builder = new StringBuilder(); builder.append(JobID.getJobIDsPatternWOPrefix(jtIdentifier, jobId)) .append(SEPARATOR) .append(type != null ? (org.apache.hadoop.mapreduce.TaskID.getRepresentingCharacter(type)) : org.apache.hadoop.mapreduce.TaskID.getAllTaskTypes()). append(SEPARATOR) .append(taskId != null ? idFormat.format(taskId) : "[0-9]*"); return builder; }
/** * 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-[mrsct]-$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.getRepresentingCharacter(taskId.getTaskType())); result.append('-'); result.append(NUMBER_FORMAT.format(partition)); result.append(extension); return result.toString(); }
/** * 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-[mrsct]-$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.getRepresentingCharacter(taskId.getTaskType())); result.append('-'); result.append(NUMBER_FORMAT.format(partition)); result.append(extension); return result.toString(); }
/** * 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-[mrsct]-$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.getRepresentingCharacter(taskId.getTaskType())); result.append('-'); result.append(NUMBER_FORMAT.format(partition)); result.append(extension); return result.toString(); }
/** * 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-[mrsct]-$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.getRepresentingCharacter(taskId.getTaskType())); result.append('-'); result.append(NUMBER_FORMAT.format(partition)); result.append(extension); return result.toString(); }
/** * 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-[mrsct]-$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.getRepresentingCharacter(taskId.getTaskType())); result.append('-'); result.append(NUMBER_FORMAT.format(partition)); result.append(extension); return result.toString(); }