use of org.apache.tez.dag.history.events.DAGSubmittedEvent in project tez by apache.
the class TestATSV15HistoryLoggingService method makeHistoryEvents.
private List<DAGHistoryEvent> makeHistoryEvents(TezDAGID dagId, ATSV15HistoryLoggingService service) {
List<DAGHistoryEvent> historyEvents = new ArrayList<>();
long time = System.currentTimeMillis();
Configuration conf = new Configuration(service.getConfig());
historyEvents.add(new DAGHistoryEvent(null, new AMStartedEvent(attemptId, time, user)));
historyEvents.add(new DAGHistoryEvent(dagId, new DAGSubmittedEvent(dagId, time, DAGPlan.getDefaultInstance(), attemptId, null, user, conf, null, "default")));
TezVertexID vertexID = TezVertexID.getInstance(dagId, 1);
historyEvents.add(new DAGHistoryEvent(dagId, new VertexStartedEvent(vertexID, time, time)));
TezTaskID tezTaskID = TezTaskID.getInstance(vertexID, 1);
historyEvents.add(new DAGHistoryEvent(dagId, new TaskStartedEvent(tezTaskID, "test", time, time)));
historyEvents.add(new DAGHistoryEvent(dagId, new TaskAttemptStartedEvent(TezTaskAttemptID.getInstance(tezTaskID, 1), "test", time, ContainerId.newContainerId(attemptId, 1), NodeId.newInstance("localhost", 8765), null, null, null)));
return historyEvents;
}
use of org.apache.tez.dag.history.events.DAGSubmittedEvent in project tez by apache.
the class HistoryEventHandler method shouldLogEvent.
private boolean shouldLogEvent(DAGHistoryEvent event) {
TezDAGID dagId = event.getDagID();
HistoryLogLevel dagLogLevel = null;
if (dagId != null) {
dagLogLevel = dagIdToLogLevel.get(dagId);
}
if (dagLogLevel == null) {
dagLogLevel = amHistoryLogLevel;
}
HistoryEvent historyEvent = event.getHistoryEvent();
HistoryEventType eventType = historyEvent.getEventType();
if (eventType == HistoryEventType.DAG_SUBMITTED) {
Configuration dagConf = ((DAGSubmittedEvent) historyEvent).getConf();
dagLogLevel = HistoryLogLevel.getLogLevel(dagConf, amHistoryLogLevel);
dagIdToLogLevel.put(dagId, dagLogLevel);
maybeUpdateDagTaskAttemptFilters(dagId, dagLogLevel, dagConf);
} else if (eventType == HistoryEventType.DAG_RECOVERED) {
if (context.getCurrentDAG() != null) {
Configuration dagConf = context.getCurrentDAG().getConf();
dagLogLevel = HistoryLogLevel.getLogLevel(dagConf, amHistoryLogLevel);
dagIdToLogLevel.put(dagId, dagLogLevel);
maybeUpdateDagTaskAttemptFilters(dagId, dagLogLevel, dagConf);
}
} else if (eventType == HistoryEventType.DAG_FINISHED) {
dagIdToLogLevel.remove(dagId);
dagIdToTaskAttemptFilters.remove(dagId);
suppressedEvents.clear();
}
if (dagLogLevel.shouldLog(historyEvent.getEventType().getHistoryLogLevel())) {
return shouldLogTaskAttemptEvents(event, dagLogLevel);
}
return false;
}
use of org.apache.tez.dag.history.events.DAGSubmittedEvent in project tez by apache.
the class TestHistoryEventHandler method makeHistoryEvents.
private List<DAGHistoryEvent> makeHistoryEvents(TezDAGID dagId, Configuration inConf) {
List<DAGHistoryEvent> historyEvents = new ArrayList<>();
long time = System.currentTimeMillis();
Configuration conf = new Configuration(inConf);
historyEvents.add(new DAGHistoryEvent(null, new AMStartedEvent(attemptId, time, user)));
historyEvents.add(new DAGHistoryEvent(dagId, new DAGSubmittedEvent(dagId, time, DAGPlan.getDefaultInstance(), attemptId, null, user, conf, null, "default")));
TezVertexID vertexID = TezVertexID.getInstance(dagId, 1);
historyEvents.add(new DAGHistoryEvent(dagId, new VertexStartedEvent(vertexID, time, time)));
ContainerId containerId = ContainerId.newContainerId(attemptId, dagId.getId());
TezTaskID tezTaskID = TezTaskID.getInstance(vertexID, 1);
historyEvents.add(new DAGHistoryEvent(dagId, new TaskStartedEvent(tezTaskID, "test", time, time)));
historyEvents.add(new DAGHistoryEvent(new ContainerLaunchedEvent(containerId, time, attemptId)));
historyEvents.add(new DAGHistoryEvent(dagId, new TaskAttemptStartedEvent(TezTaskAttemptID.getInstance(tezTaskID, 1), "test", time, containerId, NodeId.newInstance("localhost", 8765), null, null, null)));
historyEvents.add(new DAGHistoryEvent(dagId, new TaskAttemptFinishedEvent(TezTaskAttemptID.getInstance(tezTaskID, 1), "test", time, time + 1, TaskAttemptState.KILLED, null, TaskAttemptTerminationCause.EXTERNAL_PREEMPTION, "", null, null, null, time, null, time, containerId, NodeId.newInstance("localhost", 8765), null, null, null)));
historyEvents.add(new DAGHistoryEvent(dagId, new TaskAttemptStartedEvent(TezTaskAttemptID.getInstance(tezTaskID, 2), "test", time, containerId, NodeId.newInstance("localhost", 8765), null, null, null)));
historyEvents.add(new DAGHistoryEvent(dagId, new TaskAttemptFinishedEvent(TezTaskAttemptID.getInstance(tezTaskID, 2), "test", time + 2, time + 3, TaskAttemptState.KILLED, null, TaskAttemptTerminationCause.INTERRUPTED_BY_USER, "", null, null, null, time, null, time + 2, containerId, NodeId.newInstance("localhost", 8765), null, null, null)));
historyEvents.add(new DAGHistoryEvent(dagId, new DAGFinishedEvent(dagId, time, time, DAGState.SUCCEEDED, null, null, user, "test", null, attemptId, DAGPlan.getDefaultInstance())));
historyEvents.add(new DAGHistoryEvent(new ContainerStoppedEvent(containerId, time + 4, 0, attemptId)));
return historyEvents;
}
use of org.apache.tez.dag.history.events.DAGSubmittedEvent in project tez by apache.
the class TestRecoveryService method testRecoveryFlushOnSummaryEvent.
@Test(timeout = 5000)
public void testRecoveryFlushOnSummaryEvent() throws Exception {
setup(true, new String[][] { { TezConfiguration.DAG_RECOVERY_MAX_UNFLUSHED_EVENTS, "-1" }, { TezConfiguration.DAG_RECOVERY_FLUSH_INTERVAL_SECS, "-1" } });
recoveryService.start();
DAGPlan dagPlan = DAGPlan.newBuilder().setName("test_dag").build();
// This writes to recovery immediately.
recoveryService.handle(new DAGHistoryEvent(dagId, new DAGSubmittedEvent(dagId, startTime, dagPlan, appAttemptId, null, "nobody", conf, null, "default")));
waitForDrain(-1);
verify(summaryFos, times(1)).hflush();
verify(dagFos, times(1)).hflush();
// This does not write to recovery immediately.
recoveryService.handle(new DAGHistoryEvent(dagId, new DAGCommitStartedEvent(dagId, startTime)));
waitForDrain(-1);
verify(summaryFos, times(2)).hflush();
verify(dagFos, times(1)).hflush();
// Does flush on stop.
recoveryService.stop();
verify(dagFos, times(2)).hflush();
}
use of org.apache.tez.dag.history.events.DAGSubmittedEvent in project tez by apache.
the class TestRecoveryParser method testRecoverableSummary_VertexGroupFinishCommitting.
@Test(timeout = 5000)
public void testRecoverableSummary_VertexGroupFinishCommitting() throws IOException {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagID = TezDAGID.getInstance(appId, 1);
AppContext appContext = mock(AppContext.class);
when(appContext.getCurrentRecoveryDir()).thenReturn(new Path(recoveryPath + "/1"));
when(appContext.getClock()).thenReturn(new SystemClock());
when(mockDAGImpl.getID()).thenReturn(dagID);
when(appContext.getHadoopShim()).thenReturn(new DefaultHadoopShim());
when(appContext.getApplicationID()).thenReturn(appId);
RecoveryService rService = new RecoveryService(appContext);
Configuration conf = new Configuration();
conf.setBoolean(RecoveryService.TEZ_TEST_RECOVERY_DRAIN_EVENTS_WHEN_STOPPED, true);
rService.init(conf);
rService.start();
DAGPlan dagPlan = TestDAGImpl.createTestDAGPlan();
// write a DAGSubmittedEvent first to initialize summaryStream
rService.handle(new DAGHistoryEvent(dagID, new DAGSubmittedEvent(dagID, 1L, dagPlan, ApplicationAttemptId.newInstance(appId, 1), null, "user", new Configuration(), null, null)));
// It should be fine to skip other events, just for testing.
TezVertexID v0 = TezVertexID.getInstance(dagID, 0);
TezVertexID v1 = TezVertexID.getInstance(dagID, 1);
rService.handle(new DAGHistoryEvent(dagID, new VertexGroupCommitStartedEvent(dagID, "group_1", Lists.newArrayList(v0, v1), 0L)));
rService.handle(new DAGHistoryEvent(dagID, new VertexGroupCommitFinishedEvent(dagID, "group_1", Lists.newArrayList(v0, v1), 0L)));
// also write VertexFinishedEvent, otherwise it is still non-recoverable
// when checking with non-summary event
rService.handle(new DAGHistoryEvent(dagID, new VertexFinishedEvent(v0, "v1", 10, 0L, 0L, 0L, 0L, 0L, VertexState.SUCCEEDED, "", null, null, null, null)));
rService.handle(new DAGHistoryEvent(dagID, new VertexFinishedEvent(v1, "v1", 10, 0L, 0L, 0L, 0L, 0L, VertexState.SUCCEEDED, "", null, null, null, null)));
rService.stop();
DAGRecoveryData dagData = parser.parseRecoveryData();
assertEquals(dagID, dagData.recoveredDagID);
assertFalse(dagData.nonRecoverable);
}
Aggregations