/** * Returns the named counter group, or an empty group if there is none * with the specified name. */ public synchronized CounterGroup getGroup(String groupName) { CounterGroup grp = groups.get(groupName); if (grp == null) { grp = new CounterGroup(groupName); groups.put(groupName, grp); } return grp; }
/** * Returns the named counter group, or an empty group if there is none * with the specified name. */ public synchronized CounterGroup getGroup(String groupName) { CounterGroup grp = groups.get(groupName); if (grp == null) { grp = new CounterGroup(groupName); groups.put(groupName, grp); } return grp; }
/** * Read a set of groups. */ @Override public synchronized void readFields(DataInput in) throws IOException { int numClasses = in.readInt(); groups.clear(); while (numClasses-- > 0) { String groupName = Text.readString(in); CounterGroup group = new CounterGroup(groupName); group.readFields(in); groups.put(groupName, group); } }
/** * Read a set of groups. */ @Override public synchronized void readFields(DataInput in) throws IOException { int numClasses = in.readInt(); groups.clear(); while (numClasses-- > 0) { String groupName = Text.readString(in); CounterGroup group = new CounterGroup(groupName); group.readFields(in); groups.put(groupName, group); } }
/** * Increments multiple counters by their amounts in another Counters * instance. * @param other the other Counters instance */ public synchronized void incrAllCounters(Counters other) { for(Map.Entry<String, CounterGroup> rightEntry: other.groups.entrySet()) { CounterGroup left = groups.get(rightEntry.getKey()); CounterGroup right = rightEntry.getValue(); if (left == null) { left = new CounterGroup(right.getName(), right.getDisplayName()); groups.put(rightEntry.getKey(), left); } left.incrAllCounters(right); } }
/** * Increments multiple counters by their amounts in another Counters * instance. * @param other the other Counters instance */ public synchronized void incrAllCounters(Counters other) { for(Map.Entry<String, CounterGroup> rightEntry: other.groups.entrySet()) { CounterGroup left = groups.get(rightEntry.getKey()); CounterGroup right = rightEntry.getValue(); if (left == null) { left = new CounterGroup(right.getName(), right.getDisplayName()); groups.put(rightEntry.getKey(), left); } left.incrAllCounters(right); } }
static Counters fromAvro(JhCounters counters) { Counters result = new Counters(); for (JhCounterGroup g : counters.groups) { CounterGroup group = new CounterGroup(g.name.toString(), g.displayName.toString()); for (JhCounter c : g.counts) { group.addCounter(new Counter(c.name.toString(), c.displayName.toString(), c.value)); } result.addGroup(group); } return result; }
Counters(org.apache.hadoop.mapred.Counters counters) { for(org.apache.hadoop.mapred.Counters.Group group: counters) { String name = group.getName(); CounterGroup newGroup = new CounterGroup(name, group.getDisplayName()); groups.put(name, newGroup); for(Counter counter: group) { newGroup.addCounter(counter); } } }
/** * Utility method to create a Counters object from the * org.apache.hadoop.mapred counters * @param counters */ public Counters(org.apache.hadoop.mapred.Counters counters) { for(org.apache.hadoop.mapred.Counters.Group group: counters) { String name = group.getName(); CounterGroup newGroup = new CounterGroup(name, group.getDisplayName()); groups.put(name, newGroup); for(Counter counter: group) { newGroup.addCounter(counter); } } }