use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestKVReadersWithMR method setup.
@Before
public void setup() {
conf = new JobConf();
counters = new TezCounters();
inputRecordCounter = counters.findCounter(TaskCounter.INPUT_RECORDS_PROCESSED);
}
use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestMROutput method createMockOutputContext.
private OutputContext createMockOutputContext(UserPayload payload, Configuration baseConf) {
OutputContext outputContext = mock(OutputContext.class);
ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
when(outputContext.getUserPayload()).thenReturn(payload);
when(outputContext.getApplicationId()).thenReturn(appId);
when(outputContext.getTaskVertexIndex()).thenReturn(1);
when(outputContext.getTaskAttemptNumber()).thenReturn(1);
when(outputContext.getCounters()).thenReturn(new TezCounters());
when(outputContext.getContainerConfiguration()).thenReturn(baseConf);
return outputContext;
}
use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestMRCombiner method getTaskContext.
private TaskContext getTaskContext(TezConfiguration conf) throws IOException {
UserPayload payload = TezUtils.createUserPayloadFromConf(conf);
TaskContext taskContext = Mockito.mock(InputContext.class);
Mockito.when(taskContext.getUserPayload()).thenReturn(payload);
Mockito.when(taskContext.getCounters()).thenReturn(new TezCounters());
Mockito.when(taskContext.getApplicationId()).thenReturn(ApplicationId.newInstance(123456, 1));
return taskContext;
}
use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestMRInput method testConfigMerge.
@Test(timeout = 5000)
public void testConfigMerge() throws Exception {
JobConf jobConf = new JobConf(false);
jobConf.set("payload-key", "payload-value");
Configuration localConfig = new Configuration(false);
localConfig.set("local-key", "local-value");
InputContext inputContext = mock(InputContext.class);
DataSourceDescriptor dsd = MRInput.createConfigBuilder(jobConf, TestInputFormat.class).groupSplits(false).build();
doReturn(dsd.getInputDescriptor().getUserPayload()).when(inputContext).getUserPayload();
doReturn(TEST_ATTRIBUTES_DAG_INDEX).when(inputContext).getDagIdentifier();
doReturn(TEST_ATTRIBUTES_VERTEX_INDEX).when(inputContext).getTaskVertexIndex();
doReturn(TEST_ATTRIBUTES_TASK_INDEX).when(inputContext).getTaskIndex();
doReturn(TEST_ATTRIBUTES_TASK_ATTEMPT_INDEX).when(inputContext).getTaskAttemptNumber();
doReturn(TEST_ATTRIBUTES_INPUT_INDEX).when(inputContext).getInputIndex();
doReturn(TEST_ATTRIBUTES_DAG_ATTEMPT_NUMBER).when(inputContext).getDAGAttemptNumber();
doReturn(TEST_ATTRIBUTES_DAG_NAME).when(inputContext).getDAGName();
doReturn(TEST_ATTRIBUTES_VERTEX_NAME).when(inputContext).getTaskVertexName();
doReturn(TEST_ATTRIBUTES_INPUT_NAME).when(inputContext).getSourceVertexName();
doReturn(TEST_ATTRIBUTES_APPLICATION_ID).when(inputContext).getApplicationId();
doReturn(TEST_ATTRIBUTES_UNIQUE_IDENTIFIER).when(inputContext).getUniqueIdentifier();
doReturn(localConfig).when(inputContext).getContainerConfiguration();
doReturn(new TezCounters()).when(inputContext).getCounters();
MRInputForTest input = new MRInputForTest(inputContext, 1);
input.initialize();
Configuration mergedConfig = input.getConfiguration();
assertEquals("local-value", mergedConfig.get("local-key"));
assertEquals("payload-value", mergedConfig.get("payload-key"));
}
use of org.apache.tez.common.counters.TezCounters in project tez by apache.
the class TestMRInput method testMRInputCloseWithUnintializedReader.
@Test
public void testMRInputCloseWithUnintializedReader() throws IOException {
InputContext inputContext = mock(InputContext.class);
doReturn(new TezCounters()).when(inputContext).getCounters();
doReturn(new InputStatisticsReporterImplForTest()).when(inputContext).getStatisticsReporter();
MRInput mrInput = new MRInput(inputContext, 0);
// shouldn't throw NPE
mrInput.close();
}
Aggregations