org.apache.hadoop.mapreduce.counters
Class AbstractCounterGroup<T extends Counter>

java.lang.Object
  extended by org.apache.hadoop.mapreduce.counters.AbstractCounterGroup<T>
Type Parameters:
T - type of the counter for the group
All Implemented Interfaces:
Iterable<T>, org.apache.hadoop.io.Writable, CounterGroupBase<T>

@InterfaceAudience.Private
public abstract class AbstractCounterGroup<T extends Counter>
extends Object
implements CounterGroupBase<T>

An abstract class to provide common implementation of the generic counter group in both mapred and mapreduce package.


Constructor Summary
AbstractCounterGroup(String name, String displayName, Limits limits)
           
 
Method Summary
 T addCounter(String counterName, String displayName, long value)
          Add a counter to this group
 void addCounter(T counter)
          Add a counter to this group.
 boolean equals(Object genericRight)
           
 T findCounter(String counterName)
          Find a counter in the group.
 T findCounter(String counterName, boolean create)
          Find a counter in the group
 T findCounter(String counterName, String displayName)
          Find a counter in the group.
 String getDisplayName()
          Get the display name of the group.
 String getName()
          Get the internal name of the group
 int hashCode()
           
 void incrAllCounters(CounterGroupBase<T> rightGroup)
          Increment all counters by a group of counters
 Iterator<T> iterator()
           
protected abstract  T newCounter()
          Abstract factory method to create a new counter of type T
protected abstract  T newCounter(String counterName, String displayName, long value)
          Abstract factory method to create a new counter of type T
 void readFields(DataInput in)
           
 void setDisplayName(String displayName)
          Set the display name of the group
 int size()
           
 void write(DataOutput out)
          GenericGroup ::= displayName #counter counter*
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.mapreduce.counters.CounterGroupBase
getUnderlyingGroup
 

Constructor Detail

AbstractCounterGroup

public AbstractCounterGroup(String name,
                            String displayName,
                            Limits limits)
Method Detail

getName

public String getName()
Description copied from interface: CounterGroupBase
Get the internal name of the group

Specified by:
getName in interface CounterGroupBase<T extends Counter>
Returns:
the internal name

getDisplayName

public String getDisplayName()
Description copied from interface: CounterGroupBase
Get the display name of the group.

Specified by:
getDisplayName in interface CounterGroupBase<T extends Counter>
Returns:
the human readable name

setDisplayName

public void setDisplayName(String displayName)
Description copied from interface: CounterGroupBase
Set the display name of the group

Specified by:
setDisplayName in interface CounterGroupBase<T extends Counter>
Parameters:
displayName - of the group

addCounter

public void addCounter(T counter)
Description copied from interface: CounterGroupBase
Add a counter to this group.

Specified by:
addCounter in interface CounterGroupBase<T extends Counter>
Parameters:
counter - to add

addCounter

public T addCounter(String counterName,
                    String displayName,
                    long value)
Description copied from interface: CounterGroupBase
Add a counter to this group

Specified by:
addCounter in interface CounterGroupBase<T extends Counter>
Parameters:
counterName - of the counter
displayName - of the counter
value - of the counter
Returns:
the counter

findCounter

public T findCounter(String counterName,
                     String displayName)
Description copied from interface: CounterGroupBase
Find a counter in the group.

Specified by:
findCounter in interface CounterGroupBase<T extends Counter>
Parameters:
counterName - the name of the counter
displayName - the display name of the counter
Returns:
the counter that was found or added

findCounter

public T findCounter(String counterName,
                     boolean create)
Description copied from interface: CounterGroupBase
Find a counter in the group

Specified by:
findCounter in interface CounterGroupBase<T extends Counter>
Parameters:
counterName - the name of the counter
create - create the counter if not found if true
Returns:
the counter that was found or added or null if create is false

findCounter

public T findCounter(String counterName)
Description copied from interface: CounterGroupBase
Find a counter in the group.

Specified by:
findCounter in interface CounterGroupBase<T extends Counter>
Parameters:
counterName - the name of the counter
Returns:
the counter that was found or added

newCounter

protected abstract T newCounter(String counterName,
                                String displayName,
                                long value)
Abstract factory method to create a new counter of type T

Parameters:
counterName - of the counter
displayName - of the counter
value - of the counter
Returns:
a new counter

newCounter

protected abstract T newCounter()
Abstract factory method to create a new counter of type T

Returns:
a new counter object

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T extends Counter>

write

public void write(DataOutput out)
           throws IOException
GenericGroup ::= displayName #counter counter*

Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

size

public int size()
Specified by:
size in interface CounterGroupBase<T extends Counter>
Returns:
the number of counters in this group.

equals

public boolean equals(Object genericRight)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

incrAllCounters

public void incrAllCounters(CounterGroupBase<T> rightGroup)
Description copied from interface: CounterGroupBase
Increment all counters by a group of counters

Specified by:
incrAllCounters in interface CounterGroupBase<T extends Counter>
Parameters:
rightGroup - the group to be added to this group


Copyright © 2013 Apache Software Foundation. All Rights Reserved.