use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.
the class TestDAGImpl method testEdgeManager_RouteDataMovementEventToDestination.
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testEdgeManager_RouteDataMovementEventToDestination() {
setupDAGWithCustomEdge(ExceptionLocation.RouteDataMovementEventToDestination);
dispatcher.getEventHandler().handle(new DAGEvent(dagWithCustomEdge.getID(), DAGEventType.DAG_INIT));
dispatcher.getEventHandler().handle(new DAGEventStartDag(dagWithCustomEdge.getID(), null));
dispatcher.await();
Assert.assertEquals(DAGState.RUNNING, dagWithCustomEdge.getState());
VertexImpl v1 = (VertexImpl) dagWithCustomEdge.getVertex("vertex1");
VertexImpl v2 = (VertexImpl) dagWithCustomEdge.getVertex("vertex2");
dispatcher.await();
Task t1 = v2.getTask(0);
TaskAttemptImpl ta1 = (TaskAttemptImpl) t1.getAttempt(TezTaskAttemptID.getInstance(t1.getTaskId(), 0));
DataMovementEvent daEvent = DataMovementEvent.create(ByteBuffer.wrap(new byte[0]));
TezEvent tezEvent = new TezEvent(daEvent, new EventMetaData(EventProducerConsumerType.INPUT, "vertex1", "vertex2", ta1.getID()));
dispatcher.getEventHandler().handle(new VertexEventRouteEvent(v2.getVertexId(), Lists.newArrayList(tezEvent)));
dispatcher.await();
v2.getTaskAttemptTezEvents(ta1.getID(), 0, 0, 1000);
dispatcher.await();
Assert.assertEquals(VertexState.FAILED, v2.getState());
Assert.assertEquals(VertexState.KILLED, v1.getState());
String diag = StringUtils.join(v2.getDiagnostics(), ",");
Assert.assertTrue(diag.contains(ExceptionLocation.RouteDataMovementEventToDestination.name()));
}
use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.
the class TaskImpl method internalErrorUncaughtException.
protected void internalErrorUncaughtException(TaskEventType type, Exception e) {
eventHandler.handle(new DAGEventDiagnosticsUpdate(this.taskId.getVertexID().getDAGId(), "Uncaught exception when handling event " + type + " on Task " + this.taskId + ", error=" + e.getMessage()));
eventHandler.handle(new DAGEvent(this.taskId.getVertexID().getDAGId(), DAGEventType.INTERNAL_ERROR));
}
use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.
the class TaskImpl method internalError.
protected void internalError(TaskEventType type) {
LOG.error("Invalid event " + type + " on Task " + this.taskId + " in state:" + getInternalState());
eventHandler.handle(new DAGEventDiagnosticsUpdate(this.taskId.getVertexID().getDAGId(), "Invalid event " + type + " on Task " + this.taskId));
eventHandler.handle(new DAGEvent(this.taskId.getVertexID().getDAGId(), DAGEventType.INTERNAL_ERROR));
}
use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.
the class VertexImpl method finished.
VertexState finished(VertexState finalState, VertexTerminationCause termCause, String diag) {
if (finishTime == 0)
setFinishTime();
if (termCause != null) {
trySetTerminationCause(termCause);
}
if (rootInputInitializerManager != null) {
rootInputInitializerManager.shutdown();
rootInputInitializerManager = null;
}
switch(finalState) {
case ERROR:
addDiagnostic("Vertex: " + logIdentifier + " error due to:" + terminationCause);
if (!StringUtils.isEmpty(diag)) {
addDiagnostic(diag);
}
abortVertex(VertexStatus.State.valueOf(finalState.name()));
eventHandler.handle(new DAGEvent(getDAGId(), DAGEventType.INTERNAL_ERROR));
try {
logJobHistoryVertexFailedEvent(finalState);
} catch (IOException e) {
LOG.error("Failed to send vertex finished event to recovery", e);
}
break;
case KILLED:
case FAILED:
addDiagnostic("Vertex " + logIdentifier + " killed/failed due to:" + terminationCause);
if (!StringUtils.isEmpty(diag)) {
addDiagnostic(diag);
}
abortVertex(VertexStatus.State.valueOf(finalState.name()));
eventHandler.handle(new DAGEventVertexCompleted(getVertexId(), finalState, terminationCause));
try {
logJobHistoryVertexFailedEvent(finalState);
} catch (IOException e) {
LOG.error("Failed to send vertex finished event to recovery", e);
}
break;
case SUCCEEDED:
try {
try {
logJobHistoryVertexFinishedEvent();
eventHandler.handle(new DAGEventVertexCompleted(getVertexId(), finalState));
} catch (LimitExceededException e) {
LOG.error("Counter limits exceeded for vertex: " + getLogIdentifier(), e);
finalState = VertexState.FAILED;
addDiagnostic("Counters limit exceeded: " + e.getMessage());
trySetTerminationCause(VertexTerminationCause.COUNTER_LIMITS_EXCEEDED);
logJobHistoryVertexFailedEvent(finalState);
eventHandler.handle(new DAGEventVertexCompleted(getVertexId(), finalState));
}
} catch (IOException e) {
LOG.error("Failed to send vertex finished event to recovery", e);
finalState = VertexState.FAILED;
trySetTerminationCause(VertexTerminationCause.INTERNAL_ERROR);
eventHandler.handle(new DAGEventVertexCompleted(getVertexId(), finalState));
}
break;
default:
throw new TezUncheckedException("Unexpected VertexState: " + finalState);
}
return finalState;
}
use of org.apache.tez.dag.app.dag.event.DAGEvent in project tez by apache.
the class DAGAppMaster method startDAGExecution.
private void startDAGExecution(DAG dag, final Map<String, LocalResource> additionalAmResources) throws TezException {
currentDAG = dag;
// Try localizing the actual resources.
List<URL> additionalUrlsForClasspath;
try {
additionalUrlsForClasspath = dag.getDagUGI().doAs(new PrivilegedExceptionAction<List<URL>>() {
@Override
public List<URL> run() throws Exception {
return processAdditionalResources(currentDAG.getID(), additionalAmResources);
}
});
} catch (IOException e) {
throw new TezException(e);
} catch (InterruptedException e) {
throw new TezException(e);
}
dagIDs.add(currentDAG.getID().toString());
// End of creating the job.
((RunningAppContext) context).setDAG(currentDAG);
// Send out an event to inform components that a new DAG has been submitted.
// Information about this DAG is available via the context.
sendEvent(new DAGAppMasterEvent(DAGAppMasterEventType.NEW_DAG_SUBMITTED));
// create a job event for job initialization
DAGEvent initDagEvent = new DAGEvent(currentDAG.getID(), DAGEventType.DAG_INIT);
// Send init to the job (this does NOT trigger job execution)
// This is a synchronous call, not an event through dispatcher. We want
// job-init to be done completely here.
dagEventDispatcher.handle(initDagEvent);
// All components have started, start the job.
/**
* create a job-start event to get this ball rolling
*/
DAGEvent startDagEvent = new DAGEventStartDag(currentDAG.getID(), additionalUrlsForClasspath);
/**
* send the job-start event. this triggers the job execution.
*/
sendEvent(startDagEvent);
}
Aggregations