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;
}
Aggregations