Search in sources :

Example 46 with TezCounters

use of org.apache.tez.common.counters.TezCounters in project hive by apache.

the class DAGSummary method hiveInputRecordsFromTezCounters.

private long hiveInputRecordsFromTezCounters(String vertexName, String inputVertexName) {
    // Get the counters for the input vertex.
    Set<StatusGetOpts> statusOptions = Collections.singleton(StatusGetOpts.GET_COUNTERS);
    VertexStatus inputVertexStatus = vertexStatus(statusOptions, inputVertexName);
    final TezCounters inputVertexCounters = inputVertexStatus.getVertexCounters();
    // eg, group name TaskCounter_Map_7_OUTPUT_Reducer_8, counter name OUTPUT_RECORDS
    String groupName = formattedName("TaskCounter", inputVertexName, vertexName);
    String counterName = "OUTPUT_RECORDS";
    // Do not create counter if it does not exist -
    // instead fall back to default behavior for determining input records.
    TezCounter tezCounter = inputVertexCounters.getGroup(groupName).findCounter(counterName, false);
    if (tezCounter == null) {
        return -1;
    } else {
        return tezCounter.getValue();
    }
}
Also used : VertexStatus(org.apache.tez.dag.api.client.VertexStatus) StatusGetOpts(org.apache.tez.dag.api.client.StatusGetOpts) TezCounter(org.apache.tez.common.counters.TezCounter) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 47 with TezCounters

use of org.apache.tez.common.counters.TezCounters in project hive by apache.

the class DAGSummary method vertexSummary.

private String vertexSummary(String vertexName, Progress progress, VertexStatus vertexStatus) {
    /*
   * Get the CPU & GC
   *
   * counters org.apache.tez.common.counters.TaskCounter
   *  GC_TIME_MILLIS=37712
   *  CPU_MILLISECONDS=2774230
   */
    final TezCounters vertexCounters = vertexStatus.getVertexCounters();
    final double cpuTimeMillis = getCounterValueByGroupName(vertexCounters, TaskCounter.class.getName(), TaskCounter.CPU_MILLISECONDS.name());
    final double gcTimeMillis = getCounterValueByGroupName(vertexCounters, TaskCounter.class.getName(), TaskCounter.GC_TIME_MILLIS.name());
    /*
     * Get the HIVE counters
     *
     * HIVE
     *  CREATED_FILES=1
     *  DESERIALIZE_ERRORS=0
     *  RECORDS_IN_Map_1=550076554
     *  RECORDS_OUT_INTERMEDIATE_Map_1=854987
     *  RECORDS_OUT_Reducer_2=1
     */
    final long hiveInputRecords = hiveCounterValue(formattedName(MapOperator.Counter.RECORDS_IN.toString(), vertexName)) + hiveInputRecordsFromOtherVertices(vertexName);
    final long hiveOutputRecords = hiveCounterValue(formattedName(FileSinkOperator.Counter.RECORDS_OUT.toString(), vertexName)) + hiveCounterValue(formattedName(ReduceSinkOperator.Counter.RECORDS_OUT_INTERMEDIATE.toString(), vertexName));
    final double duration = perfLogger.getDuration(PerfLogger.TEZ_RUN_VERTEX + vertexName);
    return String.format(FORMATTING_PATTERN, vertexName, secondsFormatter.format((duration)), commaFormatter.format(cpuTimeMillis), commaFormatter.format(gcTimeMillis), commaFormatter.format(hiveInputRecords), commaFormatter.format(hiveOutputRecords));
}
Also used : TaskCounter(org.apache.tez.common.counters.TaskCounter) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 48 with TezCounters

use of org.apache.tez.common.counters.TezCounters in project hive by apache.

the class LLAPioSummary method print.

@Override
public void print(SessionState.LogHelper console) {
    console.printInfo("");
    console.printInfo(LLAP_IO_SUMMARY_HEADER);
    SortedSet<String> keys = new TreeSet<>(progressMap.keySet());
    Set<StatusGetOpts> statusOptions = Collections.singleton(StatusGetOpts.GET_COUNTERS);
    String counterGroup = LlapIOCounters.class.getName();
    for (String vertexName : keys) {
        // Reducers do not benefit from LLAP IO so no point in printing
        if (vertexName.startsWith("Reducer")) {
            continue;
        }
        TezCounters vertexCounters = vertexCounter(statusOptions, vertexName);
        if (vertexCounters != null) {
            if (!first) {
                console.printInfo(SEPARATOR);
                console.printInfo(LLAP_SUMMARY_HEADER);
                console.printInfo(SEPARATOR);
                first = true;
            }
            console.printInfo(vertexSummary(vertexName, counterGroup, vertexCounters));
        }
    }
    console.printInfo(SEPARATOR);
    console.printInfo("");
}
Also used : StatusGetOpts(org.apache.tez.dag.api.client.StatusGetOpts) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 49 with TezCounters

use of org.apache.tez.common.counters.TezCounters in project hive by apache.

the class FSCountersSummary method print.

@Override
public void print(SessionState.LogHelper console) {
    console.printInfo("FileSystem Counters Summary");
    SortedSet<String> keys = new TreeSet<>(progressMap.keySet());
    Set<StatusGetOpts> statusOptions = Collections.singleton(StatusGetOpts.GET_COUNTERS);
    // as well. If not, we need a way to get all the schemes that are accessed by the tez task/llap.
    for (FileSystem.Statistics statistics : FileSystem.getAllStatistics()) {
        final String scheme = statistics.getScheme().toUpperCase();
        console.printInfo("");
        console.printInfo("Scheme: " + scheme);
        console.printInfo(SEPARATOR);
        console.printInfo(HEADER);
        console.printInfo(SEPARATOR);
        for (String vertexName : keys) {
            TezCounters vertexCounters = vertexCounters(statusOptions, vertexName);
            if (vertexCounters != null) {
                console.printInfo(summary(scheme, vertexName, vertexCounters));
            }
        }
        console.printInfo(SEPARATOR);
    }
}
Also used : StatusGetOpts(org.apache.tez.dag.api.client.StatusGetOpts) FileSystem(org.apache.hadoop.fs.FileSystem) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 50 with TezCounters

use of org.apache.tez.common.counters.TezCounters 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"));
}
Also used : TaskEventScheduleTask(org.apache.tez.dag.app.dag.event.TaskEventScheduleTask) Task(org.apache.tez.dag.app.dag.Task) VertexEventTaskCompleted(org.apache.tez.dag.app.dag.event.VertexEventTaskCompleted) TezTaskID(org.apache.tez.dag.records.TezTaskID) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint) VertexLocationHint(org.apache.tez.dag.api.VertexLocationHint) PlanTaskLocationHint(org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint) TezCounters(org.apache.tez.common.counters.TezCounters) VertexManagerPluginForTest(org.apache.tez.test.VertexManagerPluginForTest) Test(org.junit.Test) GraceShuffleVertexManagerForTest(org.apache.tez.test.GraceShuffleVertexManagerForTest) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest) EdgeManagerForTest(org.apache.tez.test.EdgeManagerForTest)

Aggregations

TezCounters (org.apache.tez.common.counters.TezCounters)100 Test (org.junit.Test)33 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)22 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)20 InputContext (org.apache.tez.runtime.api.InputContext)20 TezCounter (org.apache.tez.common.counters.TezCounter)18 Configuration (org.apache.hadoop.conf.Configuration)17 InvocationOnMock (org.mockito.invocation.InvocationOnMock)14 OutputContext (org.apache.tez.runtime.api.OutputContext)13 TezRuntimeConfiguration (org.apache.tez.runtime.library.api.TezRuntimeConfiguration)12 IOException (java.io.IOException)10 Path (org.apache.hadoop.fs.Path)10 DAG (org.apache.tez.dag.api.DAG)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 Map (java.util.Map)7 Set (java.util.Set)7 LimitExceededException (org.apache.tez.common.counters.LimitExceededException)7