use of org.apache.hadoop.mapred.Counters.Counter in project hadoop by apache.
the class TestStreamingCounters method validateCounters.
private void validateCounters() throws IOException {
Counters counters = job.running_.getCounters();
assertNotNull("Counters", counters);
Group group = counters.getGroup("UserCounters");
assertNotNull("Group", group);
Counter counter = group.getCounterForName("InputLines");
assertNotNull("Counter", counter);
assertEquals(3, counter.getCounter());
}
use of org.apache.hadoop.mapred.Counters.Counter in project ambrose by twitter.
the class AmbroseHiveUtil method counterGroupInfoMap.
/**
* Constructs counter groups from job runtime statistics. Hive mangles Hadoop Counter data,
* forming counter names with format "$groupName::$counterName".
*
* @param counterNameToValue mangled hadoop counters from hive.
* @return counter groups by name.
*/
public static Map<String, CounterGroup> counterGroupInfoMap(Map<String, Double> counterNameToValue) {
Counters counters = new Counters();
for (Map.Entry<String, ? extends Number> entry : counterNameToValue.entrySet()) {
String key = entry.getKey();
Number value = entry.getValue();
String[] cNames = key.split("::");
String groupName = cNames[0];
String counterName = cNames[1];
Counter counter = counters.findCounter(groupName, counterName);
counter.setValue(value.longValue());
}
return CounterGroup.counterGroupsByName(counters);
}
Aggregations