com.h3c.sdn.metric

## Class MetricRegistry

- java.lang.Object
- - com.h3c.sdn.metric.MetricRegistry

-     public class MetricRegistry
      extends Object

  A registry of `TimeStampedMetric` instances.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `MetricRegistry.PersistTimes` Utility class that holds two time stamps that should correspond to a single metric.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MetricRegistry()` Creates a new `MetricRegistry` with a default metric persistence interval of SummaryIntervalMinutes.ONE.
    `MetricRegistry(MetricDescriptor.SummaryIntervalMinutes defaultInterval)` Creates a new `MetricRegistry` with a metric persistence interval that should be applied to any metrics registered without their own specific interval being specified.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addListener(MetricRegistryListener listener)` Adds a `MetricRegistryListener` to a collection of listeners that will be notified upon registration of a `TimeStampedMetric`.
    `SortedMap<MetricDescriptor,TimeStampedCounter>` | `getCounters()` Returns a map of all `TimeStampedCounter`s from the registry, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedCounter>` | `getCounters(MetricFilter filter)` Returns a map of `TimeStampedCounter`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
    `MetricDescriptor.SummaryIntervalMinutes` | `getDefaultInterval()`
    `Set<MetricDescriptor>` | `getDescriptors()` Returns a set of the `MetricDescriptor`s of all the `TimeStampedMetric`s in the registry.
    `SortedMap<MetricDescriptor,TimeStampedGauge>` | `getGauges()` Returns a map of all `TimeStampedGauge`s from the registry, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedGauge>` | `getGauges(MetricFilter filter)` Returns a map of `TimeStampedGauge`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedHistogram>` | `getHistograms()` Returns a map of all `TimeStampedHistogram`s from the registry, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedHistogram>` | `getHistograms(MetricFilter filter)` Returns a map of `TimeStampedHistogram`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedMeter>` | `getMeters()` Returns a map of all `TimeStampedMeter`s from the registry, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedMeter>` | `getMeters(MetricFilter filter)` Returns a map of `TimeStampedMeter`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
    `Set<String>` | `getMetricUids()` Returns a `Set` of `UIDs` corresponding to the `TimeStampedMetric`s in the `MetricRegistry`.
    `SortedMap<MetricDescriptor,TimeStampedRatioGauge>` | `getRatioGauges()` Returns a map of all `TimeStampedRatioGauge`s from the registry, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedRatioGauge>` | `getRatioGauges(MetricFilter filter)` Returns a map of `TimeStampedRatioGauge`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedRollingCounter>` | `getRollingCounters()` Returns a map of all `TimeStampedRollingCounter`s from the registry, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedRollingCounter>` | `getRollingCounters(MetricFilter filter)` Returns a map of `TimeStampedRollingCounter`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedTimer>` | `getTimers()` Returns a map of all `TimeStampedTimer`s from the registry, along with their `MetricDescriptor`s.
    `SortedMap<MetricDescriptor,TimeStampedTimer>` | `getTimers(MetricFilter filter)` Returns a map of `TimeStampedTimer`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
    `Map<MetricDescriptor,TimeStampedMetric>` | `getTimeStampedMetrics()` Returns a copy of the `Map` used by the `MetricRegistry` to track registered `TimeStampedMetric`s.
    `Map<TimeStampedMetric,MetricRegistry.PersistTimes>` | `getTimeStamps()` Returns the `Map` used by the `MetricRegistry` to track when `TimeStampedMetric`s should be persisted.
    `TimeStampedMetric` | `register(MetricDescriptor descriptor, TimeStampedMetric metric)` Given a `TimeStampedMetric`, registers it using the provided `MetricDescriptor`.
    `void` | `registerAll(Collection<TimeStampedMetric> metrics)` Given a `Collection` of `TimeStampedMetric`s, register them.
    `boolean` | `remove(MetricDescriptor descriptor)` Unregisters the `TimeStampedMetric` corresponding to the specified `MetricDescriptor`.
    `void` | `removeListener(MetricRegistryListener listener)` Removes a `MetricRegistryListener` from this registry's collection of listeners.
    `void` | `removeMatching(MetricFilter filter)` Removes all metrics that match the given filter.
    `void` | `setDefaultInterval(MetricDescriptor.SummaryIntervalMinutes toSet)`
    `TimeStampedCounter` | `timeStampedCounter(CounterDescriptor descriptor)` Creates a new `TimeStampedCounter` and registers it using the given `CounterDescriptor`.
    `TimeStampedCounter` | `timeStampedCounter(CounterDescriptor descriptor, String uid)` Creates a new `TimeStampedCounter` and registers it with the `MetricRegistry` using the given `CounterDescriptor` and UID.
    `TimeStampedGauge` | `timeStampedGauge(GaugeDescriptor descriptor)` Creates a new `TimeStampedGauge` and registers it using the given `GaugeDescriptor`.
    `TimeStampedGauge` | `timeStampedGauge(GaugeDescriptor descriptor, String uid)` Creates a new `TimeStampedGauge` and registers it with the `MetricRegistry` using the given `GaugeDescriptor` and UID.
    `TimeStampedHistogram` | `timeStampedHistogram(HistogramDescriptor descriptor)` Creates a new `TimeStampedHistogram` and registers it using the given `HistogramDescriptor`.
    `TimeStampedHistogram` | `timeStampedHistogram(HistogramDescriptor descriptor, String uid)` Creates a new `TimeStampedHistogram` and registers it with the `MetricRegistry` using the given `HistogramDescriptor` and UID.
    `TimeStampedMeter` | `timeStampedMeter(MeterDescriptor descriptor)` Creates a new `TimeStampedMeter` and registers it using the given `MeterDescriptor`.
    `TimeStampedMeter` | `timeStampedMeter(MeterDescriptor descriptor, String uid)` Creates a new `TimeStampedMeter` and registers it with the `MetricRegistry` using the given `MeterDescriptor` and UID.
    `TimeStampedRatioGauge` | `timeStampedRatioGauge(RatioGaugeDescriptor descriptor)` Creates a new `TimeStampedRatioGauge` and registers it using the given `RatioGaugeDescriptor`.
    `TimeStampedRatioGauge` | `timeStampedRatioGauge(RatioGaugeDescriptor descriptor, String uid)` Creates a new `TimeStampedRatioGauge` and registers it with the `MetricRegistry` using the given `RatioGaugeDescriptor` and UID.
    `TimeStampedRollingCounter` | `timeStampedRollingCounter(RollingCounterDescriptor descriptor)` Creates a new `TimeStampedRollingCounter` and registers it using the given `RollingCounterDescriptor`.
    `TimeStampedRollingCounter` | `timeStampedRollingCounter(RollingCounterDescriptor descriptor, String uid)` Creates a new `TimeStampedRollingCounter` and registers it with the `MetricRegistry` using the given `RollingCounterDescriptor` and UID.
    `TimeStampedTimer` | `timeStampedTimer(TimerDescriptor descriptor)` Creates a new `TimeStampedTimer` and registers it using the given `TimerDescriptor`.
    `TimeStampedTimer` | `timeStampedTimer(TimerDescriptor descriptor, String uid)` Creates a new `TimeStampedTimer` and registers it with the `MetricRegistry` using the given `TimerDescriptor` and UID.

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

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

- - ### Constructor Detail

    - #### MetricRegistry

          public MetricRegistry()

      Creates a new `MetricRegistry` with a default metric persistence interval of SummaryIntervalMinutes.ONE.

    - #### MetricRegistry

          public MetricRegistry(MetricDescriptor.SummaryIntervalMinutes defaultInterval)

      Creates a new `MetricRegistry` with a metric persistence interval that should be applied to any metrics registered without their own specific interval being specified.

  - ### Method Detail

    - #### addListener

          public void addListener(MetricRegistryListener listener)

      Adds a `MetricRegistryListener` to a collection of listeners that will be notified upon registration of a `TimeStampedMetric`. Listeners will be notified in the order in which they are added. Also, listeners will be notified of all previously-registered `TimeStampedMetric`s when they first register.
      Parameters:
        `listener` - listener to notify

    - #### getCounters

          public SortedMap<MetricDescriptor,TimeStampedCounter> getCounters()

      Returns a map of all `TimeStampedCounter`s from the registry, along with their `MetricDescriptor`s.
      Returns:
        all registered `TimeStampedCounter`s

    - #### getCounters

          public SortedMap<MetricDescriptor,TimeStampedCounter> getCounters(MetricFilter filter)

      Returns a map of `TimeStampedCounter`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
      Parameters:
        `filter` - `MetricFilter` to match
      Returns:
        all registered `TimeStampedCounter`s that match the `MetricFilter`

    - #### getDefaultInterval

          public MetricDescriptor.SummaryIntervalMinutes getDefaultInterval()

    - #### getDescriptors

          public Set<MetricDescriptor> getDescriptors()

      Returns a set of the `MetricDescriptor`s of all the `TimeStampedMetric`s in the registry.
      Returns:
        a set of `MetricDescriptor`s for all registered `TimeStampedMetric`s

    - #### getGauges

          public SortedMap<MetricDescriptor,TimeStampedGauge> getGauges()

      Returns a map of all `TimeStampedGauge`s from the registry, along with their `MetricDescriptor`s.
      Returns:
        all registered `TimeStampedGauge`s

    - #### getGauges

          public SortedMap<MetricDescriptor,TimeStampedGauge> getGauges(MetricFilter filter)

      Returns a map of `TimeStampedGauge`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
      Parameters:
        `filter` - `MetricFilter` to match
      Returns:
        all registered `TimeStampedGauge`s that match the `MetricFilter`

    - #### getHistograms

          public SortedMap<MetricDescriptor,TimeStampedHistogram> getHistograms()

      Returns a map of all `TimeStampedHistogram`s from the registry, along with their `MetricDescriptor`s.
      Returns:
        all registered `TimeStampedHistogram`s

    - #### getHistograms

          public SortedMap<MetricDescriptor,TimeStampedHistogram> getHistograms(MetricFilter filter)

      Returns a map of `TimeStampedHistogram`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
      Parameters:
        `filter` - `MetricFilter` to match
      Returns:
        all registered `TimeStampedHistogram`s that match the `MetricFilter`

    - #### getMeters

          public SortedMap<MetricDescriptor,TimeStampedMeter> getMeters()

      Returns a map of all `TimeStampedMeter`s from the registry, along with their `MetricDescriptor`s.
      Returns:
        all registered `TimeStampedMeter`s

    - #### getMeters

          public SortedMap<MetricDescriptor,TimeStampedMeter> getMeters(MetricFilter filter)

      Returns a map of `TimeStampedMeter`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
      Parameters:
        `filter` - `MetricFilter` to match
      Returns:
        all registered `TimeStampedMeter`s that match the `MetricFilter`

    - #### getMetricUids

          public Set<String> getMetricUids()

      Returns a `Set` of `UIDs` corresponding to the `TimeStampedMetric`s in the `MetricRegistry`.
      Returns:
        a `Set` of `UIDs`

    - #### getRatioGauges

          public SortedMap<MetricDescriptor,TimeStampedRatioGauge> getRatioGauges()

      Returns a map of all `TimeStampedRatioGauge`s from the registry, along with their `MetricDescriptor`s.
      Returns:
        all registered `TimeStampedRatioGauge`s

    - #### getRatioGauges

          public SortedMap<MetricDescriptor,TimeStampedRatioGauge> getRatioGauges(MetricFilter filter)

      Returns a map of `TimeStampedRatioGauge`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
      Parameters:
        `filter` - `MetricFilter` to match
      Returns:
        all registered `TimeStampedRatioGauge`s that match the `MetricFilter`

    - #### getRollingCounters

          public SortedMap<MetricDescriptor,TimeStampedRollingCounter> getRollingCounters()

      Returns a map of all `TimeStampedRollingCounter`s from the registry, along with their `MetricDescriptor`s.
      Returns:
        all registered `TimeStampedRollingCounter`s

    - #### getRollingCounters

          public SortedMap<MetricDescriptor,TimeStampedRollingCounter> getRollingCounters(MetricFilter filter)

      Returns a map of `TimeStampedRollingCounter`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
      Parameters:
        `filter` - `MetricFilter` to match
      Returns:
        all registered `TimeStampedRollingCounter`s that match the `MetricFilter`

    - #### getTimers

          public SortedMap<MetricDescriptor,TimeStampedTimer> getTimers()

      Returns a map of all `TimeStampedTimer`s from the registry, along with their `MetricDescriptor`s.
      Returns:
        all registered `TimeStampedTimer`s

    - #### getTimers

          public SortedMap<MetricDescriptor,TimeStampedTimer> getTimers(MetricFilter filter)

      Returns a map of `TimeStampedTimer`s from the registry that match the given `MetricFilter`, along with their `MetricDescriptor`s.
      Parameters:
        `filter` - `MetricFilter` to match
      Returns:
        all registered `TimeStampedTimer`s that match the `MetricFilter`

    - #### getTimeStampedMetrics

          public Map<MetricDescriptor,TimeStampedMetric> getTimeStampedMetrics()

      Returns a copy of the `Map` used by the `MetricRegistry` to track registered `TimeStampedMetric`s.
      Returns:
        an unmodifiable `Map`

    - #### getTimeStamps

          public Map<TimeStampedMetric,MetricRegistry.PersistTimes> getTimeStamps()

      Returns the `Map` used by the `MetricRegistry` to track when `TimeStampedMetric`s should be persisted.
      Returns:
        a modifiable `Map`

    - #### register

          public TimeStampedMetric register(MetricDescriptor descriptor,
                                   TimeStampedMetric metric)
                                     throws IllegalArgumentException

      Given a `TimeStampedMetric`, registers it using the provided `MetricDescriptor`.
      Parameters:
        `descriptor` - `MetricDescriptor` for the `TimeStampedMetric`
        `metric` - `TimeStampedMetric` to register
      Returns:
        `TimeStampedMetric` that was registered
      Throws:
        `IllegalArgumentException` - if the `TimeStampedMetric` was already registered

    - #### registerAll

          public void registerAll(Collection<TimeStampedMetric> metrics)
                           throws IllegalArgumentException

      Given a `Collection` of `TimeStampedMetric`s, register them.
      Parameters:
        `metrics` - `TimeStampedMetric`s to register
      Throws:
        `IllegalArgumentException` - if any of the `TimeStampedMetric`s are already registered

    - #### remove

          public boolean remove(MetricDescriptor descriptor)

      Unregisters the `TimeStampedMetric` corresponding to the specified `MetricDescriptor`.
      Parameters:
        `descriptor` - `MetricDescriptor` for the `TimeStampedMetric` to unregister
      Returns:
        whether the `TimeStampedMetric` was removed

    - #### removeListener

          public void removeListener(MetricRegistryListener listener)

      Removes a `MetricRegistryListener` from this registry's collection of listeners.
      Parameters:
        `listener` - listener to remove

    - #### removeMatching

          public void removeMatching(MetricFilter filter)

      Removes all metrics that match the given filter.
      Parameters:
        `filter` - the `MetricFilter` to match

    - #### setDefaultInterval

          public void setDefaultInterval(MetricDescriptor.SummaryIntervalMinutes toSet)

    - #### timeStampedCounter

          public TimeStampedCounter timeStampedCounter(CounterDescriptor descriptor)

      Creates a new `TimeStampedCounter` and registers it using the given `CounterDescriptor`.
      Parameters:
        `descriptor` - `CounterDescriptor` specifying characteristics of the requested `TimeStampedCounter`
      Returns:
        new `TimeStampedCounter`

    - #### timeStampedCounter

          public TimeStampedCounter timeStampedCounter(CounterDescriptor descriptor,
                                              String uid)

      Creates a new `TimeStampedCounter` and registers it with the `MetricRegistry` using the given `CounterDescriptor` and UID.
      Parameters:
        `descriptor` - `CounterDescriptor` specifying characteristics of the requested metric
        `uid` - UID for the `TimeStampedCounter`
      Returns:
        new `TimeStampedCounter`

    - #### timeStampedGauge

          public TimeStampedGauge timeStampedGauge(GaugeDescriptor descriptor)

      Creates a new `TimeStampedGauge` and registers it using the given `GaugeDescriptor`.
      Parameters:
        `descriptor` - `GaugeDescriptor` specifying characteristics of the requested `TimeStampedGauge`
      Returns:
        new `TimeStampedGauge`

    - #### timeStampedGauge

          public TimeStampedGauge timeStampedGauge(GaugeDescriptor descriptor,
                                          String uid)

      Creates a new `TimeStampedGauge` and registers it with the `MetricRegistry` using the given `GaugeDescriptor` and UID.
      Parameters:
        `descriptor` - `GaugeDescriptor` specifying characteristics of the requested `TimeStampedGauge`
        `uid` - UID for the `TimeStampedGauge`
      Returns:
        new `TimeStampedGauge`

    - #### timeStampedHistogram

          public TimeStampedHistogram timeStampedHistogram(HistogramDescriptor descriptor)

      Creates a new `TimeStampedHistogram` and registers it using the given `HistogramDescriptor`.
      Parameters:
        `descriptor` - `HistogramDescriptor` specifying characteristics of the requested `TimeStampedHistogram`
      Returns:
        new `TimeStampedHistogram`

    - #### timeStampedHistogram

          public TimeStampedHistogram timeStampedHistogram(HistogramDescriptor descriptor,
                                                  String uid)

      Creates a new `TimeStampedHistogram` and registers it with the `MetricRegistry` using the given `HistogramDescriptor` and UID.
      Parameters:
        `descriptor` - `HistogramDescriptor` specifying characteristics of the requested `TimeStampedHistogram`
        `uid` - UID for the `TimeStampedHistogram`
      Returns:
        new `TimeStampedHistogram`

    - #### timeStampedMeter

          public TimeStampedMeter timeStampedMeter(MeterDescriptor descriptor)

      Creates a new `TimeStampedMeter` and registers it using the given `MeterDescriptor`.
      Parameters:
        `descriptor` - `MeterDescriptor` specifying characteristics of the requested `TimeStampedMeter`
      Returns:
        new `TimeStampedMeter`

    - #### timeStampedMeter

          public TimeStampedMeter timeStampedMeter(MeterDescriptor descriptor,
                                          String uid)

      Creates a new `TimeStampedMeter` and registers it with the `MetricRegistry` using the given `MeterDescriptor` and UID.
      Parameters:
        `descriptor` - `MeterDescriptor` specifying characteristics of the requested metric
        `uid` - UID for the `TimeStampedMeter`
      Returns:
        new `TimeStampedMeter`

    - #### timeStampedRatioGauge

          public TimeStampedRatioGauge timeStampedRatioGauge(RatioGaugeDescriptor descriptor)

      Creates a new `TimeStampedRatioGauge` and registers it using the given `RatioGaugeDescriptor`.
      Parameters:
        `descriptor` - `RatioGaugeDescriptor` specifying characteristics of the requested `TimeStampedRatioGauge`
      Returns:
        new `TimeStampedRatioGauge`

    - #### timeStampedRatioGauge

          public TimeStampedRatioGauge timeStampedRatioGauge(RatioGaugeDescriptor descriptor,
                                                    String uid)

      Creates a new `TimeStampedRatioGauge` and registers it with the `MetricRegistry` using the given `RatioGaugeDescriptor` and UID.
      Parameters:
        `descriptor` - `RatioGaugeDescriptor` specifying characteristics of the requested `TimeStampedRatioGauge`
        `uid` - UID for the `TimeStampedRatioGauge`
      Returns:
        new `TimeStampedRatioGauge`

    - #### timeStampedRollingCounter

          public TimeStampedRollingCounter timeStampedRollingCounter(RollingCounterDescriptor descriptor)

      Creates a new `TimeStampedRollingCounter` and registers it using the given `RollingCounterDescriptor`.
      Parameters:
        `descriptor` - `RollingCounterDescriptor` specifying characteristics of the requested `TimeStampedRollingCounter`
      Returns:
        new `TimeStampedRollingCounter`

    - #### timeStampedRollingCounter

          public TimeStampedRollingCounter timeStampedRollingCounter(RollingCounterDescriptor descriptor,
                                                            String uid)

      Creates a new `TimeStampedRollingCounter` and registers it with the `MetricRegistry` using the given `RollingCounterDescriptor` and UID.
      Parameters:
        `descriptor` - `RollingCounterDescriptor` specifying characteristics of the requested metric
        `uid` - UID for the `TimeStampedRollingCounter`
      Returns:
        new `TimeStampedRollingCounter`

    - #### timeStampedTimer

          public TimeStampedTimer timeStampedTimer(TimerDescriptor descriptor)

      Creates a new `TimeStampedTimer` and registers it using the given `TimerDescriptor`.
      Parameters:
        `descriptor` - `TimerDescriptor` specifying characteristics of the requested `TimeStampedTimer`
      Returns:
        new `TimeStampedTimer`

    - #### timeStampedTimer

          public TimeStampedTimer timeStampedTimer(TimerDescriptor descriptor,
                                          String uid)

      Creates a new `TimeStampedTimer` and registers it with the `MetricRegistry` using the given `TimerDescriptor` and UID.
      Parameters:
        `descriptor` - `TimerDescriptor` specifying characteristics of the requested metric
        `uid` - UID for the `TimeStampedTimer`
      Returns:
        new `TimeStampedTimer`

Copyright © 2014. All Rights Reserved.