@Override public void registerLaunchedTask( org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId attemptID, WrappedJvmID jvmId) { // The AM considers the task to be launched (Has asked the NM to launch it) // The JVM will only be given a task after this registartion. launchedJVMs.add(jvmId); taskHeartbeatHandler.register(attemptID); }
@Override public void registerLaunchedTask( org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId attemptID, WrappedJvmID jvmId) { // The AM considers the task to be launched (Has asked the NM to launch it) // The JVM will only be given a task after this registartion. launchedJVMs.add(jvmId); taskHeartbeatHandler.register(attemptID); }
@Override public void registerLaunchedTask( org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId attemptID, WrappedJvmID jvmId) { // The AM considers the task to be launched (Has asked the NM to launch it) // The JVM will only be given a task after this registartion. launchedJVMs.add(jvmId); taskHeartbeatHandler.register(attemptID); attemptIdToStatus.put(attemptID, new AtomicReference<>()); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testTimeout() throws InterruptedException { EventHandler mockHandler = mock(EventHandler.class); Clock clock = SystemClock.getInstance(); TaskHeartbeatHandler hb = new TaskHeartbeatHandler(mockHandler, clock, 1); Configuration conf = new Configuration(); conf.setInt(MRJobConfig.TASK_TIMEOUT, 10); //10 ms // set TASK_PROGRESS_REPORT_INTERVAL to a value smaller than TASK_TIMEOUT // so that TASK_TIMEOUT is not overridden conf.setLong(MRJobConfig.TASK_PROGRESS_REPORT_INTERVAL, 5); conf.setInt(MRJobConfig.TASK_TIMEOUT_CHECK_INTERVAL_MS, 10); //10 ms hb.init(conf); hb.start(); try { ApplicationId appId = ApplicationId.newInstance(0l, 5); JobId jobId = MRBuilderUtils.newJobId(appId, 4); TaskId tid = MRBuilderUtils.newTaskId(jobId, 3, TaskType.MAP); TaskAttemptId taid = MRBuilderUtils.newTaskAttemptId(tid, 2); hb.register(taid); Thread.sleep(100); //Events only happen when the task is canceled verify(mockHandler, times(2)).handle(any(Event.class)); } finally { hb.stop(); } }
@Test public void testStatusUpdateProgress() throws IOException, InterruptedException { configureMocks(); startListener(true); verify(hbHandler).register(attemptId); // make sure a ping doesn't report progress AMFeedback feedback = listener.statusUpdate(attemptID, null); assertTrue(feedback.getTaskFound()); verify(hbHandler, never()).progressing(eq(attemptId)); // make sure a status update does report progress MapTaskStatus mockStatus = new MapTaskStatus(attemptID, 0.0f, 1, TaskStatus.State.RUNNING, "", "RUNNING", "", TaskStatus.Phase.MAP, new Counters()); feedback = listener.statusUpdate(attemptID, mockStatus); assertTrue(feedback.getTaskFound()); verify(hbHandler).progressing(eq(attemptId)); }
final TaskAttemptId taid = MRBuilderUtils.newTaskAttemptId(tid, 2); Assert.assertFalse(hb.hasRecentlyUnregistered(taid)); hb.register(taid); Assert.assertFalse(hb.hasRecentlyUnregistered(taid)); hb.unregister(taid);
verify(hbHandler).register(attemptId); result = listener.getTask(context); assertNotNull(result);