/**
   * Constructs Countergroups from job runtime statistics
   *
   * @param counterNameToValue
   * @return
   */
  public static Map<String, CounterGroup> counterGroupInfoMap(
      Map<String, Double> counterNameToValue) {

    Counters counters = new Counters();
    for (Map.Entry<String, ? extends Number> entry : counterNameToValue.entrySet()) {

      String[] cNames = entry.getKey().split("::");
      String groupName = cNames[0];
      String counterName = cNames[1];
      Counter counter = counters.findCounter(groupName, counterName);
      counter.setValue(entry.getValue().longValue());
    }
    return CounterGroup.counterGroupInfoMap(counters);
  }
Example #2
0
  /**
   * helper method for counter group map retrieval
   *
   * @param HadoopStepStats
   * @return a map of counter name to counter value
   */
  private Map<String, Long> counterGroupInfoMapHelper(HadoopStepStats stats) {
    Counters counters = new Counters();
    Map<String, Long> counterNameToValue = new HashMap<String, Long>();
    for (String groupName : stats.getCounterGroups()) { // retreiving groups
      for (String counterName :
          stats.getCountersFor(groupName)) { // retreiving counters in that group
        Long counterValue = stats.getCounterValue(groupName, counterName);
        counterNameToValue.put(groupName + "::" + counterName, counterValue);

        // creating counter
        Counter counter = counters.findCounter(groupName, counterName);
        counter.setValue(counterValue);
      }
    }
    setCounterGroupMap(CounterGroup.counterGroupInfoMap(counters));
    return counterNameToValue;
  }