Search in sources :

Example 6 with TaskAttemptEventOutputFailed

use of org.apache.tez.dag.app.dag.event.TaskAttemptEventOutputFailed in project tez by apache.

the class TestTaskImpl method testSpeculatedThenRetroactiveFailure.

@Test(timeout = 20000)
public void testSpeculatedThenRetroactiveFailure() {
    TezTaskID taskId = getNewTaskID();
    scheduleTaskAttempt(taskId);
    MockTaskAttemptImpl firstAttempt = mockTask.getLastAttempt();
    launchTaskAttempt(firstAttempt.getID());
    updateAttemptState(firstAttempt, TaskAttemptState.RUNNING);
    // Add a speculative task attempt
    mockTask.handle(createTaskTAAddSpecAttempt(firstAttempt.getID()));
    MockTaskAttemptImpl specAttempt = mockTask.getLastAttempt();
    launchTaskAttempt(specAttempt.getID());
    updateAttemptState(specAttempt, TaskAttemptState.RUNNING);
    assertEquals(2, mockTask.getAttemptList().size());
    // Have the first task succeed
    eventHandler.events.clear();
    mockTask.handle(createTaskTASucceededEvent(firstAttempt.getID()));
    // The task should now have succeeded and sent kill to other attempt
    assertTaskSucceededState();
    verify(mockTask.stateChangeNotifier).taskSucceeded(any(String.class), eq(taskId), eq(firstAttempt.getID().getId()));
    @SuppressWarnings("rawtypes") Event event = eventHandler.events.get(eventHandler.events.size() - 1);
    assertEquals(TaskAttemptEventType.TA_KILL_REQUEST, event.getType());
    assertEquals(specAttempt.getID(), ((TaskAttemptEventKillRequest) event).getTaskAttemptID());
    // Emulate the spec attempt being killed
    mockTask.handle(createTaskTAKilledEvent(specAttempt.getID()));
    assertTaskSucceededState();
    // Now fail the attempt after it has succeeded
    TezTaskAttemptID mockDestId = mock(TezTaskAttemptID.class);
    TezEvent mockTezEvent = mock(TezEvent.class);
    EventMetaData meta = new EventMetaData(EventProducerConsumerType.INPUT, "Vertex", "Edge", mockDestId);
    when(mockTezEvent.getSourceInfo()).thenReturn(meta);
    TaskAttemptEventOutputFailed outputFailedEvent = new TaskAttemptEventOutputFailed(mockDestId, mockTezEvent, 1);
    eventHandler.events.clear();
    mockTask.handle(createTaskTAFailedEvent(firstAttempt.getID(), TaskFailureType.NON_FATAL, outputFailedEvent));
    // The task should still be in the scheduled state
    assertTaskScheduledState();
    event = eventHandler.events.get(eventHandler.events.size() - 1);
    Assert.assertEquals(VertexEventType.V_TASK_RESCHEDULED, event.getType());
    // There should be a new attempt, and report of output read error
    // should be the causal TA
    List<MockTaskAttemptImpl> attempts = mockTask.getAttemptList();
    Assert.assertEquals(3, attempts.size());
    MockTaskAttemptImpl newAttempt = attempts.get(2);
    Assert.assertEquals(mockDestId, newAttempt.getSchedulingCausalTA());
}
Also used : TaskAttemptEventOutputFailed(org.apache.tez.dag.app.dag.event.TaskAttemptEventOutputFailed) TaskFinishedEvent(org.apache.tez.dag.history.events.TaskFinishedEvent) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) HistoryEvent(org.apache.tez.dag.history.HistoryEvent) TezAbstractEvent(org.apache.tez.common.TezAbstractEvent) DataMovementEvent(org.apache.tez.runtime.api.events.DataMovementEvent) TaskEvent(org.apache.tez.dag.app.dag.event.TaskEvent) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskAttemptEventTerminationCauseEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEventTerminationCauseEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TezTaskID(org.apache.tez.dag.records.TezTaskID) EventMetaData(org.apache.tez.runtime.api.impl.EventMetaData) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Aggregations

TaskAttemptEventOutputFailed (org.apache.tez.dag.app.dag.event.TaskAttemptEventOutputFailed)6 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)6 InputReadErrorEvent (org.apache.tez.runtime.api.events.InputReadErrorEvent)6 TezTaskID (org.apache.tez.dag.records.TezTaskID)5 EventMetaData (org.apache.tez.runtime.api.impl.EventMetaData)5 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)5 TaskAttemptEvent (org.apache.tez.dag.app.dag.event.TaskAttemptEvent)4 TaskEvent (org.apache.tez.dag.app.dag.event.TaskEvent)4 Test (org.junit.Test)4 Event (org.apache.hadoop.yarn.event.Event)3 TaskEventTAFailed (org.apache.tez.dag.app.dag.event.TaskEventTAFailed)3 DAGHistoryEvent (org.apache.tez.dag.history.DAGHistoryEvent)3 Configuration (org.apache.hadoop.conf.Configuration)2 TezAbstractEvent (org.apache.tez.common.TezAbstractEvent)2 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)2 TaskAttemptEventSchedule (org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule)2 TaskAttemptEventStartedRemotely (org.apache.tez.dag.app.dag.event.TaskAttemptEventStartedRemotely)2 TaskAttemptEventSubmitted (org.apache.tez.dag.app.dag.event.TaskAttemptEventSubmitted)2 HashSet (java.util.HashSet)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1