use of org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted in project tez by apache.
the class TestVertexImpl method completeAllTasksSuccessfully.
private void completeAllTasksSuccessfully(Vertex v) {
Assert.assertEquals(VertexState.RUNNING, v.getState());
Set<TezTaskID> tasks = v.getTasks().keySet();
Assert.assertFalse(tasks.isEmpty());
for (TezTaskID task : tasks) {
dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(task, TaskState.SUCCEEDED));
}
dispatcher.await();
}
use of org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted in project tez by apache.
the class TestVertexImpl method testCounterLimits.
@Test(timeout = 5000)
public void testCounterLimits() {
initAllVertices(VertexState.INITED);
VertexImpl v = vertices.get("vertex2");
startVertex(v);
TezTaskID t1 = TezTaskID.getInstance(v.getVertexId(), 0);
TezTaskID t2 = TezTaskID.getInstance(v.getVertexId(), 1);
for (int i = 0; i < 2; ++i) {
TezCounters ctrs = new TezCounters();
for (int j = 0; j < 75; ++j) {
ctrs.findCounter("g", "c" + i + "_" + j).increment(1);
}
Task t = v.getTask(i);
((TaskImpl) t).setCounters(ctrs);
}
dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(t1, TaskState.SUCCEEDED));
dispatcher.await();
Assert.assertEquals(VertexState.RUNNING, v.getState());
Assert.assertEquals(1, v.getCompletedTasks());
Assert.assertTrue((0.5f) == v.getCompletedTaskProgress());
dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(t2, TaskState.SUCCEEDED));
dispatcher.await();
Assert.assertEquals(VertexState.FAILED, v.getState());
Assert.assertEquals(2, v.getCompletedTasks());
System.out.println(v.getDiagnostics());
Assert.assertTrue("Diagnostics should contain counter limits error message", StringUtils.join(v.getDiagnostics(), ",").contains("Counters limit exceeded"));
}
use of org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted in project tez by apache.
the class TestVertexImpl method testInputInitializerEvents.
@Test(timeout = 10000)
public void testInputInitializerEvents() throws Exception {
useCustomInitializer = true;
customInitializer = new EventHandlingRootInputInitializer(null);
EventHandlingRootInputInitializer initializer = (EventHandlingRootInputInitializer) customInitializer;
setupPreDagCreation();
dagPlan = createDAGPlanWithRunningInitializer();
setupPostDagCreation();
VertexImplWithRunningInputInitializer v1 = (VertexImplWithRunningInputInitializer) vertices.get("vertex1");
VertexImplWithRunningInputInitializer v2 = (VertexImplWithRunningInputInitializer) vertices.get("vertex2");
initVertex(v1);
startVertex(v1);
Assert.assertEquals(VertexState.RUNNING, v1.getState());
Assert.assertEquals(VertexState.INITIALIZING, v2.getState());
dispatcher.await();
// Wait for the initializer to be invoked - which may be a separate thread.
while (!initializer.initStarted.get()) {
Thread.sleep(10);
}
Assert.assertFalse(initializer.eventReceived.get());
Assert.assertFalse(initializer.initComplete.get());
// Signal the initializer by sending an event - via vertex1
InputInitializerEvent event = InputInitializerEvent.create("vertex2", "input1", null);
// Create taskId and taskAttemptId for the single task that exists in vertex1
TezTaskID t0_v1 = TezTaskID.getInstance(v1.getVertexId(), 0);
TezTaskAttemptID ta0_t0_v1 = TezTaskAttemptID.getInstance(t0_v1, 0);
TezEvent tezEvent = new TezEvent(event, new EventMetaData(EventProducerConsumerType.OUTPUT, "vertex1", "vertex2", ta0_t0_v1));
dispatcher.getEventHandler().handle(new VertexEventRouteEvent(v1.getVertexId(), Collections.singletonList(tezEvent)));
dispatcher.await();
// Events should not be cached in the vertex, since the initializer is running
Assert.assertEquals(0, v2.pendingInitializerEvents.size());
// Verify that events are cached
RootInputInitializerManager.InitializerWrapper initializerWrapper = v2.rootInputInitializerManager.getInitializerWrapper("input1");
Assert.assertEquals(1, initializerWrapper.getFirstSuccessfulAttemptMap().size());
Assert.assertEquals(1, initializerWrapper.getPendingEvents().get(v1.getName()).size());
for (TezTaskID taskId : v1.getTasks().keySet()) {
TezTaskAttemptID taskAttemptId = TezTaskAttemptID.getInstance(taskId, 0);
v1.handle(new VertexEventTaskAttemptCompleted(taskAttemptId, TaskAttemptStateInternal.SUCCEEDED));
v1.handle(new VertexEventTaskCompleted(taskId, TaskState.SUCCEEDED));
dispatcher.await();
v1.stateChangeNotifier.taskSucceeded(v1.getName(), taskId, taskAttemptId.getId());
}
// Both happening in separate threads
while (!initializer.eventReceived.get()) {
Thread.sleep(10);
}
while (!initializer.initComplete.get()) {
Thread.sleep(10);
}
// Will eventually go into RUNNING state, via INITED
while (v2.getState() != VertexState.RUNNING) {
Thread.sleep(10);
}
// Verify the events are no longer cached, but attempts are remembered
Assert.assertEquals(1, initializerWrapper.getFirstSuccessfulAttemptMap().size());
Assert.assertEquals(0, initializerWrapper.getPendingEvents().get(v1.getName()).size());
}
use of org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted in project tez by apache.
the class TestVertexImpl method testInputInitializerEventsAtNew.
@Test(timeout = 10000)
public void testInputInitializerEventsAtNew() throws Exception {
useCustomInitializer = true;
customInitializer = new EventHandlingRootInputInitializer(null);
EventHandlingRootInputInitializer initializer = (EventHandlingRootInputInitializer) customInitializer;
setupPreDagCreation();
dagPlan = createDAGPlanWithRunningInitializer3();
setupPostDagCreation();
VertexImplWithRunningInputInitializer v1 = (VertexImplWithRunningInputInitializer) vertices.get("vertex1");
VertexImplWithRunningInputInitializer v2 = (VertexImplWithRunningInputInitializer) vertices.get("vertex2");
VertexImplWithRunningInputInitializer v3 = (VertexImplWithRunningInputInitializer) vertices.get("vertex3");
initVertex(v1);
startVertex(v1);
dispatcher.await();
// Vertex2 has not been INITED, so the rest of the vertices should be in state NEW.
Assert.assertEquals(VertexState.RUNNING, v1.getState());
Assert.assertEquals(VertexState.NEW, v2.getState());
Assert.assertEquals(VertexState.NEW, v3.getState());
// Genrate events from v1 to v3's InputInitializer
InputInitializerEvent event = InputInitializerEvent.create("vertex3", "input1", null);
// Create taskId and taskAttemptId for the single task that exists in vertex1
TezTaskID t0_v1 = TezTaskID.getInstance(v1.getVertexId(), 0);
TezTaskAttemptID ta0_t0_v1 = TezTaskAttemptID.getInstance(t0_v1, 0);
TezEvent tezEvent = new TezEvent(event, new EventMetaData(EventProducerConsumerType.OUTPUT, "vertex1", "vertex3", ta0_t0_v1));
dispatcher.getEventHandler().handle(new VertexEventRouteEvent(v1.getVertexId(), Collections.singletonList(tezEvent)));
dispatcher.await();
// Events should be cached in the vertex, since the Initializer has not started
Assert.assertEquals(1, v3.pendingInitializerEvents.size());
// Get Vertex1 to succeed before Vertex2 is INITED. Contrived case ? This is likely a tiny race.
for (TezTaskID taskId : v1.getTasks().keySet()) {
TezTaskAttemptID taskAttemptId = TezTaskAttemptID.getInstance(taskId, 0);
TaskImpl task = (TaskImpl) v1.getTask(taskId);
task.handle(new TaskEvent(taskId, TaskEventType.T_ATTEMPT_LAUNCHED));
task.handle(new TaskEventTASucceeded(taskAttemptId));
v1.handle(new VertexEventTaskAttemptCompleted(taskAttemptId, TaskAttemptStateInternal.SUCCEEDED));
v1.handle(new VertexEventTaskCompleted(taskId, TaskState.SUCCEEDED));
dispatcher.await();
v1.stateChangeNotifier.taskSucceeded(v1.getName(), taskId, taskAttemptId.getId());
}
dispatcher.await();
// Events should still be cached in the vertex
Assert.assertEquals(1, v3.pendingInitializerEvents.size());
Assert.assertEquals(VertexState.NEW, v3.getState());
// Move processing along. INIT the remaining root level vertex.
initVertex(v2);
startVertex(v2);
dispatcher.await();
// Initializer would have run, and processed events.
while (v3.getState() != VertexState.RUNNING) {
Thread.sleep(10);
}
Assert.assertEquals(VertexState.RUNNING, v3.getState());
// Events should have been cleared from the vertex.
Assert.assertEquals(0, v3.pendingInitializerEvents.size());
// KK Add checks to validate thte RootInputManager doesn't remember the events either
Assert.assertTrue(initializer.eventReceived.get());
Assert.assertEquals(3, initializer.stateUpdates.size());
Assert.assertEquals(org.apache.tez.dag.api.event.VertexState.CONFIGURED, initializer.stateUpdates.get(0).getVertexState());
Assert.assertEquals(org.apache.tez.dag.api.event.VertexState.RUNNING, initializer.stateUpdates.get(1).getVertexState());
Assert.assertEquals(org.apache.tez.dag.api.event.VertexState.SUCCEEDED, initializer.stateUpdates.get(2).getVertexState());
}
use of org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted in project tez by apache.
the class TestVertexImpl method testBadCommitter2.
@Test(timeout = 5000)
public void testBadCommitter2() throws Exception {
VertexImpl v = vertices.get("vertex2");
List<RootInputLeafOutputProto> outputs = new ArrayList<RootInputLeafOutputProto>();
outputs.add(RootInputLeafOutputProto.newBuilder().setControllerDescriptor(TezEntityDescriptorProto.newBuilder().setClassName(CountingOutputCommitter.class.getName()).setTezUserPayload(DAGProtos.TezUserPayloadProto.newBuilder().setUserPayload(ByteString.copyFrom(new CountingOutputCommitter.CountingOutputCommitterConfig(true, true, true).toUserPayload())).build())).setName("output_v2").setIODescriptor(TezEntityDescriptorProto.newBuilder().setClassName("output.class")).build());
v.setAdditionalOutputs(outputs);
initAllVertices(VertexState.INITED);
startVertex(v);
CountingOutputCommitter committer = (CountingOutputCommitter) v.getOutputCommitter("output_v2");
TezTaskID t1 = TezTaskID.getInstance(v.getVertexId(), 0);
TezTaskID t2 = TezTaskID.getInstance(v.getVertexId(), 1);
dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(t1, TaskState.SUCCEEDED));
dispatcher.getEventHandler().handle(new VertexEventTaskCompleted(t2, TaskState.SUCCEEDED));
dispatcher.await();
Assert.assertEquals(VertexState.FAILED, v.getState());
Assert.assertEquals(VertexTerminationCause.COMMIT_FAILURE, v.getTerminationCause());
Assert.assertEquals(1, committer.commitCounter);
Assert.assertEquals(1, committer.abortCounter);
Assert.assertEquals(1, committer.initCounter);
Assert.assertEquals(1, committer.setupCounter);
}
Aggregations