You could use this function to increment your counters:
context.getCounter("PrettyGroupName", BadRecordCounters.NO_CREATION_DATE.name()).increment(1);
Domanda
I have the following counters defined
static enum BadRecordCounters
{
NO_CREATION_DATE, UNKNOWN_USER_ID, UNPARSEABLE_RECORD, UNTAGGED_POSTS
}
and they are displayed as below
14/05/06 21:43:06 INFO mapred.JobClient: com.aravind.learning.hadoop.mapred.techtalks.StackoverflowDataWranglerMapper$BadRecordCounters
14/05/06 21:43:06 INFO mapred.JobClient: UNKNOWN_USER_ID=93
14/05/06 21:43:06 INFO mapred.JobClient: UNTAGGED_POSTS=2461
I am wondering if there is a mechanism to use alternate text for these. For e.g I want the counter group to be read as Bad Record Counters instead of FQCN.
Soluzione 2
You could use this function to increment your counters:
context.getCounter("PrettyGroupName", BadRecordCounters.NO_CREATION_DATE.name()).increment(1);
Altri suggerimenti
Map Reduce lets you modify the labels for counters specified in your programs via property files.
The Definitive guide has a section called "Readable counter names" which deals with this topic.
I am just reproducing the relevant section here
The recipe to provide readable names is as follows. Create a properties file named after the enum, using an underscore as a separator for nested classes. The properties file should be in the same directory as the top-level class containing the enum. The file is named MaxTemperatureWithCounters_Temperature.properties for the counters in Example 8-1.
The properties file should contain a single property named CounterGroupName, whose value is the display name for the whole group. Then each field in the enum should have a corresponding property defined for it, whose name is the name of the field suffixed with .name and whose value is the display name for the counter.
MaxTemperatureWithCounters_Temperature.properties:
CounterGroupName=Air Temperature Records
MISSING.name=Missing
MALFORMED.name=Malformed
The properties file should be in the same directory as the top-level class containing the enum.