org.apache.hadoop.mapreduce.counters

## Class FrameworkCounterGroup<T extends Enum<T>,C extends Counter>

- java.lang.Object
- - 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:
    Iterable<C>, org.apache.hadoop.io.Writable, CounterGroupBase<C>

      @InterfaceAudience.Private
      public abstract class FrameworkCounterGroup<T extends Enum<T>,C extends Counter>
      extends 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

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `FrameworkCounterGroup.FrameworkCounter<T extends Enum<T>>` A counter facade for framework counters.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FrameworkCounterGroup(Class<T> enumClass)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addCounter(C counter)` Add a counter to this group.
    `C` | `addCounter(String name, String displayName, long value)` Add a counter to this group
    `boolean` | `equals(Object genericRight)`
    `C` | `findCounter(String counterName)` Find a counter in the group.
    `C` | `findCounter(String counterName, boolean create)` Find a counter in the group
    `C` | `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<C> other)` Increment all counters by a group of counters
    `Iterator<C>` | `iterator()`
    `protected abstract C` | `newCounter(T key)` Abstract factory method for new framework counter
    `void` | `readFields(DataInput in)`
    `void` | `setDisplayName(String displayName)` Set the display name of the group
    `int` | `size()`
    `void` | `write(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`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### FrameworkCounterGroup

          public FrameworkCounterGroup(Class<T> enumClass)

  - ### Method Detail

    - #### getName

          public 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 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(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(String name,
                              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(String counterName,
                               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(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(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(DataOutput out)
                     throws IOException

      FrameworkGroup ::= #counter (key value)*
      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`

    - #### iterator

          public Iterator<C> iterator()

      Specified by:
        `iterator` in interface `Iterable<C extends Counter>`

    - #### equals

          public boolean equals(Object genericRight)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.