TaskID extends org.apache.hadoop.mapred.ID { public static TaskID forName(String str) throws IllegalArgumentException { if(str == null) return null; Matcher m = taskIdPattern.matcher(str); if (m.matches()) { return new org.apache.hadoop.mapred.TaskID(m.group(1), Integer.parseInt(m.group(2)), CharTaskTypeMaps.getTaskType(m.group(3).charAt(0)), Integer.parseInt(m.group(4))); } String exceptionMsg = "TaskId string : " + str + " is not properly formed" + "\nReason: " + m.toString(); throw new IllegalArgumentException(exceptionMsg); } TaskID(JobID jobId, TaskType type, int id);  TaskID(String jtIdentifier, int jobId, TaskType type, int id); @Deprecated  TaskID(JobID jobId, boolean isMap, int id); @Deprecated  TaskID(String jtIdentifier, int jobId, boolean isMap, int id);  TaskID(); JobID getJobID(); @Deprecated boolean isMap(); TaskType getTaskType(); @Override boolean equals(Object o); @Override int compareTo(ID o); @Override String toString(); @Override int hashCode(); @Override void readFields(DataInput in); @Override void write(DataOutput out); static TaskID forName(String str); static char getRepresentingCharacter(TaskType type); static TaskType getTaskType(char c); static String getAllTaskTypes(); static final String TASK_ID_REGEX; static final Pattern taskIdPattern; }
@Test public void testForName() { assertEquals("The forName() method did not parse the task ID string " + "correctly", "task_1_0001_m_000000", TaskID.forName("task_1_0001_m_000").toString()); assertEquals("The forName() method did not parse the task ID string " + "correctly", "task_23_0002_r_000001", TaskID.forName("task_23_0002_r_0001").toString()); assertEquals("The forName() method did not parse the task ID string " + "correctly", "task_345_0003_s_000002", TaskID.forName("task_345_0003_s_00002").toString()); assertEquals("The forName() method did not parse the task ID string " + "correctly", "task_6789_0004_c_000003", TaskID.forName("task_6789_0004_c_000003").toString()); assertEquals("The forName() method did not parse the task ID string " + "correctly", "task_12345_0005_t_4000000", TaskID.forName("task_12345_0005_t_4000000").toString()); try { TaskID.forName("tisk_12345_0005_t_4000000"); fail("The forName() method parsed an invalid job ID: " + "tisk_12345_0005_t_4000000"); } catch (IllegalArgumentException ex) { } try { TaskID.forName("tisk_12345_0005_t_4000000"); fail("The forName() method parsed an invalid job ID: " + "tisk_12345_0005_t_4000000"); } catch (IllegalArgumentException ex) { } try { TaskID.forName("task_abc_0005_t_4000000"); fail("The forName() method parsed an invalid job ID: " + "task_abc_0005_t_4000000"); } catch (IllegalArgumentException ex) { } try { TaskID.forName("task_12345_xyz_t_4000000"); fail("The forName() method parsed an invalid job ID: " + "task_12345_xyz_t_4000000"); } catch (IllegalArgumentException ex) { } try { TaskID.forName("task_12345_0005_x_4000000"); fail("The forName() method parsed an invalid job ID: " + "task_12345_0005_x_4000000"); } catch (IllegalArgumentException ex) { } try { TaskID.forName("task_12345_0005_t_jkl"); fail("The forName() method parsed an invalid job ID: " + "task_12345_0005_t_jkl"); } catch (IllegalArgumentException ex) { } try { TaskID.forName("task_12345_0005_t"); fail("The forName() method parsed an invalid job ID: " + "task_12345_0005_t"); } catch (IllegalArgumentException ex) { } try { TaskID.forName("task_12345_0005_4000000"); fail("The forName() method parsed an invalid job ID: " + "task_12345_0005_4000000"); } catch (IllegalArgumentException ex) { } try { TaskID.forName("task_12345_t_4000000"); fail("The forName() method parsed an invalid job ID: " + "task_12345_t_4000000"); } catch (IllegalArgumentException ex) { } try { TaskID.forName("12345_0005_t_4000000"); fail("The forName() method parsed an invalid job ID: " + "12345_0005_t_4000000"); } catch (IllegalArgumentException ex) { } }