Class AbstractCounters<C extends Counter,G extends CounterGroupBase<C>>
java.lang.Object
org.apache.hadoop.mapreduce.counters.AbstractCounters<C,G>
- Type Parameters:
C- type of counter inside the countersG- type of group inside the counters
@Public
@Stable
public abstract class AbstractCounters<C extends Counter,G extends CounterGroupBase<C>>
extends Object
implements Writable, Iterable<G>
An abstract class to provide common implementation for the Counters
container in both mapred and mapreduce packages.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCounters(AbstractCounters<C1, G1> counters, org.apache.hadoop.mapreduce.counters.CounterGroupFactory<C, G> groupFactory) Construct from another counters object. -
Method Summary
Modifier and TypeMethodDescriptionaddGroup(G group) Add a group.Add a new groupintReturns the total number of counters, by summing the number of counters in each group.booleanfindCounter(Enum<?> key) Find the counter for the given enum.findCounter(String groupName, String counterName) Find a counter, create one if necessaryfindCounter(String scheme, org.apache.hadoop.mapreduce.FileSystemCounter key) Find the file system counter for the given scheme and enum.Returns the named counter group, or an empty group if there is none with the specified name.Returns the names of all counter classes.booleangetWriteAllCounters()Get the "writeAllCounters" optioninthashCode()voidincrAllCounters(AbstractCounters<C, G> other) Increments multiple counters by their amounts in another Counters instance.iterator()org.apache.hadoop.mapreduce.counters.Limitslimits()voidreadFields(DataInput in) Deserialize the fields of this object fromin.voidsetWriteAllCounters(boolean send) Set the "writeAllCounters" option to true or falsetoString()Return textual representation of the counter values.voidwrite(DataOutput out) Write the set of groups.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG
-
-
Constructor Details
-
AbstractCounters
-
AbstractCounters
@Private public AbstractCounters(AbstractCounters<C1, G1> counters, org.apache.hadoop.mapreduce.counters.CounterGroupFactory<C, G> groupFactory) Construct from another counters object.- Type Parameters:
C1- type of the other counterG1- type of the other counter group- Parameters:
counters- the counters object to copygroupFactory- the factory for new groups
-
-
Method Details
-
addGroup
Add a group.- Parameters:
group- object to add- Returns:
- the group
-
addGroup
Add a new group- Parameters:
name- of the groupdisplayName- of the group- Returns:
- the group
-
findCounter
Find a counter, create one if necessary- Parameters:
groupName- of the countercounterName- name of the counter- Returns:
- the matching counter
-
findCounter
Find the counter for the given enum. The same enum will always return the same counter.- Parameters:
key- the counter key- Returns:
- the matching counter object
-
findCounter
Find the file system counter for the given scheme and enum.- Parameters:
scheme- of the file systemkey- the enum of the counter- Returns:
- the file system counter
-
getGroupNames
Returns the names of all counter classes.- Returns:
- Set of counter names.
-
iterator
-
getGroup
Returns the named counter group, or an empty group if there is none with the specified name.- Parameters:
groupName- name of the group- Returns:
- the group
-
countCounters
public int countCounters()Returns the total number of counters, by summing the number of counters in each group.- Returns:
- the total number of counters
-
write
Write the set of groups. Counters ::= version #fgroups (groupId, group)* #groups (group)*- Specified by:
writein interfaceWritable- Parameters:
out-DataOuputto serialize this object into.- Throws:
IOException- any other problem for write.
-
readFields
Description copied from interface:WritableDeserialize the fields of this object fromin.For efficiency, implementations should attempt to re-use storage in the existing object where possible.
- Specified by:
readFieldsin interfaceWritable- Parameters:
in-DataInputto deseriablize this object from.- Throws:
IOException- any other problem for readFields.
-
toString
Return textual representation of the counter values. -
incrAllCounters
Increments multiple counters by their amounts in another Counters instance.- Parameters:
other- the other Counters instance
-
equals
-
hashCode
public int hashCode() -
setWriteAllCounters
@Private public void setWriteAllCounters(boolean send) Set the "writeAllCounters" option to true or false- Parameters:
send- if true all counters would be serialized, otherwise only framework counters would be serialized inwrite(DataOutput)
-
getWriteAllCounters
@Private public boolean getWriteAllCounters()Get the "writeAllCounters" option- Returns:
- true of all counters would serialized
-
limits
@Private public org.apache.hadoop.mapreduce.counters.Limits limits()
-