use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestAMRecovery method testVertexPartiallyFinished_Broadcast.
/**
* Fine-grained recovery task-level, In a vertex (v1), task 0 is done task 1
* is not started. History flush happens. AM dies. Once AM is recovered, task 0 is
* not re-run. Task 1 is re-run. (Broadcast)
*
* @throws Exception
*/
@Test(timeout = 120000)
public void testVertexPartiallyFinished_Broadcast() throws Exception {
DAG dag = createDAG("VertexPartiallyFinished_Broadcast", ControlledImmediateStartVertexManager.class, DataMovementType.BROADCAST, true);
TezCounters counters = runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
assertEquals(4, counters.findCounter(DAGCounter.NUM_SUCCEEDED_TASKS).getValue());
assertEquals(2, counters.findCounter(TestCounter.Counter_1).getValue());
List<HistoryEvent> historyEvents1 = readRecoveryLog(1);
List<HistoryEvent> historyEvents2 = readRecoveryLog(2);
printHistoryEvents(historyEvents1, 1);
printHistoryEvents(historyEvents1, 2);
// task_0 of v1 is finished in attempt 1, task_1 of v1 is not finished in
// attempt 1
assertEquals(1, findTaskAttemptFinishedEvent(historyEvents1, 0, 0).size());
assertEquals(0, findTaskAttemptFinishedEvent(historyEvents1, 0, 1).size());
// task_0 of v1 is finished in attempt 1 and not rerun, task_1 of v1 is
// finished in attempt 2
assertEquals(1, findTaskAttemptFinishedEvent(historyEvents2, 0, 0).size());
assertEquals(1, findTaskAttemptFinishedEvent(historyEvents2, 0, 1).size());
}
use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestRecovery method testTwoRoundsRecoverying.
@Test(timeout = 1800000)
public void testTwoRoundsRecoverying() throws Exception {
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
TezDAGID dagId = TezDAGID.getInstance(appId, 1);
TezVertexID vertexId0 = TezVertexID.getInstance(dagId, 0);
TezVertexID vertexId1 = TezVertexID.getInstance(dagId, 1);
TezVertexID vertexId2 = TezVertexID.getInstance(dagId, 2);
ContainerId containerId = ContainerId.newInstance(ApplicationAttemptId.newInstance(appId, 1), 1);
NodeId nodeId = NodeId.newInstance("localhost", 10);
List<TezEvent> initGeneratedEvents = Lists.newArrayList(new TezEvent(InputDataInformationEvent.createWithObjectPayload(0, new Object()), null));
List<SimpleShutdownCondition> shutdownConditions = Lists.newArrayList(new SimpleShutdownCondition(TIMING.POST, new DAGInitializedEvent(dagId, 0L, "username", "dagName", null)), new SimpleShutdownCondition(TIMING.POST, new DAGStartedEvent(dagId, 0L, "username", "dagName")), new SimpleShutdownCondition(TIMING.POST, new VertexInitializedEvent(vertexId0, "Tokenizer", 0L, 0L, 0, "", null, initGeneratedEvents, null)), new SimpleShutdownCondition(TIMING.POST, new VertexStartedEvent(vertexId0, 0L, 0L)), new SimpleShutdownCondition(TIMING.POST, new VertexConfigurationDoneEvent(vertexId0, 0L, 2, null, null, null, true)), new SimpleShutdownCondition(TIMING.POST, new TaskStartedEvent(TezTaskID.getInstance(vertexId0, 0), "vertexName", 0L, 0L)), new SimpleShutdownCondition(TIMING.POST, new TaskAttemptStartedEvent(TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId0, 0), 0), "vertexName", 0L, containerId, nodeId, "", "", "")), new SimpleShutdownCondition(TIMING.POST, new TaskFinishedEvent(TezTaskID.getInstance(vertexId0, 0), "vertexName", 0L, 0L, null, TaskState.SUCCEEDED, "", new TezCounters(), 0)), new SimpleShutdownCondition(TIMING.POST, new VertexFinishedEvent(vertexId0, "vertexName", 1, 0L, 0L, 0L, 0L, 0L, VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(), new HashMap<String, Integer>(), null)), new SimpleShutdownCondition(TIMING.POST, new VertexFinishedEvent(vertexId1, "vertexName", 1, 0L, 0L, 0L, 0L, 0L, VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(), new HashMap<String, Integer>(), null)), new SimpleShutdownCondition(TIMING.POST, new VertexFinishedEvent(vertexId2, "vertexName", 1, 0L, 0L, 0L, 0L, 0L, VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(), new HashMap<String, Integer>(), null)), new SimpleShutdownCondition(TIMING.POST, new DAGFinishedEvent(dagId, 0L, 0L, DAGState.SUCCEEDED, "", new TezCounters(), "username", "dagName", new HashMap<String, Integer>(), ApplicationAttemptId.newInstance(appId, 1), null)));
Random rand = new Random();
for (int i = 0; i < shutdownConditions.size() - 1; i++) {
// timeout.
if (rand.nextDouble() < 0.5) {
int nextSimpleConditionIndex = i + 1 + rand.nextInt(shutdownConditions.size() - i - 1);
if (nextSimpleConditionIndex == shutdownConditions.size() - 1) {
testOrderedWordCountMultipleRoundRecoverying(new RecoveryServiceWithEventHandlingHook.MultipleRoundShutdownCondition(Lists.newArrayList(shutdownConditions.get(i), shutdownConditions.get(nextSimpleConditionIndex))), true, shutdownConditions.get(i).getHistoryEvent().getEventType() == HistoryEventType.VERTEX_STARTED);
}
}
}
}
use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestTezJobs method testPerIOCounterAggregation.
@Test(timeout = 60000)
public void testPerIOCounterAggregation() throws Exception {
String baseDir = "/tmp/perIOCounterAgg/";
Path inPath1 = new Path(baseDir + "inPath1");
Path inPath2 = new Path(baseDir + "inPath2");
Path outPath = new Path(baseDir + "outPath");
final Set<String> expectedResults = generateSortMergeJoinInput(inPath1, inPath2);
Path stagingDirPath = new Path("/tmp/tez-staging-dir");
remoteFs.mkdirs(stagingDirPath);
TezConfiguration conf = new TezConfiguration(mrrTezCluster.getConfig());
conf.setBoolean(TezConfiguration.TEZ_TASK_GENERATE_COUNTERS_PER_IO, true);
TezClient tezClient = TezClient.create(SortMergeJoinHelper.class.getSimpleName(), conf);
tezClient.start();
SortMergeJoinHelper sortMergeJoinHelper = new SortMergeJoinHelper(tezClient);
sortMergeJoinHelper.setConf(conf);
String[] args = new String[] { "-D" + TezConfiguration.TEZ_AM_STAGING_DIR + "=" + stagingDirPath.toString(), "-counter", inPath1.toString(), inPath2.toString(), "1", outPath.toString() };
assertEquals(0, sortMergeJoinHelper.run(conf, args, tezClient));
verifySortMergeJoinInput(outPath, expectedResults);
String joinerVertexName = "joiner";
String input1Name = "input1";
String input2Name = "input2";
String joinOutputName = "joinOutput";
Set<StatusGetOpts> statusOpts = new HashSet<StatusGetOpts>();
statusOpts.add(StatusGetOpts.GET_COUNTERS);
VertexStatus joinerVertexStatus = sortMergeJoinHelper.dagClient.getVertexStatus(joinerVertexName, statusOpts);
final TezCounters joinerCounters = joinerVertexStatus.getVertexCounters();
final CounterGroup aggregatedGroup = joinerCounters.getGroup(TaskCounter.class.getCanonicalName());
final CounterGroup input1Group = joinerCounters.getGroup(TaskCounter.class.getSimpleName() + "_" + joinerVertexName + "_INPUT_" + input1Name);
final CounterGroup input2Group = joinerCounters.getGroup(TaskCounter.class.getSimpleName() + "_" + joinerVertexName + "_INPUT_" + input2Name);
assertTrue("aggregated counter group cannot be empty", aggregatedGroup.size() > 0);
assertTrue("per io group for input1 cannot be empty", input1Group.size() > 0);
assertTrue("per io group for input1 cannot be empty", input2Group.size() > 0);
List<TaskCounter> countersToVerifyAgg = Arrays.asList(TaskCounter.ADDITIONAL_SPILLS_BYTES_READ, TaskCounter.ADDITIONAL_SPILLS_BYTES_WRITTEN, TaskCounter.COMBINE_INPUT_RECORDS, TaskCounter.MERGED_MAP_OUTPUTS, TaskCounter.NUM_DISK_TO_DISK_MERGES, TaskCounter.NUM_FAILED_SHUFFLE_INPUTS, TaskCounter.NUM_MEM_TO_DISK_MERGES, TaskCounter.NUM_SHUFFLED_INPUTS, TaskCounter.NUM_SKIPPED_INPUTS, TaskCounter.REDUCE_INPUT_GROUPS, TaskCounter.REDUCE_INPUT_RECORDS, TaskCounter.SHUFFLE_BYTES, TaskCounter.SHUFFLE_BYTES_DECOMPRESSED, TaskCounter.SHUFFLE_BYTES_DISK_DIRECT, TaskCounter.SHUFFLE_BYTES_TO_DISK, TaskCounter.SHUFFLE_BYTES_TO_MEM, TaskCounter.SPILLED_RECORDS);
int nonZeroCounters = 0;
// verify that the sum of the counter values for edges add up to the aggregated counter value.
for (TaskCounter c : countersToVerifyAgg) {
TezCounter aggregatedCounter = aggregatedGroup.findCounter(c.name(), false);
TezCounter input1Counter = input1Group.findCounter(c.name(), false);
TezCounter input2Counter = input2Group.findCounter(c.name(), false);
assertNotNull("aggregated counter cannot be null " + c.name(), aggregatedCounter);
assertNotNull("input1 counter cannot be null " + c.name(), input1Counter);
assertNotNull("input2 counter cannot be null " + c.name(), input2Counter);
assertEquals("aggregated counter does not match sum of input counters " + c.name(), aggregatedCounter.getValue(), input1Counter.getValue() + input2Counter.getValue());
if (aggregatedCounter.getValue() > 0) {
nonZeroCounters++;
}
}
// ensure that at least one of the counters tested above were non-zero.
assertTrue("At least one of the counter should be non-zero. invalid test ", nonZeroCounters > 0);
CounterGroup joinerOutputGroup = joinerCounters.getGroup(TaskCounter.class.getSimpleName() + "_" + joinerVertexName + "_OUTPUT_" + joinOutputName);
String outputCounterName = TaskCounter.OUTPUT_RECORDS.name();
TezCounter aggregateCounter = aggregatedGroup.findCounter(outputCounterName, false);
TezCounter joinerOutputCounter = joinerOutputGroup.findCounter(outputCounterName, false);
assertNotNull("aggregated counter cannot be null " + outputCounterName, aggregateCounter);
assertNotNull("output counter cannot be null " + outputCounterName, joinerOutputCounter);
assertTrue("counter value is zero. test is invalid", aggregateCounter.getValue() > 0);
assertEquals("aggregated counter does not match sum of output counters " + outputCounterName, aggregateCounter.getValue(), joinerOutputCounter.getValue());
}
use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestValuesIterator method createTezInputContext.
private InputContext createTezInputContext() {
TezCounters counters = new TezCounters();
InputContext inputContext = mock(InputContext.class);
doReturn(1024 * 1024 * 100l).when(inputContext).getTotalMemoryAvailableToTask();
doReturn(counters).when(inputContext).getCounters();
doReturn(1).when(inputContext).getInputIndex();
doReturn("srcVertex").when(inputContext).getSourceVertexName();
doReturn(1).when(inputContext).getTaskVertexIndex();
doReturn(UserPayload.create(ByteBuffer.wrap(new byte[1024]))).when(inputContext).getUserPayload();
return inputContext;
}
use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestUnorderedKVReader method testInterruptOnNext.
@Test(timeout = 5000)
public void testInterruptOnNext() throws IOException, InterruptedException {
ShuffleManager shuffleManager = mock(ShuffleManager.class);
// Simulate an interrupt while waiting for the next fetched input.
doThrow(new InterruptedException()).when(shuffleManager).getNextInput();
TezCounters counters = new TezCounters();
TezCounter inputRecords = counters.findCounter(TaskCounter.INPUT_RECORDS_PROCESSED);
UnorderedKVReader<Text, Text> reader = new UnorderedKVReader<Text, Text>(shuffleManager, defaultConf, null, false, -1, -1, inputRecords, mock(InputContext.class));
try {
reader.next();
fail("No data available to reader. Should not be able to access any record");
} catch (IOInterruptedException e) {
// Expected exception. Any other should fail the test.
}
}
Aggregations