use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class TestATSV15HistoryLoggingService method testDAGGroupingGroupingEnabled.
@Test(timeout = 2000)
public void testDAGGroupingGroupingEnabled() throws Exception {
int numDagsPerGroup = 100;
ATSV15HistoryLoggingService service = createService(numDagsPerGroup);
service.start();
TezDAGID dagId1 = TezDAGID.getInstance(appId, 1);
for (DAGHistoryEvent event : makeHistoryEvents(dagId1, service)) {
service.handle(event);
}
TezDAGID dagId2 = TezDAGID.getInstance(appId, numDagsPerGroup);
for (DAGHistoryEvent event : makeHistoryEvents(dagId2, service)) {
service.handle(event);
}
TezDAGID dagId3 = TezDAGID.getInstance(appId, numDagsPerGroup + 1);
for (DAGHistoryEvent event : makeHistoryEvents(dagId3, service)) {
service.handle(event);
}
while (!service.eventQueue.isEmpty()) {
Thread.sleep(100);
}
assertEquals(dagId1.getGroupId(numDagsPerGroup), dagId2.getGroupId(numDagsPerGroup));
assertNotEquals(dagId2.getGroupId(numDagsPerGroup), dagId3.getGroupId(numDagsPerGroup));
assertEquals(3, entityLog.size());
List<TimelineEntity> amEvents = entityLog.get(TimelineEntityGroupId.newInstance(appId, appId.toString()));
assertNotNull(amEvents);
assertEquals(3, amEvents.size());
List<TimelineEntity> nonGroupedDagEvents = entityLog.get(TimelineEntityGroupId.newInstance(appId, dagId1.toString()));
assertNull(nonGroupedDagEvents);
List<TimelineEntity> groupedDagEvents = entityLog.get(TimelineEntityGroupId.newInstance(appId, dagId1.getGroupId(numDagsPerGroup)));
assertNotNull(groupedDagEvents);
assertEquals(10, groupedDagEvents.size());
nonGroupedDagEvents = entityLog.get(TimelineEntityGroupId.newInstance(appId, dagId3.toString()));
assertNull(nonGroupedDagEvents);
groupedDagEvents = entityLog.get(TimelineEntityGroupId.newInstance(appId, dagId3.getGroupId(numDagsPerGroup)));
assertNotNull(groupedDagEvents);
assertEquals(5, groupedDagEvents.size());
service.stop();
}
use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class TestTaskExecution2 method createTaskRunner.
private TezTaskRunner2 createTaskRunner(ApplicationId appId, TaskExecutionTestHelpers.TezTaskUmbilicalForTest umbilical, TaskReporter taskReporter, ListeningExecutorService executor, String processorClass, byte[] processorConf, boolean testRunner, boolean updateSysCounters) throws IOException {
TezConfiguration tezConf = new TezConfiguration(defaultConf);
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
Path testDir = new Path(workDir, UUID.randomUUID().toString());
String[] localDirs = new String[] { testDir.toString() };
TezDAGID dagId = TezDAGID.getInstance(appId, 1);
TezVertexID vertexId = TezVertexID.getInstance(dagId, 1);
TezTaskID taskId = TezTaskID.getInstance(vertexId, 1);
TezTaskAttemptID taskAttemptId = TezTaskAttemptID.getInstance(taskId, 1);
ProcessorDescriptor processorDescriptor = ProcessorDescriptor.create(processorClass).setUserPayload(UserPayload.create(ByteBuffer.wrap(processorConf)));
TaskSpec taskSpec = new TaskSpec(taskAttemptId, "dagName", "vertexName", -1, processorDescriptor, new ArrayList<InputSpec>(), new ArrayList<OutputSpec>(), null, null);
TezExecutors sharedExecutor = new TezSharedExecutor(tezConf);
TezTaskRunner2 taskRunner;
if (testRunner) {
taskRunner = new TezTaskRunner2ForTest(tezConf, ugi, localDirs, taskSpec, 1, new HashMap<String, ByteBuffer>(), new HashMap<String, String>(), HashMultimap.<String, String>create(), taskReporter, executor, null, "", new ExecutionContextImpl("localhost"), Runtime.getRuntime().maxMemory(), updateSysCounters, sharedExecutor);
} else {
taskRunner = new TezTaskRunner2(tezConf, ugi, localDirs, taskSpec, 1, new HashMap<String, ByteBuffer>(), new HashMap<String, String>(), HashMultimap.<String, String>create(), taskReporter, executor, null, "", new ExecutionContextImpl("localhost"), Runtime.getRuntime().maxMemory(), updateSysCounters, new DefaultHadoopShim(), sharedExecutor);
}
return taskRunner;
}
use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class TestLogicalIOProcessorRuntimeTask method testAutoStart.
@Test(timeout = 5000)
public void testAutoStart() throws Exception {
TezDAGID dagId = createTezDagId();
TezVertexID vertexId = createTezVertexId(dagId);
Map<String, ByteBuffer> serviceConsumerMetadata = new HashMap<String, ByteBuffer>();
Multimap<String, String> startedInputsMap = HashMultimap.create();
TezUmbilical umbilical = mock(TezUmbilical.class);
TezConfiguration tezConf = new TezConfiguration();
tezConf.set(TezConfiguration.TEZ_TASK_SCALE_MEMORY_ALLOCATOR_CLASS, ScalingAllocator.class.getName());
TezTaskAttemptID taId1 = createTaskAttemptID(vertexId, 1);
TaskSpec task1 = createTaskSpec(taId1, "dag1", "vertex1", 30);
TezTaskAttemptID taId2 = createTaskAttemptID(vertexId, 2);
TaskSpec task2 = createTaskSpec(taId2, "dag2", "vertex1", 10);
TezSharedExecutor sharedExecutor = new TezSharedExecutor(tezConf);
LogicalIOProcessorRuntimeTask lio1 = new LogicalIOProcessorRuntimeTask(task1, 0, tezConf, null, umbilical, serviceConsumerMetadata, new HashMap<String, String>(), startedInputsMap, null, "", new ExecutionContextImpl("localhost"), Runtime.getRuntime().maxMemory(), true, new DefaultHadoopShim(), sharedExecutor);
try {
lio1.initialize();
lio1.run();
lio1.close();
// Input should've been started, Output should not have been started
assertEquals(1, TestProcessor.runCount);
assertEquals(1, TestInput.startCount);
assertEquals(0, TestOutput.startCount);
// test that invocations of progress are counted correctly
assertEquals(true, lio1.getAndClearProgressNotification());
// cleared after getting
assertEquals(false, lio1.getAndClearProgressNotification());
assertEquals(30, TestInput.vertexParallelism);
assertEquals(0, TestOutput.vertexParallelism);
assertEquals(30, lio1.getProcessorContext().getVertexParallelism());
assertEquals(30, lio1.getInputContexts().iterator().next().getVertexParallelism());
assertEquals(30, lio1.getOutputContexts().iterator().next().getVertexParallelism());
} catch (Exception e) {
fail();
sharedExecutor.shutdownNow();
} finally {
cleanupAndTest(lio1);
}
// local mode
tezConf.setBoolean(TezConfiguration.TEZ_LOCAL_MODE, true);
LogicalIOProcessorRuntimeTask lio2 = new LogicalIOProcessorRuntimeTask(task2, 0, tezConf, null, umbilical, serviceConsumerMetadata, new HashMap<String, String>(), startedInputsMap, null, "", new ExecutionContextImpl("localhost"), Runtime.getRuntime().maxMemory(), true, new DefaultHadoopShim(), sharedExecutor);
try {
lio2.initialize();
lio2.run();
lio2.close();
// Input should not have been started again, Output should not have been started
assertEquals(2, TestProcessor.runCount);
assertEquals(1, TestInput.startCount);
assertEquals(0, TestOutput.startCount);
assertEquals(30, TestInput.vertexParallelism);
assertEquals(0, TestOutput.vertexParallelism);
// Check if parallelism is available in processor/ i/p / o/p contexts
assertEquals(10, lio2.getProcessorContext().getVertexParallelism());
assertEquals(10, lio2.getInputContexts().iterator().next().getVertexParallelism());
assertEquals(10, lio2.getOutputContexts().iterator().next().getVertexParallelism());
} catch (Exception e) {
fail();
} finally {
cleanupAndTest(lio2);
sharedExecutor.shutdownNow();
}
}
use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class TestDAGClientHandler method testDAGClientHandler.
@Test(timeout = 5000)
public void testDAGClientHandler() throws TezException {
TezDAGID mockTezDAGId = mock(TezDAGID.class);
when(mockTezDAGId.getId()).thenReturn(1);
when(mockTezDAGId.toString()).thenReturn("dag_9999_0001_1");
DAG mockDAG = mock(DAG.class);
when(mockDAG.getID()).thenReturn(mockTezDAGId);
DAGStatusBuilder mockDagStatusBuilder = mock(DAGStatusBuilder.class);
when(mockDAG.getDAGStatus(anySetOf(StatusGetOpts.class))).thenReturn(mockDagStatusBuilder);
VertexStatusBuilder mockVertexStatusBuilder = mock(VertexStatusBuilder.class);
when(mockDAG.getVertexStatus(anyString(), anySetOf(StatusGetOpts.class))).thenReturn(mockVertexStatusBuilder);
DAGAppMaster mockDagAM = mock(DAGAppMaster.class);
when(mockDagAM.getState()).thenReturn(DAGAppMasterState.RUNNING);
AppContext mockAppContext = mock(AppContext.class);
when(mockDagAM.getContext()).thenReturn(mockAppContext);
when(mockDagAM.getContext().getCurrentDAG()).thenReturn(mockDAG);
when(mockAppContext.getClock()).thenReturn(new SystemClock());
DAGClientHandler dagClientHandler = new DAGClientHandler(mockDagAM);
// getAllDAGs()
assertEquals(1, dagClientHandler.getAllDAGs().size());
assertEquals("dag_9999_0001_1", dagClientHandler.getAllDAGs().get(0));
// getDAGStatus
try {
dagClientHandler.getDAGStatus("dag_9999_0001_2", Sets.newSet(StatusGetOpts.GET_COUNTERS));
fail("should not come here");
} catch (TezException e) {
assertTrue(e.getMessage().contains("Unknown dagId"));
}
DAGStatus dagStatus = dagClientHandler.getDAGStatus("dag_9999_0001_1", Sets.newSet(StatusGetOpts.GET_COUNTERS));
assertEquals(mockDagStatusBuilder, dagStatus);
// getVertexStatus
try {
dagClientHandler.getVertexStatus("dag_9999_0001_2", "v1", Sets.newSet(StatusGetOpts.GET_COUNTERS));
fail("should not come here");
} catch (TezException e) {
assertTrue(e.getMessage().contains("Unknown dagId"));
}
VertexStatus vertexStatus = dagClientHandler.getVertexStatus("dag_9999_0001_1", "v1", Sets.newSet(StatusGetOpts.GET_COUNTERS));
assertEquals(mockVertexStatusBuilder, vertexStatus);
// getTezAppMasterStatus
when(mockDagAM.isSession()).thenReturn(false);
assertEquals(TezAppMasterStatus.RUNNING, dagClientHandler.getTezAppMasterStatus());
when(mockDagAM.isSession()).thenReturn(true);
when(mockDagAM.getState()).thenReturn(DAGAppMasterState.INITED);
assertEquals(TezAppMasterStatus.INITIALIZING, dagClientHandler.getTezAppMasterStatus());
when(mockDagAM.getState()).thenReturn(DAGAppMasterState.ERROR);
assertEquals(TezAppMasterStatus.SHUTDOWN, dagClientHandler.getTezAppMasterStatus());
// tryKillDAG
try {
dagClientHandler.tryKillDAG("dag_9999_0001_2");
fail("should not come here");
} catch (TezException e) {
assertTrue(e.getMessage().contains("Unknown dagId"));
}
dagClientHandler.tryKillDAG("dag_9999_0001_1");
ArgumentCaptor<DAG> eventCaptor = ArgumentCaptor.forClass(DAG.class);
verify(mockDagAM, times(1)).tryKillDAG(eventCaptor.capture(), contains("Sending client kill from"));
assertEquals(1, eventCaptor.getAllValues().size());
assertTrue(eventCaptor.getAllValues().get(0) instanceof DAG);
assertEquals("dag_9999_0001_1", ((DAG) eventCaptor.getAllValues().get(0)).getID().toString());
// submitDAG
DAGPlan dagPlan = DAGPlan.getDefaultInstance();
Map<String, LocalResource> localResources = new HashMap<String, LocalResource>();
dagClientHandler.submitDAG(dagPlan, localResources);
verify(mockDagAM).submitDAGToAppMaster(dagPlan, localResources);
// shutdown
dagClientHandler.shutdownAM();
verify(mockDagAM).shutdownTezAM(contains("Received message to shutdown AM from"));
}
use of org.apache.tez.dag.records.TezDAGID in project tez by apache.
the class AMWebController method getVerticesByIdx.
Collection<Vertex> getVerticesByIdx(DAG dag, Collection<Integer> indexes) {
Collection<Vertex> vertices = new ArrayList<Vertex>(indexes.size());
final TezDAGID tezDAGID = dag.getID();
for (Integer idx : indexes) {
final TezVertexID tezVertexID = TezVertexID.getInstance(tezDAGID, idx);
if (tezVertexID == null) {
continue;
}
final Vertex vertex = dag.getVertex(tezVertexID);
if (vertex != null) {
vertices.add(vertex);
}
}
return vertices;
}
Aggregations