Search in sources :

Example 41 with TezCounters

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);
}
Also used : JobConf(org.apache.hadoop.mapred.JobConf) TezCounters(org.apache.tez.common.counters.TezCounters) Before(org.junit.Before)

Example 42 with TezCounters

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;
}
Also used : ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) OutputContext(org.apache.tez.runtime.api.OutputContext) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 43 with TezCounters

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;
}
Also used : TaskContext(org.apache.tez.runtime.api.TaskContext) UserPayload(org.apache.tez.dag.api.UserPayload) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 44 with TezCounters

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"));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) InputContext(org.apache.tez.runtime.api.InputContext) JobConf(org.apache.hadoop.mapred.JobConf) TezCounters(org.apache.tez.common.counters.TezCounters) DataSourceDescriptor(org.apache.tez.dag.api.DataSourceDescriptor) Test(org.junit.Test)

Example 45 with TezCounters

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();
}
Also used : InputContext(org.apache.tez.runtime.api.InputContext) TezCounters(org.apache.tez.common.counters.TezCounters) Test(org.junit.Test)

Aggregations

TezCounters (org.apache.tez.common.counters.TezCounters)103 Test (org.junit.Test)34 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)24 TezCounter (org.apache.tez.common.counters.TezCounter)19 InputContext (org.apache.tez.runtime.api.InputContext)19 Configuration (org.apache.hadoop.conf.Configuration)17 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)17 OutputContext (org.apache.tez.runtime.api.OutputContext)15 DAG (org.apache.tez.dag.api.DAG)11 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 HashMap (java.util.HashMap)9 CounterGroup (org.apache.tez.common.counters.CounterGroup)9 StatusGetOpts (org.apache.tez.dag.api.client.StatusGetOpts)8 ByteString (com.google.protobuf.ByteString)7 IOException (java.io.IOException)7 Map (java.util.Map)7 Set (java.util.Set)7 Path (org.apache.hadoop.fs.Path)7 AggregateTezCounters (org.apache.tez.common.counters.AggregateTezCounters)7 LimitExceededException (org.apache.tez.common.counters.LimitExceededException)7