Search in sources :

Example 16 with Counter

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());
}
Also used : Group(org.apache.hadoop.mapred.Counters.Group) Counter(org.apache.hadoop.mapred.Counters.Counter) Counters(org.apache.hadoop.mapred.Counters)

Example 17 with Counter

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);
}
Also used : Counter(org.apache.hadoop.mapred.Counters.Counter) Counters(org.apache.hadoop.mapred.Counters) Map(java.util.Map)

Aggregations

Counter (org.apache.hadoop.mapred.Counters.Counter)17 Test (org.junit.Test)8 Counters (org.apache.hadoop.mapred.Counters)6 JobConf (org.apache.hadoop.mapred.JobConf)6 FileSystem (org.apache.hadoop.fs.FileSystem)5 IOException (java.io.IOException)4 Path (org.apache.hadoop.fs.Path)4 Group (org.apache.hadoop.mapred.Counters.Group)4 TaskCounter (org.apache.hadoop.mapreduce.TaskCounter)4 LocalDirAllocator (org.apache.hadoop.fs.LocalDirAllocator)3 CompressionCodec (org.apache.hadoop.io.compress.CompressionCodec)3 MapOutputFile (org.apache.hadoop.mapred.MapOutputFile)3 Reporter (org.apache.hadoop.mapred.Reporter)3 ShuffleConsumerPlugin (org.apache.hadoop.mapred.ShuffleConsumerPlugin)3 Task (org.apache.hadoop.mapred.Task)3 CombineOutputCollector (org.apache.hadoop.mapred.Task.CombineOutputCollector)3 TaskStatus (org.apache.hadoop.mapred.TaskStatus)3 TaskUmbilicalProtocol (org.apache.hadoop.mapred.TaskUmbilicalProtocol)3 Progress (org.apache.hadoop.util.Progress)3 ArrayList (java.util.ArrayList)2