use of org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent in project tez by apache.
the class TestDAGRecovery method testDAGRecoverFromInited.
/**
* RecoveryEvents: DAGSubmittedEvent, DAGInitializedEvent
* Recover it as normal dag execution
*/
@Test(timeout = 5000)
public void testDAGRecoverFromInited() {
DAGInitializedEvent dagInitedEvent = new DAGInitializedEvent(dagId, dagInitedTime, "user", "dagName", null);
doReturn(dagInitedEvent).when(dagRecoveryData).getDAGInitializedEvent();
DAGEventRecoverEvent recoveryEvent = new DAGEventRecoverEvent(dagId, dagRecoveryData);
dag.handle(recoveryEvent);
dispatcher.await();
assertEquals(DAGState.RUNNING, dag.getState());
assertEquals(dagInitedTime, dag.initTime);
}
use of org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent in project tez by apache.
the class TestDAGRecovery method testTARecoverFromFailed.
/**
* RecoveryEvents: TaskAttemptStartedEvent -> TaskAttemptFinishedEvent (FAILED)
* Recover it to FAILED
*/
@Test(timeout = 5000)
public void testTARecoverFromFailed() {
initMockDAGRecoveryDataForTaskAttempt();
TaskAttemptStartedEvent taStartedEvent = new TaskAttemptStartedEvent(ta1t1v1Id, "v1", ta1LaunchTime, mock(ContainerId.class), mock(NodeId.class), "", "", "");
TaskAttemptFinishedEvent taFinishedEvent = new TaskAttemptFinishedEvent(ta1t1v1Id, "v1", ta1LaunchTime, ta1FinishedTime, TaskAttemptState.FAILED, TaskFailureType.NON_FATAL, TaskAttemptTerminationCause.INPUT_READ_ERROR, "", null, null, null, 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.FAILED, taskAttempt.getInternalState());
assertEquals(TaskAttemptTerminationCause.INPUT_READ_ERROR, taskAttempt.getTerminationCause());
assertEquals(TaskStateInternal.SCHEDULED, task.getInternalState());
assertEquals(2, task.getAttempts().size());
historyEventHandler.verifyHistoryEvent(0, HistoryEventType.TASK_ATTEMPT_FINISHED);
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 testDAGRecoverFromNew.
/**
* RecoveryEvents: DAGSubmittedEvent
* Recover it as normal dag execution
*/
@Test(timeout = 5000)
public void testDAGRecoverFromNew() {
DAGEventRecoverEvent recoveryEvent = new DAGEventRecoverEvent(dagId, dagRecoveryData);
dag.handle(recoveryEvent);
dispatcher.await();
assertEquals(DAGState.RUNNING, dag.getState());
}
use of org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent in project tez by apache.
the class TestDAGRecovery method testTaskRecoverFromSucceeded.
/**
* RecoveryEvent: TaskStartedEvent -> TaskFinishedEvent
* Recover it to Scheduled
*/
@Test(timeout = 5000)
public void testTaskRecoverFromSucceeded() {
initMockDAGRecoveryDataForTask();
TaskStartedEvent taskStartedEvent = new TaskStartedEvent(t1v1Id, "v1", 0L, 0L);
TaskFinishedEvent taskFinishedEvent = new TaskFinishedEvent(t1v1Id, "v1", 0L, 0L, null, TaskState.SUCCEEDED, "", null, 4);
TaskAttemptStartedEvent taStartedEvent = new TaskAttemptStartedEvent(ta1t1v1Id, "v1", 0L, mock(ContainerId.class), mock(NodeId.class), "", "", "");
List<TezEvent> taGeneratedEvents = new ArrayList<TezEvent>();
EventMetaData metadata = new EventMetaData(EventProducerConsumerType.OUTPUT, "vertex1", "vertex3", ta1t1v2Id);
taGeneratedEvents.add(new TezEvent(DataMovementEvent.create(ByteBuffer.wrap(new byte[0])), metadata));
TaskAttemptFinishedEvent taFinishedEvent = new TaskAttemptFinishedEvent(ta1t1v1Id, "v1", 0L, 0L, TaskAttemptState.SUCCEEDED, null, null, "", null, null, taGeneratedEvents, 0L, null, 0L, null, null, null, null, null);
TaskAttemptRecoveryData taRecoveryData = new TaskAttemptRecoveryData(taStartedEvent, taFinishedEvent);
Map<TezTaskAttemptID, TaskAttemptRecoveryData> taRecoveryDataMap = new HashMap<TezTaskAttemptID, TaskAttemptRecoveryData>();
taRecoveryDataMap.put(ta1t1v1Id, taRecoveryData);
TaskRecoveryData taskRecoveryData = new TaskRecoveryData(taskStartedEvent, taskFinishedEvent, taRecoveryDataMap);
doReturn(taskRecoveryData).when(dagRecoveryData).getTaskRecoveryData(t1v1Id);
doReturn(taRecoveryData).when(dagRecoveryData).getTaskAttemptRecoveryData(ta1t1v1Id);
dag.handle(new DAGEventRecoverEvent(dagId, dagRecoveryData));
dispatcher.await();
VertexImpl vertex1 = (VertexImpl) dag.getVertex(v1Id);
TaskImpl task = (TaskImpl) vertex1.getTask(t1v1Id);
TaskAttemptImpl taskAttempt = (TaskAttemptImpl) task.getAttempt(ta1t1v1Id);
assertEquals(VertexState.RUNNING, vertex1.getState());
assertEquals(1, vertex1.getCompletedTasks());
assertEquals(TaskStateInternal.SUCCEEDED, task.getInternalState());
assertEquals(TaskAttemptStateInternal.SUCCEEDED, taskAttempt.getInternalState());
}
use of org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent in project tez by apache.
the class TestDAGRecovery method testDAGRecoverFromStarted.
@Test(timeout = 5000)
public void testDAGRecoverFromStarted() {
DAGInitializedEvent dagInitedEvent = new DAGInitializedEvent(dagId, dagInitedTime, "user", "dagName", null);
doReturn(dagInitedEvent).when(dagRecoveryData).getDAGInitializedEvent();
DAGStartedEvent dagStartedEvent = new DAGStartedEvent(dagId, dagStartedTime, "user", "dagName");
doReturn(dagStartedEvent).when(dagRecoveryData).getDAGStartedEvent();
DAGEventRecoverEvent recoveryEvent = new DAGEventRecoverEvent(dagId, dagRecoveryData);
dag.handle(recoveryEvent);
dispatcher.await();
assertEquals(DAGState.RUNNING, dag.getState());
assertEquals(dagInitedTime, dag.initTime);
assertEquals(dagStartedTime, dag.startTime);
}
Aggregations