Search in sources :

Example 11 with AMContainerMap

use of org.apache.tez.dag.app.rm.container.AMContainerMap in project tez by apache.

the class TestAMNodeTracker method testNodeCompletedAndCleanup.

@Test(timeout = 10000L)
public void testNodeCompletedAndCleanup() {
    AppContext appContext = mock(AppContext.class);
    Configuration conf = new Configuration(false);
    conf.setInt(TezConfiguration.TEZ_AM_MAX_TASK_FAILURES_PER_NODE, 2);
    TestEventHandler handler = new TestEventHandler();
    AMNodeTracker amNodeTracker = new AMNodeTracker(handler, appContext);
    doReturn(amNodeTracker).when(appContext).getNodeTracker();
    AMContainerMap amContainerMap = mock(AMContainerMap.class);
    TaskSchedulerManager taskSchedulerManager = mock(TaskSchedulerManager.class);
    dispatcher.register(AMNodeEventType.class, amNodeTracker);
    dispatcher.register(AMContainerEventType.class, amContainerMap);
    dispatcher.register(AMSchedulerEventType.class, taskSchedulerManager);
    amNodeTracker.init(conf);
    amNodeTracker.start();
    try {
        NodeId nodeId = NodeId.newInstance("fakenode", 3333);
        amNodeTracker.nodeSeen(nodeId, 0);
        AMNode amNode = amNodeTracker.get(nodeId, 0);
        ContainerId[] containerIds = new ContainerId[7];
        // Start 5 containers.
        for (int i = 0; i < 5; i++) {
            containerIds[i] = mock(ContainerId.class);
            amNodeTracker.handle(new AMNodeEventContainerAllocated(nodeId, 0, containerIds[i]));
        }
        assertEquals(5, amNode.getContainers().size());
        // Finnish 1st dag
        amNodeTracker.dagComplete(mock(DAG.class));
        assertEquals(5, amNode.getContainers().size());
        // Mark 2 as complete. Finish 2nd dag.
        for (int i = 0; i < 2; i++) {
            amNodeTracker.handle(new AMNodeEventContainerCompleted(nodeId, 0, containerIds[i]));
        }
        amNodeTracker.dagComplete(mock(DAG.class));
        assertEquals(3, amNode.getContainers().size());
        // Add 2 more containers. Mark all as complete. Finish 3rd dag.
        for (int i = 5; i < 7; i++) {
            containerIds[i] = mock(ContainerId.class);
            amNodeTracker.handle(new AMNodeEventContainerAllocated(nodeId, 0, containerIds[i]));
        }
        assertEquals(5, amNode.getContainers().size());
        amNodeTracker.dagComplete(mock(DAG.class));
        assertEquals(5, amNode.getContainers().size());
        amNodeTracker.dagComplete(mock(DAG.class));
        assertEquals(5, amNode.getContainers().size());
        for (int i = 2; i < 7; i++) {
            amNodeTracker.handle(new AMNodeEventContainerCompleted(nodeId, 0, containerIds[i]));
        }
        assertEquals(5, amNode.getContainers().size());
        amNodeTracker.dagComplete(mock(DAG.class));
        assertEquals(0, amNode.getContainers().size());
    } finally {
        amNodeTracker.stop();
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) AppContext(org.apache.tez.dag.app.AppContext) DAG(org.apache.tez.dag.app.dag.DAG) AMContainerMap(org.apache.tez.dag.app.rm.container.AMContainerMap) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) TaskSchedulerManager(org.apache.tez.dag.app.rm.TaskSchedulerManager) NodeId(org.apache.hadoop.yarn.api.records.NodeId) Test(org.junit.Test)

Example 12 with AMContainerMap

use of org.apache.tez.dag.app.rm.container.AMContainerMap in project tez by apache.

the class TestTaskCommunicatorContextImpl method testIsKnownContainer.

@Test(timeout = 5000)
public void testIsKnownContainer() {
    AppContext appContext = mock(AppContext.class);
    when(appContext.getAMConf()).thenReturn(new Configuration());
    TaskCommunicatorManager tal = mock(TaskCommunicatorManager.class);
    AMContainerMap amContainerMap = new AMContainerMap(mock(ContainerHeartbeatHandler.class), tal, mock(ContainerSignatureMatcher.class), appContext);
    doReturn(amContainerMap).when(appContext).getAllContainers();
    ContainerId containerId01 = mock(ContainerId.class);
    Container container01 = mock(Container.class);
    doReturn(containerId01).when(container01).getId();
    ContainerId containerId11 = mock(ContainerId.class);
    Container container11 = mock(Container.class);
    doReturn(containerId11).when(container11).getId();
    amContainerMap.addContainerIfNew(container01, 0, 0, 0);
    amContainerMap.addContainerIfNew(container11, 1, 1, 1);
    TaskCommunicatorContext taskCommContext0 = new TaskCommunicatorContextImpl(appContext, tal, null, 0);
    TaskCommunicatorContext taskCommContext1 = new TaskCommunicatorContextImpl(appContext, tal, null, 1);
    assertTrue(taskCommContext0.isKnownContainer(containerId01));
    assertFalse(taskCommContext0.isKnownContainer(containerId11));
    assertFalse(taskCommContext1.isKnownContainer(containerId01));
    assertTrue(taskCommContext1.isKnownContainer(containerId11));
    taskCommContext0.containerAlive(containerId01);
    verify(tal).containerAlive(containerId01);
    reset(tal);
    taskCommContext0.containerAlive(containerId11);
    verify(tal, never()).containerAlive(containerId11);
    reset(tal);
    taskCommContext1.containerAlive(containerId01);
    verify(tal, never()).containerAlive(containerId01);
    reset(tal);
    taskCommContext1.containerAlive(containerId11);
    verify(tal).containerAlive(containerId11);
    reset(tal);
    taskCommContext1.containerAlive(containerId01);
    verify(tal, never()).containerAlive(containerId01);
    reset(tal);
}
Also used : Container(org.apache.hadoop.yarn.api.records.Container) Configuration(org.apache.hadoop.conf.Configuration) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ContainerSignatureMatcher(org.apache.tez.common.ContainerSignatureMatcher) AMContainerMap(org.apache.tez.dag.app.rm.container.AMContainerMap) TaskCommunicatorContext(org.apache.tez.serviceplugins.api.TaskCommunicatorContext) Test(org.junit.Test)

Example 13 with AMContainerMap

use of org.apache.tez.dag.app.rm.container.AMContainerMap in project tez by apache.

the class TestVertexImpl method testLastTaskFinishTime.

@Test(timeout = 5000)
public void testLastTaskFinishTime() {
    NodeId nid = NodeId.newInstance("127.0.0.1", 0);
    ContainerId contId = ContainerId.newContainerId(appAttemptId, 3);
    Container container = mock(Container.class);
    when(container.getId()).thenReturn(contId);
    when(container.getNodeId()).thenReturn(nid);
    when(container.getNodeHttpAddress()).thenReturn("localhost:0");
    AMContainerMap containers = new AMContainerMap(mock(ContainerHeartbeatHandler.class), mock(TaskCommunicatorManagerInterface.class), new ContainerContextMatcher(), appContext);
    containers.addContainerIfNew(container, 0, 0, 0);
    doReturn(containers).when(appContext).getAllContainers();
    initAllVertices(VertexState.INITED);
    VertexImpl v = vertices.get("vertex2");
    startVertex(v);
    TezTaskID tid0 = TezTaskID.getInstance(v.getVertexId(), 0);
    TezTaskID tid1 = TezTaskID.getInstance(v.getVertexId(), 1);
    TaskImpl task0 = (TaskImpl) v.getTask(tid0);
    TaskImpl task1 = (TaskImpl) v.getTask(tid1);
    TezTaskAttemptID taskAttemptId0 = TezTaskAttemptID.getInstance(task0.getTaskID(), 0);
    TezTaskAttemptID taskAttemptId1 = TezTaskAttemptID.getInstance(task1.getTaskID(), 0);
    TaskAttemptImpl taskAttempt0 = (TaskAttemptImpl) task0.getAttempt(taskAttemptId0);
    TaskAttemptImpl taskAttempt1 = (TaskAttemptImpl) task1.getAttempt(taskAttemptId1);
    Assert.assertEquals(v.getLastTaskFinishTime(), -1);
    taskAttempt0.handle(new TaskAttemptEventSchedule(taskAttemptId0, 0, 0));
    taskAttempt0.handle(new TaskAttemptEventSubmitted(taskAttemptId0, contId));
    taskAttempt0.handle(new TaskAttemptEventStartedRemotely(taskAttemptId0));
    taskAttempt0.handle(new TaskAttemptEvent(taskAttemptId0, TaskAttemptEventType.TA_DONE));
    // task0.handle(new TaskEventTAUpdate(taskAttemptId0, TaskEventType.T_ATTEMPT_SUCCEEDED));
    Assert.assertEquals(v.getLastTaskFinishTime(), -1);
    taskAttempt1.handle(new TaskAttemptEventSchedule(taskAttemptId1, 0, 0));
    taskAttempt1.handle(new TaskAttemptEventSubmitted(taskAttemptId1, contId));
    taskAttempt1.handle(new TaskAttemptEventStartedRemotely(taskAttemptId1));
    taskAttempt1.handle(new TaskAttemptEvent(taskAttemptId1, TaskAttemptEventType.TA_DONE));
    // task1.handle(new TaskEventTAUpdate(taskAttemptId1, TaskEventType.T_ATTEMPT_SUCCEEDED));
    dispatcher.await();
    Assert.assertEquals(VertexState.SUCCEEDED, v.getState());
    Assert.assertTrue(v.getLastTaskFinishTime() > 0);
}
Also used : TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) AMContainerMap(org.apache.tez.dag.app.rm.container.AMContainerMap) TaskCommunicatorManagerInterface(org.apache.tez.dag.app.TaskCommunicatorManagerInterface) ContainerContextMatcher(org.apache.tez.dag.app.rm.container.ContainerContextMatcher) TaskAttemptEventSubmitted(org.apache.tez.dag.app.dag.event.TaskAttemptEventSubmitted) TezTaskID(org.apache.tez.dag.records.TezTaskID) Container(org.apache.hadoop.yarn.api.records.Container) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) NodeId(org.apache.hadoop.yarn.api.records.NodeId) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule) ContainerHeartbeatHandler(org.apache.tez.dag.app.ContainerHeartbeatHandler) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) TaskAttemptEventStartedRemotely(org.apache.tez.dag.app.dag.event.TaskAttemptEventStartedRemotely) VertexManagerPluginForTest(org.apache.tez.test.VertexManagerPluginForTest) Test(org.junit.Test) GraceShuffleVertexManagerForTest(org.apache.tez.test.GraceShuffleVertexManagerForTest) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest) EdgeManagerForTest(org.apache.tez.test.EdgeManagerForTest)

Example 14 with AMContainerMap

use of org.apache.tez.dag.app.rm.container.AMContainerMap in project tez by apache.

the class TestTaskAttempt method testFailureFatalError.

@Test(timeout = 5000)
public void testFailureFatalError() throws Exception {
    ApplicationId appId = ApplicationId.newInstance(1, 2);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 0);
    TezDAGID dagID = TezDAGID.getInstance(appId, 1);
    TezVertexID vertexID = TezVertexID.getInstance(dagID, 1);
    TezTaskID taskID = TezTaskID.getInstance(vertexID, 1);
    MockEventHandler eventHandler = spy(new MockEventHandler());
    TaskCommunicatorManagerInterface taListener = createMockTaskAttemptListener();
    Configuration taskConf = new Configuration();
    taskConf.setClass("fs.file.impl", StubbedFS.class, FileSystem.class);
    taskConf.setBoolean("fs.file.impl.disable.cache", true);
    taskConf.setBoolean(TezConfiguration.TEZ_AM_SPECULATION_ENABLED, true);
    locationHint = TaskLocationHint.createTaskLocationHint(new HashSet<String>(Arrays.asList(new String[] { "127.0.0.1" })), null);
    Resource resource = Resource.newInstance(1024, 1);
    NodeId nid = NodeId.newInstance("127.0.0.1", 0);
    @SuppressWarnings("deprecation") ContainerId contId = ContainerId.newInstance(appAttemptId, 3);
    Container container = mock(Container.class);
    when(container.getId()).thenReturn(contId);
    when(container.getNodeId()).thenReturn(nid);
    when(container.getNodeHttpAddress()).thenReturn("localhost:0");
    AMContainerMap containers = new AMContainerMap(mock(ContainerHeartbeatHandler.class), mock(TaskCommunicatorManagerInterface.class), new ContainerContextMatcher(), appCtx);
    containers.addContainerIfNew(container, 0, 0, 0);
    doReturn(new ClusterInfo()).when(appCtx).getClusterInfo();
    doReturn(containers).when(appCtx).getAllContainers();
    TaskHeartbeatHandler mockHeartbeatHandler = mock(TaskHeartbeatHandler.class);
    TaskAttemptImpl taImpl = new MockTaskAttemptImpl(taskID, 1, eventHandler, taListener, taskConf, new SystemClock(), mockHeartbeatHandler, appCtx, false, resource, createFakeContainerContext(), false);
    TezTaskAttemptID taskAttemptID = taImpl.getTaskAttemptID();
    ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
    taImpl.handle(new TaskAttemptEventSchedule(taskAttemptID, 0, 0));
    taImpl.handle(new TaskAttemptEventSubmitted(taskAttemptID, contId));
    taImpl.handle(new TaskAttemptEventStartedRemotely(taskAttemptID));
    assertEquals("Task attempt is not in the RUNNING state", taImpl.getState(), TaskAttemptState.RUNNING);
    verify(mockHeartbeatHandler).register(taskAttemptID);
    int expectedEventsAtRunning = 6;
    verify(eventHandler, times(expectedEventsAtRunning)).handle(arg.capture());
    verifyEventType(arg.getAllValues().subList(0, expectedEventsAtRunning), SpeculatorEventTaskAttemptStatusUpdate.class, 1);
    taImpl.handle(new TaskAttemptEventStatusUpdate(taskAttemptID, new TaskStatusUpdateEvent(null, 0.1f, null, false)));
    taImpl.handle(new TaskAttemptEventAttemptFailed(taskAttemptID, TaskAttemptEventType.TA_FAILED, TaskFailureType.FATAL, "0", TaskAttemptTerminationCause.APPLICATION_ERROR));
    assertEquals("Task attempt is not in the  FAIL_IN_PROGRESS state", taImpl.getInternalState(), TaskAttemptStateInternal.FAIL_IN_PROGRESS);
    verify(mockHeartbeatHandler).unregister(taskAttemptID);
    assertEquals(1, taImpl.getDiagnostics().size());
    assertEquals("0", taImpl.getDiagnostics().get(0));
    assertEquals(TaskAttemptTerminationCause.APPLICATION_ERROR, taImpl.getTerminationCause());
    assertEquals(TaskAttemptStateInternal.FAIL_IN_PROGRESS, taImpl.getInternalState());
    taImpl.handle(new TaskAttemptEventTezEventUpdate(taImpl.getTaskAttemptID(), Collections.EMPTY_LIST));
    assertFalse("InternalError occurred trying to handle TA_TEZ_EVENT_UPDATE in FAIL_IN_PROGRESS state", eventHandler.internalError);
    taImpl.handle(new TaskAttemptEventContainerTerminated(contId, taskAttemptID, "1", TaskAttemptTerminationCause.CONTAINER_EXITED));
    // verify unregister is not invoked again
    verify(mockHeartbeatHandler, times(1)).unregister(taskAttemptID);
    assertEquals(2, taImpl.getDiagnostics().size());
    assertEquals("1", taImpl.getDiagnostics().get(1));
    // err cause does not change
    assertEquals(TaskAttemptTerminationCause.APPLICATION_ERROR, taImpl.getTerminationCause());
    int expectedEvenstAfterTerminating = expectedEventsAtRunning + 5;
    arg = ArgumentCaptor.forClass(Event.class);
    verify(eventHandler, times(expectedEvenstAfterTerminating)).handle(arg.capture());
    Event e = verifyEventType(arg.getAllValues().subList(expectedEventsAtRunning, expectedEvenstAfterTerminating), TaskEventTAFailed.class, 1);
    TaskEventTAFailed failedEvent = (TaskEventTAFailed) e;
    assertEquals(TaskFailureType.FATAL, failedEvent.getTaskFailureType());
    verifyEventType(arg.getAllValues().subList(expectedEventsAtRunning, expectedEvenstAfterTerminating), AMSchedulerEventTAEnded.class, 1);
    verifyEventType(arg.getAllValues().subList(expectedEventsAtRunning, expectedEvenstAfterTerminating), DAGEventCounterUpdate.class, 1);
    verifyEventType(arg.getAllValues().subList(expectedEventsAtRunning, expectedEvenstAfterTerminating), SpeculatorEventTaskAttemptStatusUpdate.class, 2);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) TaskAttemptEventStatusUpdate(org.apache.tez.dag.app.dag.event.TaskAttemptEventStatusUpdate) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) AMContainerMap(org.apache.tez.dag.app.rm.container.AMContainerMap) Container(org.apache.hadoop.yarn.api.records.Container) TaskAttemptEventTezEventUpdate(org.apache.tez.dag.app.dag.event.TaskAttemptEventTezEventUpdate) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) TezDAGID(org.apache.tez.dag.records.TezDAGID) TaskHeartbeatHandler(org.apache.tez.dag.app.TaskHeartbeatHandler) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule) TezVertexID(org.apache.tez.dag.records.TezVertexID) ContainerHeartbeatHandler(org.apache.tez.dag.app.ContainerHeartbeatHandler) HashSet(java.util.HashSet) TaskAttemptEventStartedRemotely(org.apache.tez.dag.app.dag.event.TaskAttemptEventStartedRemotely) SystemClock(org.apache.hadoop.yarn.util.SystemClock) Resource(org.apache.hadoop.yarn.api.records.Resource) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) TaskEventTAFailed(org.apache.tez.dag.app.dag.event.TaskEventTAFailed) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) TaskCommunicatorManagerInterface(org.apache.tez.dag.app.TaskCommunicatorManagerInterface) ContainerContextMatcher(org.apache.tez.dag.app.rm.container.ContainerContextMatcher) TaskAttemptEventSubmitted(org.apache.tez.dag.app.dag.event.TaskAttemptEventSubmitted) TezTaskID(org.apache.tez.dag.records.TezTaskID) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint) ClusterInfo(org.apache.tez.dag.app.ClusterInfo) NodeId(org.apache.hadoop.yarn.api.records.NodeId) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) TaskAttemptFinishedEvent(org.apache.tez.dag.history.events.TaskAttemptFinishedEvent) TaskEvent(org.apache.tez.dag.app.dag.event.TaskEvent) DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskAttemptEventContainerTerminated(org.apache.tez.dag.app.dag.event.TaskAttemptEventContainerTerminated) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) TaskAttemptEventAttemptFailed(org.apache.tez.dag.app.dag.event.TaskAttemptEventAttemptFailed) Test(org.junit.Test)

Example 15 with AMContainerMap

use of org.apache.tez.dag.app.rm.container.AMContainerMap in project tez by apache.

the class TestTaskAttempt method testSuccess.

@Test(timeout = 5000)
public void testSuccess() throws Exception {
    ApplicationId appId = ApplicationId.newInstance(1, 2);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 0);
    TezDAGID dagID = TezDAGID.getInstance(appId, 1);
    TezVertexID vertexID = TezVertexID.getInstance(dagID, 1);
    TezTaskID taskID = TezTaskID.getInstance(vertexID, 1);
    MockEventHandler eventHandler = spy(new MockEventHandler());
    TaskCommunicatorManagerInterface taListener = createMockTaskAttemptListener();
    Configuration taskConf = new Configuration();
    taskConf.setClass("fs.file.impl", StubbedFS.class, FileSystem.class);
    taskConf.setBoolean("fs.file.impl.disable.cache", true);
    taskConf.setBoolean(TezConfiguration.TEZ_AM_SPECULATION_ENABLED, true);
    locationHint = TaskLocationHint.createTaskLocationHint(new HashSet<String>(Arrays.asList(new String[] { "127.0.0.1" })), null);
    Resource resource = Resource.newInstance(1024, 1);
    NodeId nid = NodeId.newInstance("127.0.0.1", 0);
    @SuppressWarnings("deprecation") ContainerId contId = ContainerId.newInstance(appAttemptId, 3);
    Container container = mock(Container.class);
    when(container.getId()).thenReturn(contId);
    when(container.getNodeId()).thenReturn(nid);
    when(container.getNodeHttpAddress()).thenReturn("localhost:0");
    AMContainerMap containers = new AMContainerMap(mock(ContainerHeartbeatHandler.class), mock(TaskCommunicatorManagerInterface.class), new ContainerContextMatcher(), appCtx);
    containers.addContainerIfNew(container, 0, 0, 0);
    doReturn(new ClusterInfo()).when(appCtx).getClusterInfo();
    doReturn(containers).when(appCtx).getAllContainers();
    TaskHeartbeatHandler mockHeartbeatHandler = mock(TaskHeartbeatHandler.class);
    TaskAttemptImpl taImpl = new MockTaskAttemptImpl(taskID, 1, eventHandler, taListener, taskConf, new SystemClock(), mockHeartbeatHandler, appCtx, false, resource, createFakeContainerContext(), false);
    TezTaskAttemptID taskAttemptID = taImpl.getTaskAttemptID();
    ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
    taImpl.handle(new TaskAttemptEventSchedule(taskAttemptID, 0, 0));
    taImpl.handle(new TaskAttemptEventSubmitted(taskAttemptID, contId));
    taImpl.handle(new TaskAttemptEventStartedRemotely(taskAttemptID));
    assertEquals("Task attempt is not in the RUNNING state", taImpl.getState(), TaskAttemptState.RUNNING);
    verify(mockHeartbeatHandler).register(taskAttemptID);
    int expectedEventsAtRunning = 6;
    verify(eventHandler, times(expectedEventsAtRunning)).handle(arg.capture());
    verifyEventType(arg.getAllValues().subList(0, expectedEventsAtRunning), SpeculatorEventTaskAttemptStatusUpdate.class, 1);
    taImpl.handle(new TaskAttemptEventStatusUpdate(taskAttemptID, new TaskStatusUpdateEvent(null, 0.1f, null, false)));
    taImpl.handle(new TaskAttemptEvent(taskAttemptID, TaskAttemptEventType.TA_DONE));
    assertEquals("Task attempt is not in the  SUCCEEDED state", taImpl.getState(), TaskAttemptState.SUCCEEDED);
    verify(mockHeartbeatHandler).unregister(taskAttemptID);
    assertEquals(0, taImpl.getDiagnostics().size());
    int expectedEvenstAfterTerminating = expectedEventsAtRunning + 5;
    arg = ArgumentCaptor.forClass(Event.class);
    verify(eventHandler, times(expectedEvenstAfterTerminating)).handle(arg.capture());
    Event e = verifyEventType(arg.getAllValues().subList(expectedEventsAtRunning, expectedEvenstAfterTerminating), TaskEventTASucceeded.class, 1);
    assertEquals(TaskEventType.T_ATTEMPT_SUCCEEDED, e.getType());
    verifyEventType(arg.getAllValues().subList(expectedEventsAtRunning, expectedEvenstAfterTerminating), AMSchedulerEventTAEnded.class, 1);
    verifyEventType(arg.getAllValues().subList(expectedEventsAtRunning, expectedEvenstAfterTerminating), DAGEventCounterUpdate.class, 1);
    verifyEventType(arg.getAllValues().subList(expectedEventsAtRunning, expectedEvenstAfterTerminating), SpeculatorEventTaskAttemptStatusUpdate.class, 2);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) TaskAttemptEventStatusUpdate(org.apache.tez.dag.app.dag.event.TaskAttemptEventStatusUpdate) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) AMContainerMap(org.apache.tez.dag.app.rm.container.AMContainerMap) Container(org.apache.hadoop.yarn.api.records.Container) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) TezDAGID(org.apache.tez.dag.records.TezDAGID) TaskHeartbeatHandler(org.apache.tez.dag.app.TaskHeartbeatHandler) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule) TezVertexID(org.apache.tez.dag.records.TezVertexID) ContainerHeartbeatHandler(org.apache.tez.dag.app.ContainerHeartbeatHandler) HashSet(java.util.HashSet) TaskAttemptEventStartedRemotely(org.apache.tez.dag.app.dag.event.TaskAttemptEventStartedRemotely) SystemClock(org.apache.hadoop.yarn.util.SystemClock) Resource(org.apache.hadoop.yarn.api.records.Resource) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) TaskCommunicatorManagerInterface(org.apache.tez.dag.app.TaskCommunicatorManagerInterface) ContainerContextMatcher(org.apache.tez.dag.app.rm.container.ContainerContextMatcher) TaskAttemptEventSubmitted(org.apache.tez.dag.app.dag.event.TaskAttemptEventSubmitted) TezTaskID(org.apache.tez.dag.records.TezTaskID) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint) ClusterInfo(org.apache.tez.dag.app.ClusterInfo) NodeId(org.apache.hadoop.yarn.api.records.NodeId) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) TaskAttemptFinishedEvent(org.apache.tez.dag.history.events.TaskAttemptFinishedEvent) TaskEvent(org.apache.tez.dag.app.dag.event.TaskEvent) DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Aggregations

AMContainerMap (org.apache.tez.dag.app.rm.container.AMContainerMap)44 Test (org.junit.Test)42 Configuration (org.apache.hadoop.conf.Configuration)39 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)38 Container (org.apache.hadoop.yarn.api.records.Container)35 ContainerHeartbeatHandler (org.apache.tez.dag.app.ContainerHeartbeatHandler)33 TaskCommunicatorManagerInterface (org.apache.tez.dag.app.TaskCommunicatorManagerInterface)33 ContainerContextMatcher (org.apache.tez.dag.app.rm.container.ContainerContextMatcher)33 TezDAGID (org.apache.tez.dag.records.TezDAGID)30 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)29 Resource (org.apache.hadoop.yarn.api.records.Resource)29 ClusterInfo (org.apache.tez.dag.app.ClusterInfo)29 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)29 TezVertexID (org.apache.tez.dag.records.TezVertexID)29 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)25 NodeId (org.apache.hadoop.yarn.api.records.NodeId)24 TaskAttemptEventSchedule (org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule)21 TaskAttemptEventSubmitted (org.apache.tez.dag.app.dag.event.TaskAttemptEventSubmitted)21 AppContext (org.apache.tez.dag.app.AppContext)19 TaskAttemptEventStartedRemotely (org.apache.tez.dag.app.dag.event.TaskAttemptEventStartedRemotely)19