In the development of the Mr Program of Hadoop, it is often necessary to statistic some Map/reduce's running state information, which can be implemented by custom counter, which is done by the Code runtime check instead of the configuration information.
1. Create a Counter enumeration class of your own.
enum Process_counter { bad_records, bad_groups;}
2, in need of statistics, such as map or reduce phase of the following operations.
// added 1 // 1 Reduction
3, after the completion of the job run to obtain statistical information, the code is as follows:
Org.apache.hadoop.mapreduce.Counters Counters == counters.findcounter (process_counter. Bad_records); System.out.println ("Bad records:" + Counter.getvalue ()); System.out.println ("bad groups:" + job.getcounters (). Findcounter (Process_counter. bad_groups). GetValue ());
[Hadoop]-MapReduce Custom counter