Search in sources :

Example 11 with DAGEventRecoverEvent

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);
}
Also used : DAGEventRecoverEvent(org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent) DAGInitializedEvent(org.apache.tez.dag.history.events.DAGInitializedEvent) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Example 12 with DAGEventRecoverEvent

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());
}
Also used : DAGEventRecoverEvent(org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) NodeId(org.apache.hadoop.yarn.api.records.NodeId) TaskAttemptFinishedEvent(org.apache.tez.dag.history.events.TaskAttemptFinishedEvent) TaskAttemptStartedEvent(org.apache.tez.dag.history.events.TaskAttemptStartedEvent) TaskAttemptRecoveryData(org.apache.tez.dag.app.RecoveryParser.TaskAttemptRecoveryData) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Example 13 with DAGEventRecoverEvent

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());
}
Also used : DAGEventRecoverEvent(org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Example 14 with DAGEventRecoverEvent

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());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TaskStartedEvent(org.apache.tez.dag.history.events.TaskStartedEvent) TaskAttemptStartedEvent(org.apache.tez.dag.history.events.TaskAttemptStartedEvent) TaskAttemptRecoveryData(org.apache.tez.dag.app.RecoveryParser.TaskAttemptRecoveryData) TaskRecoveryData(org.apache.tez.dag.app.RecoveryParser.TaskRecoveryData) DAGEventRecoverEvent(org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent) TaskFinishedEvent(org.apache.tez.dag.history.events.TaskFinishedEvent) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) NodeId(org.apache.hadoop.yarn.api.records.NodeId) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskAttemptFinishedEvent(org.apache.tez.dag.history.events.TaskAttemptFinishedEvent) EventMetaData(org.apache.tez.runtime.api.impl.EventMetaData) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Example 15 with DAGEventRecoverEvent

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);
}
Also used : DAGEventRecoverEvent(org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent) DAGStartedEvent(org.apache.tez.dag.history.events.DAGStartedEvent) DAGInitializedEvent(org.apache.tez.dag.history.events.DAGInitializedEvent) Test(org.junit.Test) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)

Aggregations

DAGEventRecoverEvent (org.apache.tez.dag.app.dag.event.DAGEventRecoverEvent)22 StateChangeNotifierForTest (org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)21 Test (org.junit.Test)21 TaskAttemptRecoveryData (org.apache.tez.dag.app.RecoveryParser.TaskAttemptRecoveryData)8 TaskAttemptFinishedEvent (org.apache.tez.dag.history.events.TaskAttemptFinishedEvent)7 ArrayList (java.util.ArrayList)6 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)6 NodeId (org.apache.hadoop.yarn.api.records.NodeId)6 TaskRecoveryData (org.apache.tez.dag.app.RecoveryParser.TaskRecoveryData)6 TaskAttemptStartedEvent (org.apache.tez.dag.history.events.TaskAttemptStartedEvent)6 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)6 VertexRecoveryData (org.apache.tez.dag.app.RecoveryParser.VertexRecoveryData)4 VertexInitializedEvent (org.apache.tez.dag.history.events.VertexInitializedEvent)4 TaskStartedEvent (org.apache.tez.dag.history.events.TaskStartedEvent)3 VertexConfigurationDoneEvent (org.apache.tez.dag.history.events.VertexConfigurationDoneEvent)3 TezTaskID (org.apache.tez.dag.records.TezTaskID)3 EventMetaData (org.apache.tez.runtime.api.impl.EventMetaData)3 HashMap (java.util.HashMap)2 DAGInitializedEvent (org.apache.tez.dag.history.events.DAGInitializedEvent)2 TaskFinishedEvent (org.apache.tez.dag.history.events.TaskFinishedEvent)2