private Map<String, Double> extractAllCounterValues(Counters counters) { Map<String, Double> exctractedCounters = new HashMap<String, Double>(); for (Counters.Group cg : counters) { for (Counter c : cg) { exctractedCounters.put(cg.getName() + "::" + c.getName(), new Double(c.getCounter())); } } return exctractedCounters; }
private Map<String, Double> extractAllCounterValues(Counters counters) { Map<String, Double> exctractedCounters = new HashMap<String, Double>(); for (Counters.Group cg : counters) { for (Counter c : cg) { exctractedCounters.put(cg.getName() + "::" + c.getName(), new Double(c.getCounter())); } } return exctractedCounters; }
private Map<String, Long> groupToMap(Counters.Group counterGroup) { Map<String, Long> counters = Maps.newHashMap(); for (Counters.Counter counter : counterGroup) { counters.put(counter.getName(), counter.getValue()); } return counters; } }
/** * Increments multiple counters by their amounts in another Counters * instance. * @param other the other Counters instance */ public synchronized void incrAllCounters(Counters other) { for (Group otherGroup: other) { Group group = getGroup(otherGroup.getName()); group.displayName = otherGroup.displayName; for (Counter otherCounter : otherGroup) { Counter counter = group.getCounterForName(otherCounter.getName()); counter.setDisplayName(otherCounter.getDisplayName()); counter.increment(otherCounter.getValue()); } } }
/** * Increments multiple counters by their amounts in another Counters * instance. * @param other the other Counters instance */ public synchronized void incrAllCounters(Counters other) { for (Group otherGroup: other) { Group group = getGroup(otherGroup.getName()); group.displayName = otherGroup.displayName; for (Counter otherCounter : otherGroup) { Counter counter = group.getCounterForName(otherCounter.getName()); counter.displayName = otherCounter.displayName; counter.value += otherCounter.value; } } }
public static String extractCounter(String counterFromHist, String... counterNames) throws ParseException { Counters counters = Counters.fromEscapedCompactString(counterFromHist); for (Counters.Group group : counters) { for (Counters.Counter counter : group) { for (String counterName : counterNames) { if (counterName.equals(counter.getName())) { return String.valueOf(counter.getCounter()); } } } } return ""; }
@Override public synchronized void incrAllCounters( org.apache.hadoop.mapred.Counters other) { for (Group otherGroup: other) { Group group = getGroup(otherGroup.getName()); group.setDisplayName(otherGroup.getDisplayName()); for (Counter otherCounter : otherGroup) { Counter counter = group.getCounterForName(otherCounter.getName()); counter.setDisplayName(otherCounter.getDisplayName()); counter.increment(otherCounter.getValue()); } } }
@Override public synchronized boolean equals(Object genericRight) { if (genericRight instanceof Counter) { synchronized (genericRight) { Counter right = (Counter) genericRight; return getName().equals(right.getName()) && getDisplayName().equals(right.getDisplayName()) && getValue() == right.getValue(); } } return false; }
@Override public synchronized boolean equals(Object genericRight) { if (genericRight instanceof Counter) { synchronized (genericRight) { Counter right = (Counter) genericRight; return getName().equals(right.getName()) && getDisplayName().equals(right.getDisplayName()) && getValue() == right.getValue(); } } return false; }
@Override public synchronized boolean equals(Object genericRight) { if (genericRight instanceof Counter) { synchronized (genericRight) { Counter right = (Counter) genericRight; return getName().equals(right.getName()) && getDisplayName().equals(right.getDisplayName()) && getValue() == right.getValue(); } } return false; }
private Map<String, Long> groupToMap(Counters.Group counterGroup) { Map<String, Long> counters = Maps.newHashMap(); for (Counters.Counter counter : counterGroup) { counters.put(counter.getName(), counter.getValue()); } return counters; } }
private Map<String, Double> extractAllCounterValues(Counters counters) { Map<String, Double> exctractedCounters = new HashMap<String, Double>(); for (Counters.Group cg : counters) { for (Counter c : cg) { exctractedCounters.put(cg.getName() + "::" + c.getName(), new Double(c.getCounter())); } } return exctractedCounters; }
@Override public synchronized boolean equals(Object genericRight) { if (genericRight instanceof Counter) { synchronized (genericRight) { Counter right = (Counter) genericRight; return getName().equals(right.getName()) && getDisplayName().equals(right.getDisplayName()) && getValue() == right.getValue(); } } return false; }
public synchronized void readFields(DataInput in) throws IOException { displayName = Text.readString(in); subcounters.clear(); int size = WritableUtils.readVInt(in); for(int i=0; i < size; i++) { Counter counter = new Counter(); counter.readFields(in); subcounters.put(counter.getName(), counter); } }
public synchronized void readFields(DataInput in) throws IOException { displayName = CounterNames.intern(Text.readString(in)); subcounters.clear(); int size = WritableUtils.readVInt(in); for(int i=0; i < size; i++) { Counter counter = new Counter(); counter.readFields(in); subcounters.put(counter.getName(), counter); } }
synchronized boolean contentEquals(Counter c) { return name.equals(c.getName()) && displayName.equals(c.getDisplayName()) && value == c.getCounter(); }
private static List<Counter> getAllFromHadoopGroup(org.apache.hadoop.mapred.Counters.Group counterGroup) { Iterator<org.apache.hadoop.mapred.Counters.Counter> counterIterator = counterGroup.iterator(); List<Counter> counters = new ArrayList<>(); while (counterIterator.hasNext()) { org.apache.hadoop.mapred.Counters.Counter counter = counterIterator.next(); counters.add(new Counter(counterGroup.getName(), counter.getName(), counter.getValue())); } return counters; }
@Override public void map(Counters key, NullWritable value, OutputCollector<Text, Text> collector, Reporter reporter) throws IOException { for (Group group : key) { for (Counter counter : group) { reporter.incrCounter(group.getName(), counter.getName(), counter.getValue()); } } }
public synchronized void readFields(DataInput in) throws IOException { displayName = Text.readString(in); subcounters.clear(); int size = WritableUtils.readVInt(in); for(int i=0; i < size; i++) { Counter counter = new Counter(); counter.readFields(in); subcounters.put(counter.getName(), counter); } }
public CounterInfo(Counters.Counter counter) { this.name = counter.getName(); this.displayName = counter.getDisplayName(); this.value = counter.getValue(); }