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());
}
Aggregations