use of org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent in project tez by apache.
the class TestDAGRecovery method testVertexRecoverFromStart.
/**
* RecoveryEvents:
* DAG: DAGInitedEvent -> DAGStartedEvent
* V1: VertexReconfigrationDoneEvent -> VertexInitializedEvent -> VertexStartedEvent
*
* V1 skip initialization.
*/
@Test(timeout = 5000)
public void testVertexRecoverFromStart() {
initMockDAGRecoveryDataForVertex();
List<TezEvent> inputGeneratedTezEvents = new ArrayList<TezEvent>();
VertexInitializedEvent v1InitedEvent = new VertexInitializedEvent(v1Id, "vertex1", 0L, v1InitedTime, v1NumTask, "", null, inputGeneratedTezEvents, null);
VertexConfigurationDoneEvent v1ReconfigureDoneEvent = new VertexConfigurationDoneEvent(v1Id, 0L, v1NumTask, null, null, null, true);
VertexStartedEvent v1StartedEvent = new VertexStartedEvent(v1Id, 0L, v1StartedTime);
VertexRecoveryData vertexRecoveryData = new VertexRecoveryData(v1InitedEvent, v1ReconfigureDoneEvent, v1StartedEvent, null, new HashMap<TezTaskID, TaskRecoveryData>(), false);
doReturn(vertexRecoveryData).when(dagRecoveryData).getVertexRecoveryData(v1Id);
DAGEventRecoverEvent recoveryEvent = new DAGEventRecoverEvent(dagId, dagRecoveryData);
dag.handle(recoveryEvent);
dispatcher.await();
VertexImpl v1 = (VertexImpl) dag.getVertex("vertex1");
VertexImpl v2 = (VertexImpl) dag.getVertex("vertex2");
VertexImpl v3 = (VertexImpl) dag.getVertex("vertex3");
assertEquals(DAGState.RUNNING, dag.getState());
// v1 skip initialization
assertEquals(VertexState.RUNNING, v1.getState());
assertEquals(v1InitedTime, v1.initedTime);
assertEquals(v1StartedTime, v1.startedTime);
assertEquals(v1NumTask, v1.getTotalTasks());
assertEquals(VertexState.RUNNING, v2.getState());
assertEquals(VertexState.RUNNING, v3.getState());
}
use of org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent in project tez by apache.
the class TestDAGRecovery method testTARecoverFromNewToFailed.
/**
* RecoveryEvents: TaskAttemptFinishedEvent (FAILED)
* Recover it to FAILED
*/
@Test(timeout = 5000)
public void testTARecoverFromNewToFailed() {
initMockDAGRecoveryDataForTaskAttempt();
TaskAttemptFinishedEvent taFinishedEvent = new TaskAttemptFinishedEvent(ta1t1v1Id, "v1", ta1LaunchTime, ta1FinishedTime, TaskAttemptState.FAILED, TaskFailureType.NON_FATAL, TaskAttemptTerminationCause.CONTAINER_LAUNCH_FAILED, "", null, null, null, 0L, null, 0L, null, null, null, null, null);
TaskAttemptRecoveryData taRecoveryData = new TaskAttemptRecoveryData(null, taFinishedEvent);
doReturn(taRecoveryData).when(dagRecoveryData).getTaskAttemptRecoveryData(ta1t1v1Id);
dag.handle(new DAGEventRecoverEvent(dagId, dagRecoveryData));
dispatcher.await();
TaskImpl task = (TaskImpl) dag.getVertex(v1Id).getTask(t1v1Id);
TaskAttemptImpl taskAttempt = (TaskAttemptImpl) task.getAttempt(ta1t1v1Id);
assertEquals(TaskAttemptStateInternal.FAILED, taskAttempt.getInternalState());
assertEquals(TaskAttemptTerminationCause.CONTAINER_LAUNCH_FAILED, taskAttempt.getTerminationCause());
historyEventHandler.verifyHistoryEvent(0, HistoryEventType.TASK_ATTEMPT_STARTED);
historyEventHandler.verifyHistoryEvent(0, HistoryEventType.TASK_ATTEMPT_FINISHED);
assertEquals(1, task.failedAttempts);
// new task attempt is scheduled
assertEquals(2, task.getAttempts().size());
assertEquals(ta1FinishedTime, taskAttempt.getFinishTime());
}
use of org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent in project tez by apache.
the class TestDAGRecovery method testTARecoverFromSucceeded.
/**
* RecoveryEvents: TaskAttemptStartedEvent -> TaskAttemptFinishedEvent (SUCCEEDED)
* Recover it to SUCCEEDED
*/
@Test(timeout = 5000)
public void testTARecoverFromSucceeded() {
initMockDAGRecoveryDataForTaskAttempt();
TaskAttemptStartedEvent taStartedEvent = new TaskAttemptStartedEvent(ta1t1v1Id, "v1", ta1LaunchTime, mock(ContainerId.class), mock(NodeId.class), "", "", "");
List<TezEvent> taGeneratedEvents = new ArrayList<TezEvent>();
EventMetaData sourceInfo = new EventMetaData(EventProducerConsumerType.INPUT, "vertex1", "vertex3", ta1t1v1Id);
taGeneratedEvents.add(new TezEvent(DataMovementEvent.create(ByteBuffer.wrap(new byte[0])), sourceInfo));
TaskAttemptFinishedEvent taFinishedEvent = new TaskAttemptFinishedEvent(ta1t1v1Id, "v1", ta1LaunchTime, ta1FinishedTime, TaskAttemptState.SUCCEEDED, null, null, "", null, null, taGeneratedEvents, 0L, null, 0L, null, null, null, null, null);
TaskAttemptRecoveryData taRecoveryData = new TaskAttemptRecoveryData(taStartedEvent, taFinishedEvent);
doReturn(taRecoveryData).when(dagRecoveryData).getTaskAttemptRecoveryData(ta1t1v1Id);
dag.handle(new DAGEventRecoverEvent(dagId, dagRecoveryData));
dispatcher.await();
TaskImpl task = (TaskImpl) dag.getVertex(v1Id).getTask(t1v1Id);
TaskAttemptImpl taskAttempt = (TaskAttemptImpl) task.getAttempt(ta1t1v1Id);
assertEquals(TaskAttemptStateInternal.SUCCEEDED, taskAttempt.getInternalState());
historyEventHandler.verifyHistoryEvent(0, HistoryEventType.TASK_ATTEMPT_FINISHED);
assertEquals(TaskStateInternal.SUCCEEDED, task.getInternalState());
assertEquals(ta1LaunchTime, taskAttempt.getLaunchTime());
assertEquals(ta1FinishedTime, taskAttempt.getFinishTime());
}
use of org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent in project tez by apache.
the class TestDAGRecovery method testDAGRecoverFromDesiredFailed.
/**
* RecoveryEvents: SummaryEvent_DAGFinishedEvent(FAILED)
* Recover dag to FAILED and all of its vertices to FAILED
*/
@Test(timeout = 5000)
public void testDAGRecoverFromDesiredFailed() {
DAGEventRecoverEvent recoveryEvent = new DAGEventRecoverEvent(dagId, DAGState.FAILED, dagRecoveryData);
dag.handle(recoveryEvent);
dispatcher.await();
assertEquals(DAGState.FAILED, dag.getState());
assertEquals(3, dag.getVertices().size());
assertEquals(VertexState.FAILED, dag.getVertex("vertex1").getState());
assertEquals(VertexState.FAILED, dag.getVertex("vertex2").getState());
assertEquals(VertexState.FAILED, dag.getVertex("vertex3").getState());
// DAG#initTime, startTime is not guaranteed to be recovered in this case
}
use of org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent in project tez by apache.
the class TestDAGRecovery method testTaskRecoverFromStarted.
/**
* RecoveryEvent: TaskStartedEvent
* Recover it to Scheduled
*/
@Test(timeout = 5000)
public void testTaskRecoverFromStarted() {
initMockDAGRecoveryDataForTask();
TaskStartedEvent taskStartedEvent = new TaskStartedEvent(t1v1Id, "v1", 0L, 0L);
TaskRecoveryData taskRecoveryData = new TaskRecoveryData(taskStartedEvent, null, null);
doReturn(taskRecoveryData).when(dagRecoveryData).getTaskRecoveryData(t1v1Id);
dag.handle(new DAGEventRecoverEvent(dagId, dagRecoveryData));
dispatcher.await();
VertexImpl vertex1 = (VertexImpl) dag.getVertex(v1Id);
TaskImpl task = (TaskImpl) vertex1.getTask(t1v1Id);
assertEquals(TaskStateInternal.SCHEDULED, task.getInternalState());
}
Aggregations