Class MutableRatesWithAggregation

java.lang.Object
org.apache.hadoop.metrics2.lib.MutableMetric
org.apache.hadoop.metrics2.lib.MutableRatesWithAggregation

@Public @Evolving public class MutableRatesWithAggregation extends MutableMetric
Helper class to manage a group of mutable rate metrics. Each thread will maintain a local rate count, and upon snapshot, these values will be aggregated into a global rate. This class should only be used for long running threads, as any metrics produced between the last snapshot and the death of a thread will be lost. This allows for significantly higher concurrency than MutableRates. See HADOOP-24420.
  • Constructor Details

    • MutableRatesWithAggregation

      public MutableRatesWithAggregation()
  • Method Details

    • 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
    • init

      public void init(String[] names)
      Initialize the registry with all rate names passed in. This is an alternative to the above init function since this metric can be used more than just for rpc name.
      Parameters:
      names - the array of all rate names
    • 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
    • init

      public void init(Class<?> protocol, String prefix)