/** * @param ctx Context for IO operations. */ public HadoopV2Context(HadoopV2TaskContext ctx) { super(ctx.jobConf(), ctx.jobContext().getJobID()); taskAttemptID = ctx.attemptId(); conf.set(MRJobConfig.ID, taskAttemptID.getJobID().toString()); conf.set(MRJobConfig.TASK_ID, taskAttemptID.getTaskID().toString()); conf.set(MRJobConfig.TASK_ATTEMPT_ID, taskAttemptID.toString()); output = ctx.output(); input = ctx.input(); this.ctx = ctx; }
/** * Test of readFields method, of class TaskID. */ @Test public void testReadFields() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(baos); out.writeInt(0); out.writeInt(1); WritableUtils.writeVInt(out, 4); out.write(new byte[] {0x31, 0x32, 0x33, 0x34}); WritableUtils.writeEnum(out, TaskType.REDUCE); DataInputByteBuffer in = new DataInputByteBuffer(); in.reset(ByteBuffer.wrap(baos.toByteArray())); TaskID instance = new TaskID(); instance.readFields(in); assertEquals("The readFields() method did not produce the expected task ID", "task_1234_0001_r_000000", instance.toString()); }
/** * 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()); } }
/** * Reassigns the chunk to a specified Map-Task, for consumption. * * @param taskId The Map-Task to which a the chunk is to be reassigned. * @throws IOException Exception on failure to reassign. */ public void assignTo(TaskID taskId) throws IOException { Path newPath = new Path(chunkRootPath, taskId.toString()); if (!fs.rename(chunkFilePath, newPath)) { LOG.warn("{} could not be assigned to {}", chunkFilePath, taskId); } }
/** * Reassigns the chunk to a specified Map-Task, for consumption. * * @param taskId The Map-Task to which a the chunk is to be reassigned. * @throws IOException Exception on failure to reassign. */ public void assignTo(TaskID taskId) throws IOException { Path newPath = new Path(chunkRootPath, taskId.toString()); if (!fs.rename(chunkFilePath, newPath)) { LOG.warn("{} could not be assigned to {}", chunkFilePath, taskId); } }
/** * Create an event to record task updates * @param id Id of the task * @param finishTime Finish time of the task */ public TaskUpdatedEvent(TaskID id, long finishTime) { datum.taskid = new Utf8(id.toString()); datum.finishTime = finishTime; }
@Override public int hashCode() { return (counters.toString() + Arrays.toString(this.diagnostics) + this.finishTime + this.progress + this.startTime + this.state + this.taskid.toString()).hashCode(); } //////////////////////////////////////////////
/** * Create an event to record task updates * @param id Id of the task * @param finishTime Finish time of the task */ public TaskUpdatedEvent(TaskID id, long finishTime) { datum.taskid = new Utf8(id.toString()); datum.finishTime = finishTime; }
/** * Create an event to record task updates * @param id Id of the task * @param finishTime Finish time of the task */ public TaskUpdatedEvent(TaskID id, long finishTime) { datum.taskid = new Utf8(id.toString()); datum.finishTime = finishTime; }
public void printAll() { System.out.println("TASK_ID:" + taskId.toString()); System.out.println("START_TIME: " + startTime); System.out.println("FINISH_TIME:" + finishTime); System.out.println("TASK_TYPE:" + taskType); if (counters != null) { System.out.println("COUNTERS:" + counters.toString()); } for (TaskAttemptInfo tinfo: attemptsMap.values()) { tinfo.printAll(); } }
public void printAll() { System.out.println("TASK_ID:" + taskId.toString()); System.out.println("START_TIME: " + startTime); System.out.println("FINISH_TIME:" + finishTime); System.out.println("TASK_TYPE:" + taskType); if (counters != null) { System.out.println("COUNTERS:" + counters.toString()); } for (TaskAttemptInfo tinfo: attemptsMap.values()) { tinfo.printAll(); } }
public void printAll() { System.out.println("TASK_ID:" + taskId.toString()); System.out.println("START_TIME: " + startTime); System.out.println("FINISH_TIME:" + finishTime); System.out.println("TASK_TYPE:" + taskType); if (counters != null) { System.out.println("COUNTERS:" + counters.toString()); } for (TaskAttemptInfo tinfo: attemptsMap.values()) { tinfo.printAll(); } }
public void printAll() { System.out.println("TASK_ID:" + taskId.toString()); System.out.println("START_TIME: " + startTime); System.out.println("FINISH_TIME:" + finishTime); System.out.println("TASK_TYPE:" + taskType); if (counters != null) { System.out.println("COUNTERS:" + counters.toString()); } for (TaskAttemptInfo tinfo: attemptsMap.values()) { tinfo.printAll(); } }
/** * Reassigns the chunk to a specified Map-Task, for consumption. * @param taskId The Map-Task to which a the chunk is to be reassigned. * @throws IOException Exception on failure to reassign. */ public void assignTo(TaskID taskId) throws IOException { Path newPath = new Path(chunkContext.getChunkRootPath(), taskId.toString()); if (!chunkContext.getFs().rename(chunkFilePath, newPath)) { LOG.warn(chunkFilePath + " could not be assigned to " + taskId); } }
/** * Reassigns the chunk to a specified Map-Task, for consumption. * @param taskId The Map-Task to which a the chunk is to be reassigned. * @throws IOException Exception on failure to reassign. */ public void assignTo(TaskID taskId) throws IOException { Path newPath = new Path(chunkContext.getChunkRootPath(), taskId.toString()); if (!chunkContext.getFs().rename(chunkFilePath, newPath)) { LOG.warn(chunkFilePath + " could not be assigned to " + taskId); } }
@Override protected void setup(Context context) throws IOException, InterruptedException { Path attemptDir = FileOutputFormat.getWorkOutputPath(context); String filename = context.getTaskAttemptID() .getTaskID().toString(); Path sideEffectFile = new Path(attemptDir, filename); sideEffectStream = FileSystem.get(context.getConfiguration()) .create(sideEffectFile); log.info("Opened file = {}", sideEffectFile); }
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());
private void processTaskUpdatedEvent(TaskUpdatedEvent event) { ParsedTask task = getTask(event.getTaskId().toString()); if (task == null) { return; } task.setFinishTime(event.getFinishTime()); }
private void processTaskStartedEvent(TaskStartedEvent event) { ParsedTask task = getOrMakeTask(event.getTaskType(), event.getTaskId().toString(), true); task.setStartTime(event.getStartTime()); task.setPreferredLocations(preferredLocationForSplits(event .getSplitLocations())); }
private void processTaskAttemptStartedEvent(TaskAttemptStartedEvent event) { ParsedTaskAttempt attempt = getOrMakeTaskAttempt(event.getTaskType(), event.getTaskId().toString(), event.getTaskAttemptId().toString()); if (attempt == null) { return; } attempt.setStartTime(event.getStartTime()); attempt.putTrackerName(event.getTrackerName()); attempt.putHttpPort(event.getHttpPort()); attempt.putShufflePort(event.getShufflePort()); }