List of usage examples for org.apache.hadoop.mapreduce CounterGroup getUnderlyingGroup
@Private CounterGroupBase<T> getUnderlyingGroup();
From source file:dz.lab.mapred.counter.StartsWithCountJob_PrintCounters.java
@Override public int run(String[] args) throws Exception { Configuration conf = getConf(); // the following property will enable mapreduce to use its packaged local job runner //conf.set("mapreduce.framework.name", "local"); Job job = Job.getInstance(conf, "StartsWithCountJob"); job.setJarByClass(getClass());//from www. j a v a 2 s .c o m // configure output and input source TextInputFormat.addInputPath(job, new Path(args[0])); job.setInputFormatClass(TextInputFormat.class); // configure mapper and reducer job.setMapperClass(StartsWithCountMapper.class); job.setCombinerClass(StartsWithCountReducer.class); job.setReducerClass(StartsWithCountReducer.class); // configure output TextOutputFormat.setOutputPath(job, new Path(args[1])); job.setOutputFormatClass(TextOutputFormat.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); int resultCode = job.waitForCompletion(true) ? 0 : 1; System.out.println("Job is complete! Printing Counters:"); Counters counters = job.getCounters(); for (String groupName : counters.getGroupNames()) { CounterGroup group = counters.getGroup(groupName); System.out.println(group.getDisplayName()); for (Counter counter : group.getUnderlyingGroup()) { System.out.println(" " + counter.getDisplayName() + "=" + counter.getValue()); } } return resultCode; }