1、定义:用一个枚举来定义一组计数器,枚举中的每个元素都是一个计数器
在main类中定义
enum RecordsCounter{ RIGHT_COUNTER, WRONG_COUNTER };
context.getCounter(RecordsCounter.WRONG_COUNTER).increment(1);
Counters counters = job.getCounters(); Counter counter = counters.findCounter(RecordsCounter.WRONG_COUNTER); Long wrongCount = counter.getValue();
原文地址:http://blog.csdn.net/smile0198/article/details/40559769