Search in sources :

Example 1 with DAGCounter

use of org.apache.tez.common.counters.DAGCounter in project tez by apache.

the class LocalityAnalyzer method computeAverages.

/**
 * Compute counter averages for specific vertex
 *
 * @param vertexInfo
 * @param counter
 * @return task attempt details
 */
private TaskAttemptDetails computeAverages(VertexInfo vertexInfo, DAGCounter counter) {
    long totalTime = 0;
    long totalTasks = 0;
    long totalHDFSBytesRead = 0;
    TaskAttemptDetails result = new TaskAttemptDetails();
    for (TaskAttemptInfo attemptInfo : vertexInfo.getTaskAttempts()) {
        Map<String, TezCounter> localityCounter = attemptInfo.getCounter(DAGCounter.class.getName(), counter.toString());
        if (!localityCounter.isEmpty() && localityCounter.get(DAGCounter.class.getName()).getValue() > 0) {
            totalTime += attemptInfo.getTimeTaken();
            totalTasks++;
            // get HDFSBytes read counter
            Map<String, TezCounter> hdfsBytesReadCounter = attemptInfo.getCounter(FileSystemCounter.class.getName(), FileSystemCounter.HDFS_BYTES_READ.name());
            for (Map.Entry<String, TezCounter> entry : hdfsBytesReadCounter.entrySet()) {
                totalHDFSBytesRead += entry.getValue().getValue();
            }
        }
    }
    if (totalTasks > 0) {
        result.avgRuntime = (totalTime * 1.0f / totalTasks);
        result.avgHDFSBytesRead = (totalHDFSBytesRead * 1.0f / totalTasks);
    }
    return result;
}
Also used : TaskAttemptInfo(org.apache.tez.history.parser.datamodel.TaskAttemptInfo) DAGCounter(org.apache.tez.common.counters.DAGCounter) TezCounter(org.apache.tez.common.counters.TezCounter) FileSystemCounter(org.apache.tez.common.counters.FileSystemCounter) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 DAGCounter (org.apache.tez.common.counters.DAGCounter)1 FileSystemCounter (org.apache.tez.common.counters.FileSystemCounter)1 TezCounter (org.apache.tez.common.counters.TezCounter)1 TaskAttemptInfo (org.apache.tez.history.parser.datamodel.TaskAttemptInfo)1