Example usage for org.apache.hadoop.mapreduce CounterGroup getName

List of usage examples for org.apache.hadoop.mapreduce CounterGroup getName

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce CounterGroup getName.

Prototype

String getName();

Source Link

Document

Get the internal name of the group

Usage

From source file:org.apache.ignite.client.hadoop.counter.GridHadoopClientCounters.java

License:Apache License

/** {@inheritDoc} */
@Override/*from ww  w.  j a v  a 2s.  c om*/
public synchronized void incrAllCounters(AbstractCounters<Counter, CounterGroup> other) {
    for (CounterGroup group : other) {
        for (Counter counter : group) {
            findCounter(group.getName(), counter.getName()).increment(counter.getValue());
        }
    }
}

From source file:org.opencloudengine.flamingo.mapreduce.util.CounterUtils.java

License:Apache License

/**
 * Job? ??   Counter Map ? ./*w ww.  ja  va 2  s  .  c o  m*/
 * Key? <tt>GROUP_COUNTER</tt> ?   Group Name?
 * <tt>CLEAN</tt>?, Counter <tt>VALID</tt>?  Key
 * <tt>CLEAN_VALID</tt> ?.
 *
 * @param job Hadoop Job
 * @return Counter ? ? Map
 */
public static Map<String, String> getCounters(Job job) {
    Map<String, String> resultMap = new HashMap<String, String>();
    try {
        Counters counters = job.getCounters();
        Iterable<String> groupNames = counters.getGroupNames();
        Iterator<String> groupIterator = groupNames.iterator();
        while (groupIterator.hasNext()) {
            String groupName = groupIterator.next();
            CounterGroup group = counters.getGroup(groupName);
            Iterator<Counter> counterIterator = group.iterator();
            while (counterIterator.hasNext()) {
                Counter counter = counterIterator.next();
                logger.info("[{}] {} = {}",
                        new Object[] { group.getName(), counter.getName(), counter.getValue() });
                String realName = HadoopMetrics.getMetricName(group.getName() + "_" + counter.getName());
                if (!StringUtils.isEmpty(realName)) {
                    resultMap.put(realName, String.valueOf(counter.getValue()));
                }
            }
        }
    } catch (Exception ex) {
    }
    return resultMap;
}

From source file:org.openflamingo.mapreduce.util.CounterUtils.java

License:Apache License

/**
 * Job? ??   Counter Map ? ./*w  ww  . j a va2 s . c  o m*/
 * Key? <tt>GROUP_COUNTER</tt> ?   Group Name?
 * <tt>CLEAN</tt>?, Counter <tt>VALID</tt>?  Key
 * <tt>CLEAN_VALID</tt> ?.
 *
 * @param job Hadoop Job
 * @return Counter ? ? Map
 */
public static Map<String, String> getCounters(Job job) {
    Map<String, String> resultMap = new HashMap<String, String>();
    try {
        Counters counters = job.getCounters();
        Collection<String> groupNames = counters.getGroupNames();
        Iterator<String> groupIterator = groupNames.iterator();
        while (groupIterator.hasNext()) {
            String groupName = groupIterator.next();
            CounterGroup group = counters.getGroup(groupName);
            Iterator<Counter> counterIterator = group.iterator();
            while (counterIterator.hasNext()) {
                Counter counter = counterIterator.next();
                logger.info("[{}] {} = {}",
                        new Object[] { group.getName(), counter.getName(), counter.getValue() });
                String realName = HadoopMetrics.getMetricName(group.getName() + "_" + counter.getName());
                if (!StringUtils.isEmpty(realName)) {
                    resultMap.put(realName, String.valueOf(counter.getValue()));
                }
            }
        }
    } catch (Exception ex) {
    }
    return resultMap;
}