1.通过enum自定义Counter
public static num LOG_PROCESSOR_COUNTER {
BAD_RECORDS
};
2.在Mapper或者Reducer中操作Counter
context.getCounter(LOG_PROCESSOR_COUNTER.BAD_RECORDS).
increment(1);
3.在Job完成后可以进行最终统计结果的输出
Job job = new Job(getConf(), "log-analysis");
……
Counters counters = job.getCounters();
Counter badRecordsCounter = counters.findCounter(
LOG_PROCESSOR_COUNTER.BAD_RECORDS);
System.out.println("# of Bad Records:"+
badRecordsCounter.getValue());