org.apache.hadoop.mapreduce.counters
Class FrameworkCounterGroup<T extends java.lang.Enum<T>,C extends Counter>

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

@InterfaceAudience.Private
public abstract class FrameworkCounterGroup<T extends java.lang.Enum<T>,C extends Counter>
extends java.lang.Object
implements CounterGroupBase<C>

An abstract class to provide common implementation for the framework counter group in both mapred and mapreduce packages.


Nested Class Summary
 class FrameworkCounterGroup.FrameworkCounter
          A counter facade for framework counters.
 
Constructor Summary
FrameworkCounterGroup(java.lang.Class<T> enumClass)
           
 
Method Summary
 void addCounter(C counter)
          Add a counter to this group.
 C addCounter(java.lang.String name, java.lang.String displayName, long value)
          Add a counter to this group
 boolean equals(java.lang.Object genericRight)
           
 C findCounter(java.lang.String counterName)
          Find a counter in the group.
 C findCounter(java.lang.String counterName, boolean create)
          Find a counter in the group
 C findCounter(java.lang.String counterName, java.lang.String displayName)
          Find a counter in the group.
 java.lang.String getDisplayName()
          Get the display name of the group.
 java.lang.String getName()
          Get the internal name of the group
 int hashCode()
           
 void incrAllCounters(CounterGroupBase<C> other)
          Increment all counters by a group of counters
 java.util.Iterator<C> iterator()
           
protected abstract  C newCounter(T key)
          Abstract factory method for new framework counter
 void readFields(java.io.DataInput in)
           
 void setDisplayName(java.lang.String displayName)
          Set the display name of the group
 int size()
           
 void write(java.io.DataOutput out)
          FrameworkGroup ::= #counter (key value)*
 
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

FrameworkCounterGroup

public FrameworkCounterGroup(java.lang.Class<T> enumClass)
Method Detail

getName

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

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

getDisplayName

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

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

setDisplayName

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

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

addCounter

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

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

addCounter

public C addCounter(java.lang.String name,
                    java.lang.String displayName,
                    long value)
Description copied from interface: CounterGroupBase
Add a counter to this group

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

findCounter

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

Specified by:
findCounter in interface CounterGroupBase<C 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 C findCounter(java.lang.String counterName,
                     boolean create)
Description copied from interface: CounterGroupBase
Find a counter in the group

Specified by:
findCounter in interface CounterGroupBase<C 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 C findCounter(java.lang.String counterName)
Description copied from interface: CounterGroupBase
Find a counter in the group.

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

newCounter

protected abstract C newCounter(T key)
Abstract factory method for new framework counter

Parameters:
key - for the enum value of a counter
Returns:
a new counter for the key

size

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

incrAllCounters

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

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

write

public void write(java.io.DataOutput out)
           throws java.io.IOException
FrameworkGroup ::= #counter (key value)*

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

readFields

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

iterator

public java.util.Iterator<C> iterator()
Specified by:
iterator in interface java.lang.Iterable<C extends Counter>

equals

public boolean equals(java.lang.Object genericRight)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2009 The Apache Software Foundation