Search in sources :

Example 46 with TezTaskAttemptID

use of org.apache.tez.dag.records.TezTaskAttemptID in project tez by apache.

the class TestAMContainer method testMultipleAllocationsWhileActive.

@SuppressWarnings("rawtypes")
@Test(timeout = 5000)
public void testMultipleAllocationsWhileActive() {
    WrappedContainer wc = new WrappedContainer();
    List<Event> outgoingEvents;
    wc.launchContainer();
    wc.containerLaunched();
    wc.assignTaskAttempt(wc.taskAttemptID);
    wc.verifyState(AMContainerState.RUNNING);
    TezTaskAttemptID taID2 = TezTaskAttemptID.getInstance(wc.taskID, 2);
    wc.assignTaskAttempt(taID2);
    wc.verifyState(AMContainerState.STOP_REQUESTED);
    verifyUnregisterRunningContainer(wc.tal, wc.containerID, 0, ContainerEndReason.FRAMEWORK_ERROR, "Multiple simultaneous taskAttempt");
    verify(wc.chh).unregister(wc.containerID);
    // 1 for NM stop request. 2 TERMINATING to TaskAttempt.
    outgoingEvents = wc.verifyCountAndGetOutgoingEvents(4);
    verifyUnOrderedOutgoingEventTypes(outgoingEvents, ContainerLauncherEventType.CONTAINER_STOP_REQUEST, TaskAttemptEventType.TA_CONTAINER_TERMINATING, TaskAttemptEventType.TA_CONTAINER_TERMINATING, AMNodeEventType.N_CONTAINER_COMPLETED);
    assertTrue(wc.amContainer.isInErrorState());
    wc.nmStopSent();
    wc.containerCompleted();
    wc.verifyHistoryStopEvent();
    // 1 Inform scheduler. 2 TERMINATED to TaskAttempt.
    outgoingEvents = wc.verifyCountAndGetOutgoingEvents(2);
    verifyUnOrderedOutgoingEventTypes(outgoingEvents, TaskAttemptEventType.TA_CONTAINER_TERMINATED, TaskAttemptEventType.TA_CONTAINER_TERMINATED);
    assertNull(wc.amContainer.getCurrentTaskAttempt());
    assertEquals(2, wc.amContainer.getAllTaskAttempts().size());
}
Also used : Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Example 47 with TezTaskAttemptID

use of org.apache.tez.dag.records.TezTaskAttemptID in project tez by apache.

the class TestAMContainer method testNodeFailedAtCompletedMultipleSuccessfulTAs.

@SuppressWarnings("rawtypes")
@Test(timeout = 5000)
public void testNodeFailedAtCompletedMultipleSuccessfulTAs() {
    WrappedContainer wc = new WrappedContainer();
    List<Event> outgoingEvents;
    wc.launchContainer();
    wc.containerLaunched();
    wc.assignTaskAttempt(wc.taskAttemptID);
    wc.taskAttemptSucceeded(wc.taskAttemptID);
    TezTaskAttemptID taID2 = TezTaskAttemptID.getInstance(wc.taskID, 2);
    wc.assignTaskAttempt(taID2);
    wc.taskAttemptSucceeded(taID2);
    wc.stopRequest();
    wc.nmStopSent();
    wc.containerCompleted();
    wc.verifyState(AMContainerState.COMPLETED);
    wc.nodeFailed();
    outgoingEvents = wc.verifyCountAndGetOutgoingEvents(2);
    verifyUnOrderedOutgoingEventTypes(outgoingEvents, TaskAttemptEventType.TA_NODE_FAILED, TaskAttemptEventType.TA_NODE_FAILED);
    assertNull(wc.amContainer.getCurrentTaskAttempt());
    assertEquals(2, wc.amContainer.getAllTaskAttempts().size());
}
Also used : Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Example 48 with TezTaskAttemptID

use of org.apache.tez.dag.records.TezTaskAttemptID in project tez by apache.

the class TestAMContainer method testNodeFailedAtRunningMultipleAttempts.

@SuppressWarnings("rawtypes")
@Test(timeout = 5000)
public void testNodeFailedAtRunningMultipleAttempts() {
    WrappedContainer wc = new WrappedContainer();
    List<Event> outgoingEvents;
    wc.launchContainer();
    wc.containerLaunched();
    wc.assignTaskAttempt(wc.taskAttemptID);
    wc.taskAttemptSucceeded(wc.taskAttemptID);
    TezTaskAttemptID taID2 = TezTaskAttemptID.getInstance(wc.taskID, 2);
    wc.assignTaskAttempt(taID2);
    wc.verifyState(AMContainerState.RUNNING);
    wc.nodeFailed();
    // Expecting a complete event from the RM
    wc.verifyState(AMContainerState.STOPPING);
    outgoingEvents = wc.verifyCountAndGetOutgoingEvents(5);
    verifyUnOrderedOutgoingEventTypes(outgoingEvents, TaskAttemptEventType.TA_NODE_FAILED, TaskAttemptEventType.TA_NODE_FAILED, TaskAttemptEventType.TA_CONTAINER_TERMINATING, AMSchedulerEventType.S_CONTAINER_DEALLOCATE, AMNodeEventType.N_CONTAINER_COMPLETED);
    for (Event event : outgoingEvents) {
        if (event.getType() == TaskAttemptEventType.TA_NODE_FAILED) {
            TaskAttemptEventNodeFailed nfEvent = (TaskAttemptEventNodeFailed) event;
            assertTrue(nfEvent.getDiagnosticInfo().contains("nodeFailed"));
        }
    }
    wc.containerCompleted();
    wc.verifyHistoryStopEvent();
    outgoingEvents = wc.verifyCountAndGetOutgoingEvents(1);
    verifyUnOrderedOutgoingEventTypes(outgoingEvents, TaskAttemptEventType.TA_CONTAINER_TERMINATED);
    assertFalse(wc.amContainer.isInErrorState());
    assertNull(wc.amContainer.getCurrentTaskAttempt());
    assertEquals(2, wc.amContainer.getAllTaskAttempts().size());
}
Also used : Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TaskAttemptEventNodeFailed(org.apache.tez.dag.app.dag.event.TaskAttemptEventNodeFailed) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Example 49 with TezTaskAttemptID

use of org.apache.tez.dag.records.TezTaskAttemptID in project tez by apache.

the class TestAMContainer method tetMultipleSuccessfulTaskFlow.

@Test(timeout = 5000)
public // Assign before launch.
void tetMultipleSuccessfulTaskFlow() {
    WrappedContainer wc = new WrappedContainer();
    wc.verifyState(AMContainerState.ALLOCATED);
    // Launch request.
    wc.launchContainer();
    wc.verifyState(AMContainerState.LAUNCHING);
    // 1 Launch request.
    wc.verifyCountAndGetOutgoingEvents(1);
    verify(wc.tal).registerRunningContainer(wc.containerID, 0);
    assertNull(wc.amContainer.getCurrentTaskAttempt());
    // Assign task.
    wc.assignTaskAttempt(wc.taskAttemptID);
    wc.verifyState(AMContainerState.LAUNCHING);
    wc.verifyNoOutgoingEvents();
    assertEquals(wc.taskAttemptID, wc.amContainer.getCurrentTaskAttempt());
    // Container Launched
    wc.containerLaunched();
    wc.verifyState(AMContainerState.RUNNING);
    wc.verifyNoOutgoingEvents();
    assertEquals(wc.taskAttemptID, wc.amContainer.getCurrentTaskAttempt());
    // Once for the previous NO_TASKS, one for the actual task.
    verify(wc.chh).register(wc.containerID);
    ArgumentCaptor<AMContainerTask> argumentCaptor = ArgumentCaptor.forClass(AMContainerTask.class);
    verify(wc.tal, times(1)).registerTaskAttempt(argumentCaptor.capture(), eq(wc.containerID), eq(0));
    assertEquals(1, argumentCaptor.getAllValues().size());
    assertEquals(wc.taskAttemptID, argumentCaptor.getAllValues().get(0).getTask().getTaskAttemptID());
    // Attempt succeeded
    wc.taskAttemptSucceeded(wc.taskAttemptID);
    wc.verifyState(AMContainerState.IDLE);
    wc.verifyNoOutgoingEvents();
    assertNull(wc.amContainer.getCurrentTaskAttempt());
    verifyUnregisterTaskAttempt(wc.tal, wc.taskAttemptID, 0, TaskAttemptEndReason.OTHER, null);
    TezTaskAttemptID taId2 = TezTaskAttemptID.getInstance(wc.taskID, 2);
    wc.assignTaskAttempt(taId2);
    wc.verifyState(AMContainerState.RUNNING);
    argumentCaptor = ArgumentCaptor.forClass(AMContainerTask.class);
    verify(wc.tal, times(2)).registerTaskAttempt(argumentCaptor.capture(), eq(wc.containerID), eq(0));
    assertEquals(2, argumentCaptor.getAllValues().size());
    assertEquals(taId2, argumentCaptor.getAllValues().get(1).getTask().getTaskAttemptID());
    // Attempt succeeded
    wc.taskAttemptSucceeded(taId2);
    wc.verifyState(AMContainerState.IDLE);
    wc.verifyNoOutgoingEvents();
    assertNull(wc.amContainer.getCurrentTaskAttempt());
    verifyUnregisterTaskAttempt(wc.tal, wc.taskAttemptID, 0, TaskAttemptEndReason.OTHER, null);
    // Container completed
    wc.containerCompleted();
    wc.verifyHistoryStopEvent();
    wc.verifyState(AMContainerState.COMPLETED);
    List<Event> outgoingEvents = wc.verifyCountAndGetOutgoingEvents(1);
    verifyUnOrderedOutgoingEventTypes(outgoingEvents, AMNodeEventType.N_CONTAINER_COMPLETED);
    verifyUnregisterRunningContainer(wc.tal, wc.containerID, 0, ContainerEndReason.COMPLETED, null);
    verify(wc.chh).unregister(wc.containerID);
    assertEquals(2, wc.amContainer.getAllTaskAttempts().size());
    assertFalse(wc.amContainer.isInErrorState());
}
Also used : Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Example 50 with TezTaskAttemptID

use of org.apache.tez.dag.records.TezTaskAttemptID in project tez by apache.

the class TestAMContainer method testDuplicateCompletedEvents.

@Test(timeout = 5000)
public void testDuplicateCompletedEvents() {
    WrappedContainer wc = new WrappedContainer();
    wc.launchContainer();
    wc.containerLaunched();
    wc.assignTaskAttempt(wc.taskAttemptID);
    wc.taskAttemptSucceeded(wc.taskAttemptID);
    TezTaskAttemptID taID2 = TezTaskAttemptID.getInstance(wc.taskID, 2);
    wc.assignTaskAttempt(taID2);
    wc.taskAttemptSucceeded(taID2);
    wc.stopRequest();
    wc.nmStopSent();
    wc.containerCompleted();
    wc.verifyState(AMContainerState.COMPLETED);
    wc.verifyNoOutgoingEvents();
    wc.containerCompleted();
    wc.verifyNoOutgoingEvents();
    wc.verifyHistoryStopEvent();
}
Also used : TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Aggregations

TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)167 Test (org.junit.Test)124 TezTaskID (org.apache.tez.dag.records.TezTaskID)61 TezVertexID (org.apache.tez.dag.records.TezVertexID)54 Container (org.apache.hadoop.yarn.api.records.Container)48 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)46 TezDAGID (org.apache.tez.dag.records.TezDAGID)43 Configuration (org.apache.hadoop.conf.Configuration)42 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)41 Priority (org.apache.hadoop.yarn.api.records.Priority)41 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)41 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)33 Resource (org.apache.hadoop.yarn.api.records.Resource)30 TaskCommunicatorManagerInterface (org.apache.tez.dag.app.TaskCommunicatorManagerInterface)28 EventMetaData (org.apache.tez.runtime.api.impl.EventMetaData)28 ClusterInfo (org.apache.tez.dag.app.ClusterInfo)27 ContainerHeartbeatHandler (org.apache.tez.dag.app.ContainerHeartbeatHandler)27 AMContainerMap (org.apache.tez.dag.app.rm.container.AMContainerMap)27 ContainerContextMatcher (org.apache.tez.dag.app.rm.container.ContainerContextMatcher)27 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)25