Package org.apache.hadoop.mapred
Class Counters
java.lang.Object
org.apache.hadoop.mapreduce.counters.AbstractCounters<Counters.Counter,Counters.Group>
org.apache.hadoop.mapred.Counters
- All Implemented Interfaces:
Iterable<Counters.Group>,Writable
A set of named counters.
Counters represent global counters, defined either by the
Map-Reduce framework or applications. Each Counter can be of
any Enum type.
Counters are bunched into Counters.Groups, each comprising of
counters from a particular Enum class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA counter record, comprising its name and value.static classorg.apache.hadoop.mapred.Counters.CountersExceededExceptionCounter exception thrown when the number of counters exceed the limitstatic classGroupof counters, comprising of counters from a particular counterEnumclass. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intFields inherited from class org.apache.hadoop.mapreduce.counters.AbstractCounters
LOG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindCounter(String group, int id, String name) Deprecated.findCounter(String group, String name) Find a counter, create one if necessarystatic CountersfromEscapedCompactString(String compactString) Convert a stringified (bymakeEscapedCompactString()counter representation into a counter object.longgetCounter(Enum<?> key) Returns current value of the specified counter, or 0 if the counter does not exist.Returns the named counter group, or an empty group if there is none with the specified name.Returns the names of all counter classes.voidincrAllCounters(Counters other) Increments multiple counters by their amounts in another Counters instance.voidincrCounter(Enum<?> key, long amount) Increments the specified counter by the specified amount, creating it if it didn't already exist.voidincrCounter(String group, String counter, long amount) Increments the specified counter by the specified amount, creating it if it didn't already exist.voidlog(org.slf4j.Logger log) Logs the current counter values.Represent the counter in a textual format that can be converted back to its object formintsize()Deprecated.useAbstractCounters.countCounters()insteadstatic CountersConvenience method for computing the sum of two sets of counters.Methods inherited from class org.apache.hadoop.mapreduce.counters.AbstractCounters
addGroup, addGroup, countCounters, equals, findCounter, findCounter, getWriteAllCounters, hashCode, incrAllCounters, iterator, limits, readFields, setWriteAllCounters, toString, writeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
MAX_COUNTER_LIMIT
public static final int MAX_COUNTER_LIMIT -
MAX_GROUP_LIMIT
public static final int MAX_GROUP_LIMIT
-
-
Constructor Details
-
Counters
public Counters() -
Counters
-
-
Method Details
-
getGroup
Description copied from class:AbstractCountersReturns the named counter group, or an empty group if there is none with the specified name.- Overrides:
getGroupin classAbstractCounters<Counters.Counter,Counters.Group> - Parameters:
groupName- name of the group- Returns:
- the group
-
getGroupNames
Description copied from class:AbstractCountersReturns the names of all counter classes.- Overrides:
getGroupNamesin classAbstractCounters<Counters.Counter,Counters.Group> - Returns:
- Set of counter names.
-
makeCompactString
-
findCounter
Description copied from class:AbstractCountersFind a counter, create one if necessary- Overrides:
findCounterin classAbstractCounters<Counters.Counter,Counters.Group> - Parameters:
group- of the countername- name of the counter- Returns:
- the matching counter
-
findCounter
Deprecated.usefindCounter(String, String)insteadFind a counter by using strings- Parameters:
group- the name of the groupid- the id of the counter within the group (0 to N-1)name- the internal name of the counter- Returns:
- the counter for that name
-
incrCounter
Increments the specified counter by the specified amount, creating it if it didn't already exist.- Parameters:
key- identifies a counteramount- amount by which counter is to be incremented
-
incrCounter
Increments the specified counter by the specified amount, creating it if it didn't already exist.- Parameters:
group- the name of the groupcounter- the internal name of the counteramount- amount by which counter is to be incremented
-
getCounter
Returns current value of the specified counter, or 0 if the counter does not exist.- Parameters:
key- the counter enum to lookup- Returns:
- the counter value or 0 if counter not found
-
incrAllCounters
Increments multiple counters by their amounts in another Counters instance.- Parameters:
other- the other Counters instance
-
size
public int size()Deprecated.useAbstractCounters.countCounters()instead- Returns:
- the total number of counters
-
sum
Convenience method for computing the sum of two sets of counters.- Parameters:
a- the first countersb- the second counters- Returns:
- a new summed counters object
-
log
public void log(org.slf4j.Logger log) Logs the current counter values.- Parameters:
log- The log to use.
-
makeEscapedCompactString
Represent the counter in a textual format that can be converted back to its object form- Returns:
- the string in the following format {(groupName)(group-displayName)[(counterName)(displayName)(value)][]*}*
-
fromEscapedCompactString
Convert a stringified (bymakeEscapedCompactString()counter representation into a counter object.- Parameters:
compactString- to parse- Returns:
- a new counters object
- Throws:
ParseException
-
findCounter(String, String)instead