use of org.apache.tez.dag.app.dag.event.TaskEventTAKilled in project tez by apache.
the class TestTaskImpl method testKilledTaskTransitionWithLaunchedAttempt.
@Test(timeout = 30000)
public void testKilledTaskTransitionWithLaunchedAttempt() throws InterruptedException {
TezTaskID taskId = getNewTaskID();
scheduleTaskAttempt(taskId);
MockTaskAttemptImpl firstMockTaskAttempt = mockTask.getLastAttempt();
launchTaskAttempt(firstMockTaskAttempt.getID());
mockTask.handle(createTaskTAAddSpecAttempt(mockTask.getLastAttempt().getID()));
MockTaskAttemptImpl secondMockTaskAttempt = mockTask.getLastAttempt();
launchTaskAttempt(secondMockTaskAttempt.getID());
firstMockTaskAttempt.handle(new TaskAttemptEventSchedule(TezTaskAttemptID.fromString(firstMockTaskAttempt.toString()), 10, 10));
secondMockTaskAttempt.handle(new TaskAttemptEventSchedule(TezTaskAttemptID.fromString(secondMockTaskAttempt.toString()), 10, 10));
firstMockTaskAttempt.handle(new TaskAttemptEventSubmitted(TezTaskAttemptID.fromString(firstMockTaskAttempt.toString()), mockContainer.getId()));
secondMockTaskAttempt.handle(new TaskAttemptEventSubmitted(TezTaskAttemptID.fromString(secondMockTaskAttempt.toString()), mockContainer.getId()));
secondMockTaskAttempt.handle(new TaskAttemptEventStartedRemotely(TezTaskAttemptID.fromString(secondMockTaskAttempt.toString())));
firstMockTaskAttempt.handle(new TaskAttemptEventStartedRemotely(TezTaskAttemptID.fromString(firstMockTaskAttempt.toString())));
mockTask.handle(new TaskEventTermination(mockTask.getTaskId(), TaskAttemptTerminationCause.FRAMEWORK_ERROR, "test"));
secondMockTaskAttempt.handle(new TaskAttemptEventAttemptKilled(TezTaskAttemptID.fromString(secondMockTaskAttempt.toString()), "test", TaskAttemptTerminationCause.FRAMEWORK_ERROR));
mockTask.handle(new TaskEventTAKilled(secondMockTaskAttempt.getID(), new TaskAttemptEvent(secondMockTaskAttempt.getID(), TaskAttemptEventType.TA_KILLED)));
firstMockTaskAttempt.handle(new TaskAttemptEventAttemptKilled(TezTaskAttemptID.fromString(firstMockTaskAttempt.toString()), "test", TaskAttemptTerminationCause.FRAMEWORK_ERROR));
mockTask.handle(new TaskEventTAKilled(firstMockTaskAttempt.getID(), new TaskAttemptEvent(firstMockTaskAttempt.getID(), TaskAttemptEventType.TA_KILLED)));
firstMockTaskAttempt.handle(new TaskAttemptEventAttemptKilled(TezTaskAttemptID.fromString(firstMockTaskAttempt.toString()), "test", TaskAttemptTerminationCause.FRAMEWORK_ERROR));
assertEquals("Task should have been killed!", mockTask.getInternalState(), TaskStateInternal.KILLED);
mockTask.handle(createTaskTAAddSpecAttempt(mockTask.getLastAttempt().getID()));
MockTaskAttemptImpl thirdMockTaskAttempt = mockTask.getLastAttempt();
mockTask.handle(createTaskTALauncherEvent(thirdMockTaskAttempt.getID()));
mockTask.handle(createTaskTAAddSpecAttempt(mockTask.getLastAttempt().getID()));
MockTaskAttemptImpl fourthMockTaskAttempt = mockTask.getLastAttempt();
mockTask.handle(createTaskTASucceededEvent(fourthMockTaskAttempt.getID()));
MockTaskAttemptImpl fifthMockTaskAttempt = mockTask.getLastAttempt();
mockTask.handle(createTaskTAFailedEvent(fifthMockTaskAttempt.getID()));
}
Aggregations