use of org.apache.tez.dag.app.dag.event.DAGEventTerminateDag in project tez by apache.
the class TestCommit method _testDAGKilledWhileRunning_OnVertexSuccess.
// DAG killed while dag is still in RUNNING and vertex is in COMMITTING
private void _testDAGKilledWhileRunning_OnVertexSuccess(DAGTerminationCause terminationCause) throws Exception {
conf.setBoolean(TezConfiguration.TEZ_AM_COMMIT_ALL_OUTPUTS_ON_DAG_SUCCESS, false);
setupDAG(createDAGPlan(true, true));
initDAG(dag);
startDAG(dag);
VertexImpl v1 = (VertexImpl) dag.getVertex("vertex1");
VertexImpl v2 = (VertexImpl) dag.getVertex("vertex2");
VertexImpl v3 = (VertexImpl) dag.getVertex("vertex3");
// need to make vertices to go to SUCCEEDED
v1.handle(new VertexEventTaskCompleted(v1.getTask(0).getTaskId(), TaskState.SUCCEEDED));
v2.handle(new VertexEventTaskCompleted(v2.getTask(0).getTaskId(), TaskState.SUCCEEDED));
v3.handle(new VertexEventTaskCompleted(v3.getTask(0).getTaskId(), TaskState.SUCCEEDED));
Assert.assertEquals(VertexState.COMMITTING, v3.getState());
// dag is still in RUNNING because v3 has not completed
Assert.assertEquals(DAGState.RUNNING, dag.getState());
dag.handle(new DAGEventTerminateDag(dag.getID(), terminationCause, null));
waitUntil(dag, terminationCause.getFinishedState());
Assert.assertEquals(VertexState.SUCCEEDED, v1.getState());
Assert.assertEquals(VertexState.SUCCEEDED, v2.getState());
Assert.assertEquals(VertexState.KILLED, v3.getState());
Assert.assertEquals(VertexTerminationCause.DAG_TERMINATED, v3.getTerminationCause());
Assert.assertTrue(v3.commitFutures.isEmpty());
Assert.assertEquals(terminationCause.getFinishedState(), dag.getState());
Assert.assertEquals(terminationCause, dag.getTerminationCause());
Assert.assertTrue(dag.commitFutures.isEmpty());
// commit uv12 may not have started, so can't verify the VertexGroupCommitStartedEvent
historyEventHandler.verifyVertexGroupCommitFinishedEvent("uv12", 0);
historyEventHandler.verifyVertexCommitStartedEvent(v1.getVertexId(), 0);
historyEventHandler.verifyVertexFinishedEvent(v1.getVertexId(), 1);
historyEventHandler.verifyVertexCommitStartedEvent(v2.getVertexId(), 0);
historyEventHandler.verifyVertexFinishedEvent(v2.getVertexId(), 1);
historyEventHandler.verifyVertexCommitStartedEvent(v3.getVertexId(), 1);
historyEventHandler.verifyVertexFinishedEvent(v3.getVertexId(), 1);
historyEventHandler.verifyDAGCommitStartedEvent(dag.getID(), 0);
historyEventHandler.verifyDAGFinishedEvent(dag.getID(), 1);
CountingOutputCommitter v12OutputCommitter = (CountingOutputCommitter) v1.getOutputCommitter("v12Out");
CountingOutputCommitter v3OutputCommitter = (CountingOutputCommitter) v3.getOutputCommitter("v3Out");
Assert.assertEquals(1, v12OutputCommitter.initCounter);
Assert.assertEquals(1, v12OutputCommitter.setupCounter);
// commit may not have started, so can't verify commitCounter
Assert.assertEquals(1, v12OutputCommitter.abortCounter);
Assert.assertEquals(1, v3OutputCommitter.initCounter);
Assert.assertEquals(1, v3OutputCommitter.setupCounter);
// commit may not have started, so can't verify commitCounter
Assert.assertEquals(1, v3OutputCommitter.abortCounter);
}
use of org.apache.tez.dag.app.dag.event.DAGEventTerminateDag in project tez by apache.
the class TestCommit method testVertexKilledWhileCommitting.
@Test(timeout = 5000)
public void testVertexKilledWhileCommitting() throws Exception {
conf.setBoolean(TezConfiguration.TEZ_AM_COMMIT_ALL_OUTPUTS_ON_DAG_SUCCESS, false);
setupDAG(createDAGPlan_SingleVertexWith2Committer(true, true));
initDAG(dag);
startDAG(dag);
VertexImpl v1 = (VertexImpl) dag.getVertex("vertex1");
v1.handle(new VertexEventTaskCompleted(v1.getTask(0).getTaskId(), TaskState.SUCCEEDED));
Assert.assertEquals(VertexState.COMMITTING, v1.getState());
// kill dag which will trigger the vertex killed event
dag.handle(new DAGEventTerminateDag(dag.getID(), DAGTerminationCause.DAG_KILL, null));
dispatcher.await();
Assert.assertEquals(VertexState.KILLED, v1.getState());
Assert.assertTrue(v1.commitFutures.isEmpty());
Assert.assertEquals(VertexTerminationCause.DAG_TERMINATED, v1.getTerminationCause());
Assert.assertEquals(DAGState.KILLED, dag.getState());
Assert.assertEquals(DAGTerminationCause.DAG_KILL, dag.getTerminationCause());
historyEventHandler.verifyVertexCommitStartedEvent(v1.getVertexId(), 1);
historyEventHandler.verifyVertexFinishedEvent(v1.getVertexId(), 1);
CountingOutputCommitter v1OutputCommitter_1 = (CountingOutputCommitter) v1.getOutputCommitter("v1Out_1");
CountingOutputCommitter v1OutputCommitter_2 = (CountingOutputCommitter) v1.getOutputCommitter("v1Out_2");
Assert.assertEquals(1, v1OutputCommitter_1.initCounter);
Assert.assertEquals(1, v1OutputCommitter_1.setupCounter);
// commit may not have started, so can't verify commitCounter
Assert.assertEquals(1, v1OutputCommitter_1.abortCounter);
Assert.assertEquals(1, v1OutputCommitter_2.initCounter);
Assert.assertEquals(1, v1OutputCommitter_2.setupCounter);
// commit may not have started, so can't verify commitCounter
Assert.assertEquals(1, v1OutputCommitter_2.abortCounter);
}
use of org.apache.tez.dag.app.dag.event.DAGEventTerminateDag in project tez by apache.
the class TestCommit method _testCommitCanceled_OnDAGSuccess.
// test commit will be canceled no matter it is started or still in the threadpool
// ControlledThreadPoolExecutor is used for to not schedule the commits
private void _testCommitCanceled_OnDAGSuccess(DAGTerminationCause terminationCause) throws Exception {
conf.setBoolean(TezConfiguration.TEZ_AM_COMMIT_ALL_OUTPUTS_ON_DAG_SUCCESS, true);
setupDAG(createDAGPlan(true, true));
// create customized ThreadPoolExecutor to wait before schedule new task
rawExecutor = new ControlledThreadPoolExecutor(1);
execService = MoreExecutors.listeningDecorator(rawExecutor);
doReturn(execService).when(appContext).getExecService();
initDAG(dag);
startDAG(dag);
VertexImpl v1 = (VertexImpl) dag.getVertex("vertex1");
VertexImpl v2 = (VertexImpl) dag.getVertex("vertex2");
VertexImpl v3 = (VertexImpl) dag.getVertex("vertex3");
// need to make vertices to go to SUCCEEDED
v1.handle(new VertexEventTaskCompleted(v1.getTask(0).getTaskId(), TaskState.SUCCEEDED));
v2.handle(new VertexEventTaskCompleted(v2.getTask(0).getTaskId(), TaskState.SUCCEEDED));
v3.handle(new VertexEventTaskCompleted(v3.getTask(0).getTaskId(), TaskState.SUCCEEDED));
waitUntil(dag, DAGState.COMMITTING);
// mean the commits have been submitted to ThreadPool
Assert.assertEquals(2, dag.commitFutures.size());
dag.handle(new DAGEventTerminateDag(dag.getID(), terminationCause, null));
waitUntil(dag, terminationCause.getFinishedState());
Assert.assertEquals(terminationCause, dag.getTerminationCause());
// mean the commits have been canceled
Assert.assertTrue(dag.commitFutures.isEmpty());
historyEventHandler.verifyVertexGroupCommitStartedEvent("uv12", 0);
historyEventHandler.verifyVertexGroupCommitFinishedEvent("uv12", 0);
historyEventHandler.verifyVertexCommitStartedEvent(v1.getVertexId(), 0);
historyEventHandler.verifyVertexFinishedEvent(v1.getVertexId(), 1);
historyEventHandler.verifyVertexCommitStartedEvent(v2.getVertexId(), 0);
historyEventHandler.verifyVertexFinishedEvent(v2.getVertexId(), 1);
historyEventHandler.verifyVertexCommitStartedEvent(v3.getVertexId(), 0);
historyEventHandler.verifyVertexFinishedEvent(v3.getVertexId(), 1);
historyEventHandler.verifyDAGCommitStartedEvent(dag.getID(), 1);
historyEventHandler.verifyDAGFinishedEvent(dag.getID(), 1);
CountingOutputCommitter v12OutputCommitter = (CountingOutputCommitter) v1.getOutputCommitter("v12Out");
CountingOutputCommitter v3OutputCommitter = (CountingOutputCommitter) v3.getOutputCommitter("v3Out");
Assert.assertEquals(1, v12OutputCommitter.initCounter);
Assert.assertEquals(1, v12OutputCommitter.setupCounter);
// commit is not started because ControlledThreadPoolExecutor wait before schedule tasks
Assert.assertEquals(0, v12OutputCommitter.commitCounter);
Assert.assertEquals(1, v12OutputCommitter.abortCounter);
Assert.assertEquals(1, v3OutputCommitter.initCounter);
Assert.assertEquals(1, v3OutputCommitter.setupCounter);
// commit is not started because ControlledThreadPoolExecutor wait before schedule tasks
Assert.assertEquals(0, v3OutputCommitter.commitCounter);
Assert.assertEquals(1, v3OutputCommitter.abortCounter);
}
use of org.apache.tez.dag.app.dag.event.DAGEventTerminateDag in project tez by apache.
the class TestTaskSchedulerManager method testReportFailureFromTaskScheduler.
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testReportFailureFromTaskScheduler() {
String dagName = DAG_NAME;
Configuration conf = new TezConfiguration();
String taskSchedulerName = "testTaskScheduler";
String expIdentifier = "[0:" + taskSchedulerName + "]";
EventHandler eventHandler = mock(EventHandler.class);
AppContext appContext = mock(AppContext.class, RETURNS_DEEP_STUBS);
doReturn(taskSchedulerName).when(appContext).getTaskSchedulerName(0);
doReturn(eventHandler).when(appContext).getEventHandler();
doReturn(conf).when(appContext).getAMConf();
InetSocketAddress address = new InetSocketAddress("host", 55000);
DAGClientServer dagClientServer = mock(DAGClientServer.class);
doReturn(address).when(dagClientServer).getBindAddress();
DAG dag = mock(DAG.class);
TezDAGID dagId = TezDAGID.getInstance(ApplicationId.newInstance(1, 0), DAG_INDEX);
doReturn(dagName).when(dag).getName();
doReturn(dagId).when(dag).getID();
doReturn(dag).when(appContext).getCurrentDAG();
NamedEntityDescriptor<TaskSchedulerDescriptor> namedEntityDescriptor = new NamedEntityDescriptor<>(taskSchedulerName, TaskSchedulerForFailureTest.class.getName());
List<NamedEntityDescriptor> list = new LinkedList<>();
list.add(namedEntityDescriptor);
TaskSchedulerManager taskSchedulerManager = new TaskSchedulerManager(appContext, dagClientServer, eventHandler, mock(ContainerSignatureMatcher.class), mock(WebUIService.class), list, false, new HadoopShimsLoader(appContext.getAMConf()).getHadoopShim()) {
@Override
TaskSchedulerContext wrapTaskSchedulerContext(TaskSchedulerContext rawContext) {
// Avoid wrapping in threads
return rawContext;
}
};
try {
taskSchedulerManager.init(new TezConfiguration());
taskSchedulerManager.start();
taskSchedulerManager.getTotalResources(0);
ArgumentCaptor<Event> argumentCaptor = ArgumentCaptor.forClass(Event.class);
verify(eventHandler, times(1)).handle(argumentCaptor.capture());
Event rawEvent = argumentCaptor.getValue();
assertTrue(rawEvent instanceof DAGEventTerminateDag);
DAGEventTerminateDag killEvent = (DAGEventTerminateDag) rawEvent;
assertTrue(killEvent.getDiagnosticInfo().contains("ReportError"));
assertTrue(killEvent.getDiagnosticInfo().contains(ServicePluginErrorDefaults.SERVICE_UNAVAILABLE.name()));
assertTrue(killEvent.getDiagnosticInfo().contains(expIdentifier));
reset(eventHandler);
taskSchedulerManager.getAvailableResources(0);
argumentCaptor = ArgumentCaptor.forClass(Event.class);
verify(eventHandler, times(1)).handle(argumentCaptor.capture());
rawEvent = argumentCaptor.getValue();
assertTrue(rawEvent instanceof DAGAppMasterEventUserServiceFatalError);
DAGAppMasterEventUserServiceFatalError event = (DAGAppMasterEventUserServiceFatalError) rawEvent;
assertEquals(DAGAppMasterEventType.TASK_SCHEDULER_SERVICE_FATAL_ERROR, event.getType());
assertTrue(event.getDiagnosticInfo().contains("ReportedFatalError"));
assertTrue(event.getDiagnosticInfo().contains(ServicePluginErrorDefaults.INCONSISTENT_STATE.name()));
assertTrue(event.getDiagnosticInfo().contains(expIdentifier));
} finally {
taskSchedulerManager.stop();
}
}
use of org.apache.tez.dag.app.dag.event.DAGEventTerminateDag in project tez by apache.
the class TestDAGImpl method _testTerminateRunningDAG.
@SuppressWarnings("unchecked")
private void _testTerminateRunningDAG(DAGTerminationCause terminationCause) {
initDAG(dag);
startDAG(dag);
dispatcher.await();
TezVertexID vId1 = TezVertexID.getInstance(dagId, 1);
Vertex v1 = dag.getVertex(vId1);
((EventHandler<VertexEvent>) v1).handle(new VertexEventTaskCompleted(TezTaskID.getInstance(vId1, 0), TaskState.SUCCEEDED));
TezVertexID vId0 = TezVertexID.getInstance(dagId, 0);
Vertex v0 = dag.getVertex(vId0);
((EventHandler<VertexEvent>) v0).handle(new VertexEventTaskCompleted(TezTaskID.getInstance(vId0, 0), TaskState.SUCCEEDED));
dispatcher.await();
Assert.assertEquals(VertexState.SUCCEEDED, v0.getState());
Assert.assertEquals(VertexState.RUNNING, v1.getState());
dispatcher.getEventHandler().handle(new DAGEventTerminateDag(dagId, terminationCause, null));
dispatcher.await();
Assert.assertEquals(DAGState.TERMINATING, dag.getState());
Assert.assertEquals(VertexState.SUCCEEDED, v0.getState());
Assert.assertEquals(VertexState.TERMINATING, v1.getState());
for (int i = 2; i < 6; ++i) {
TezVertexID vId = TezVertexID.getInstance(dagId, i);
Vertex v = dag.getVertex(vId);
Assert.assertEquals(VertexState.KILLED, v.getState());
}
Assert.assertEquals(1, dag.getSuccessfulVertices());
}
Aggregations