Hadoop自定义Counter

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());

原文地址:https://www.cnblogs.com/pangblog/p/3315409.html