TaskID extends org.apache.hadoop.mapred.ID { @Override public void write(DataOutput out) throws IOException { super.write(out); jobId.write(out); WritableUtils.writeEnum(out, type); } 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 testWrite() throws Exception { JobID jobId = new JobID("1234", 1); TaskID taskId = new TaskID(jobId, TaskType.JOB_SETUP, 0); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(baos); taskId.write(out); DataInputByteBuffer in = new DataInputByteBuffer(); byte[] buffer = new byte[4]; in.reset(ByteBuffer.wrap(baos.toByteArray())); assertEquals("The write() method did not write the expected task ID", 0, in.readInt()); assertEquals("The write() method did not write the expected job ID", 1, in.readInt()); assertEquals("The write() method did not write the expected job " + "identifier length", 4, WritableUtils.readVInt(in)); in.readFully(buffer, 0, 4); assertEquals("The write() method did not write the expected job " + "identifier length", "1234", new String(buffer)); assertEquals("The write() method did not write the expected task type", TaskType.JOB_SETUP, WritableUtils.readEnum(in, TaskType.class)); }