org.apache.hadoop.metrics2.lib

## Class MutableRates

- java.lang.Object
- - org.apache.hadoop.metrics2.lib.MutableMetric
  - - org.apache.hadoop.metrics2.lib.MutableRates

-     @InterfaceAudience.Public
       @InterfaceStability.Evolving
      public class MutableRates
      extends MutableMetric

  Helper class to manage a group of mutable rate metrics This class synchronizes all accesses to the metrics it contains, so it should not be used in situations where there is high contention on the metrics. `MutableRatesWithAggregation` is preferable in that situation.

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(String name, long elapsed)` Add a rate sample for a rate metric
    `void` | `init(Class<?> protocol)` Initialize the registry with all the methods in a protocol so they all show up in the first snapshot.
    `void` | `snapshot(MetricsRecordBuilder rb, boolean all)` Get a snapshot of the metric

    - ### Methods inherited from class org.apache.hadoop.metrics2.lib.MutableMetric

      `changed, clearChanged, setChanged, snapshot`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### init

          public void init(Class<?> protocol)

      Initialize the registry with all the methods in a protocol so they all show up in the first snapshot. Convenient for JMX implementations.
      Parameters:
        `protocol` - the protocol class

    - #### add

          public void add(String name,
                          long elapsed)

      Add a rate sample for a rate metric
      Parameters:
        `name` - of the rate metric
        `elapsed` - time

    - #### snapshot

          public void snapshot(MetricsRecordBuilder rb,
                               boolean all)

      Description copied from class: `MutableMetric`
      Get a snapshot of the metric
      Specified by:
        `snapshot` in class `MutableMetric`
      Parameters:
        `rb` - the metrics record builder
        `all` - if true, snapshot unchanged metrics as well

Copyright © 2022 Apache Software Foundation. All rights reserved.