Counters extends AbstractCounters<Counters.Counter, Counters.Group> { public Counters() { super(groupFactory); } Counters();  Counters(org.apache.hadoop.mapreduce.Counters newCounters); synchronized Group getGroup(String groupName); @SuppressWarnings("unchecked") synchronized Collection<String> getGroupNames(); synchronized String makeCompactString(); synchronized Counter findCounter(String group, String name); @Deprecated Counter findCounter(String group, int id, String name); void incrCounter(Enum<?> key, long amount); void incrCounter(String group, String counter, long amount); synchronized long getCounter(Enum<?> key); synchronized void incrAllCounters(Counters other); int size(); static Counters sum(Counters a, Counters b); void log(Log log); String makeEscapedCompactString(); static Counters fromEscapedCompactString(String compactString); static final int MAX_COUNTER_LIMIT; static final int MAX_GROUP_LIMIT; }
@Test public void testCounters() throws IOException { Enum[] keysWithResource = {TaskCounter.MAP_INPUT_RECORDS, TaskCounter.MAP_OUTPUT_BYTES}; Enum[] keysWithoutResource = {myCounters.TEST1, myCounters.TEST2}; String[] groups = {"group1", "group2", "group{}()[]"}; String[] counters = {"counter1", "counter2", "counter{}()[]"}; try { testCounter(getEnumCounters(keysWithResource)); testCounter(getEnumCounters(keysWithoutResource)); testCounter(getEnumCounters(groups, counters)); } catch (ParseException pe) { throw new IOException(pe); } }