TaskID extends org.apache.hadoop.mapred.ID { @Override public boolean equals(Object o) { if (!super.equals(o)) return false; TaskID that = (TaskID)o; return this.type == that.type && this.jobId.equals(that.jobId); } 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 testEquals() { JobID jobId1 = new JobID("1234", 1); JobID jobId2 = new JobID("2345", 2); TaskID taskId1 = new TaskID(jobId1, TaskType.MAP, 0); TaskID taskId2 = new TaskID(jobId1, TaskType.MAP, 0); assertTrue("The equals() method reported two equal task IDs were not equal", taskId1.equals(taskId2)); taskId2 = new TaskID(jobId2, TaskType.MAP, 0); assertFalse("The equals() method reported two task IDs with different " + "job IDs were equal", taskId1.equals(taskId2)); taskId2 = new TaskID(jobId1, TaskType.MAP, 1); assertFalse("The equals() method reported two task IDs with different IDs " + "were equal", taskId1.equals(taskId2)); TaskType[] types = TaskType.values(); for (int i = 0; i < types.length; i++) { for (int j = 0; j < types.length; j++) { taskId1 = new TaskID(jobId1, types[i], 0); taskId2 = new TaskID(jobId1, types[j], 0); if (i == j) { assertTrue("The equals() method reported two equal task IDs were not " + "equal", taskId1.equals(taskId2)); } else { assertFalse("The equals() method reported two task IDs with " + "different types were equal", taskId1.equals(taskId2)); } } } assertFalse("The equals() method matched against a JobID object", taskId1.equals(jobId1)); assertFalse("The equals() method matched against a null object", taskId1.equals(null)); }