com.h3c.sdn.metric

## Class TimeStampedMeter

- java.lang.Object
- - com.codahale.metrics.Meter
  - - com.h3c.sdn.metric.TimeStampedMeter

- All Implemented Interfaces:
    com.codahale.metrics.Counting, com.codahale.metrics.Metered, com.codahale.metrics.Metric, TimeStampedMetric

      public class TimeStampedMeter
      extends com.codahale.metrics.Meter
      implements TimeStampedMetric

  Extension of Coda Hale `Meter` class that provides an association of the `Meter` value with time stamps.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimeStampedMeter(MetricRegistry registry, MeterDescriptor descriptor)` Constructs a `TimeStampedMeter` with the specified characteristics using the specified `MetricRegistry`.
    `TimeStampedMeter(MetricRegistry registry, MeterDescriptor descriptor, String uid)` Constructs a `TimeStampedMeter` with the specified UID and other characteristics using the specified `MetricRegistry`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `MeterDataPoint` | `extractDataPoint()` Extract a `MeterDataPoint` from this object.
    `long` | `getCount()` Computes and returns the delta between the current and previous counts, producing the count for the current time period.
    `MeterDescriptor` | `getDescriptor()` Gets the `MetricDescriptor` that describes this `TimeStampedMetric` object.
    `long` | `getMsSpanned()` Determines the number of milliseconds spanned between the latest (update) time stamp and the oldest (previous) time stamp, accounting for roll-over of the time stamp.
    `long` | `getPreviousCount()` Gets the previous count for the rolling counter.
    `long` | `getPreviousTimeStamp()` Gets the previous time stamp.
    `double` | `getRate()` Gets the rate of marked events for the meter.
    `int` | `getSlidingWindowMinutes()` Gets the number of minutes spanned by the sliding time window of this `TimeStampedMeter`.
    `protected TimeStampManager` | `getTimeStampManager()` Gets the `TimeStampManager` that this object uses to manage its associated time stamps.
    `String` | `getUid()` Gets the UID.
    `long` | `getUpdateTimeStamp()` Gets the update time stamp.
    `void` | `mark(long events)`
    `void` | `reset()` Prepares the meter for use in a new time period.
    `void` | `setDescriptor(MeterDescriptor toSet)` Sets the `MeterDescriptor` that specifies characteristics of this `TimeStampedMeter`.
    `void` | `setPreviousTimeStamp(long time)` Sets the previous time stamp.
    `void` | `setUid(String toSet)` Sets the UID of this object.
    `void` | `setUpdateTimeStamp(long time)` Sets the update time stamp.
    `String` | `toDebugString()` Gets a detailed representation of this object to facilitate debugging.
    `String` | `toString()`
    `void` | `updateTimeStamp()` Convenience method that sets the update time stamp to the current time.

    - ### Methods inherited from class com.codahale.metrics.Meter

      `getFifteenMinuteRate, getFiveMinuteRate, getMeanRate, getOneMinuteRate, mark`

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

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

- - ### Constructor Detail

    - #### TimeStampedMeter

          public TimeStampedMeter(MetricRegistry registry,
                          MeterDescriptor descriptor)

      Constructs a `TimeStampedMeter` with the specified characteristics using the specified `MetricRegistry`.
      Parameters:
        `registry` - `MetricRegistry` to use for allocating this object
        `descriptor` - `MeterDescriptor` that specifies various characteristics of the resulting `TimeStampedMeter`

    - #### TimeStampedMeter

          public TimeStampedMeter(MetricRegistry registry,
                          MeterDescriptor descriptor,
                          String uid)

      Constructs a `TimeStampedMeter` with the specified UID and other characteristics using the specified `MetricRegistry`.
      Parameters:
        `registry` - `MetricRegistry` to use for allocating this object
        `descriptor` - `MeterDescriptor` that specifies various characteristics of the resulting `TimeStampedMeter`
        `uid` - UID to assign to the resulting `TimeStampedMeter`
      Throws:
        `IllegalArgumentException` - if a null value is supplied for either the `MeterDescriptor` or `MetricRegistry` argument

  - ### Method Detail

    - #### extractDataPoint

          public MeterDataPoint extractDataPoint()

      Extract a `MeterDataPoint` from this object.
      Specified by:
        `extractDataPoint` in interface `TimeStampedMetric`
      Returns:
        the current value of this object represented as a `MeterDataPoint`

    - #### getCount

          public long getCount()

      Computes and returns the delta between the current and previous counts, producing the count for the current time period.
      Specified by:
        `getCount` in interface `com.codahale.metrics.Counting`
      Specified by:
        `getCount` in interface `com.codahale.metrics.Metered`
      Overrides:
        `getCount` in class `com.codahale.metrics.Meter`
      Returns:
        count

    - #### getDescriptor

          public MeterDescriptor getDescriptor()

      Description copied from interface: `TimeStampedMetric`
      Gets the `MetricDescriptor` that describes this `TimeStampedMetric` object.
      Specified by:
        `getDescriptor` in interface `TimeStampedMetric`
      Returns:
        `MetricDescriptor` that describes this `TimeStampedMetric`

    - #### getMsSpanned

          public long getMsSpanned()

      Description copied from interface: `TimeStampedMetric`
      Determines the number of milliseconds spanned between the latest (update) time stamp and the oldest (previous) time stamp, accounting for roll-over of the time stamp.
      Specified by:
        `getMsSpanned` in interface `TimeStampedMetric`
      Returns:
        milliseconds spanned between the update and previous time stamps

    - #### getPreviousCount

          public long getPreviousCount()

      Gets the previous count for the rolling counter.
      Returns:
        previous count

    - #### getPreviousTimeStamp

          public long getPreviousTimeStamp()

      Description copied from interface: `TimeStampedMetric`
      Gets the previous time stamp.
      Specified by:
        `getPreviousTimeStamp` in interface `TimeStampedMetric`
      Returns:
        previous time stamp

    - #### getRate

          public double getRate()

      Gets the rate of marked events for the meter. The rate returned is extracted from the Coda Hale base class depending upon the summary interval in minutes being applied to this `TimeStampedMeter`.
      Returns:
        marked event rate corresponding to summary interval in minutes

    - #### getSlidingWindowMinutes

          public int getSlidingWindowMinutes()

      Gets the number of minutes spanned by the sliding time window of this `TimeStampedMeter`.
      Returns:
        minutes in sliding window

    - #### getTimeStampManager

          protected TimeStampManager getTimeStampManager()

      Gets the `TimeStampManager` that this object uses to manage its associated time stamps.
      Returns:
        the `TimeStampManager` for this object

    - #### getUid

          public String getUid()

      Description copied from interface: `TimeStampedMetric`
      Gets the UID.
      Specified by:
        `getUid` in interface `TimeStampedMetric`
      Returns:
        the UID

    - #### getUpdateTimeStamp

          public long getUpdateTimeStamp()

      Description copied from interface: `TimeStampedMetric`
      Gets the update time stamp.
      Specified by:
        `getUpdateTimeStamp` in interface `TimeStampedMetric`
      Returns:
        update time stamp

    - #### mark

          public void mark(long events)

      Overrides:
        `mark` in class `com.codahale.metrics.Meter`

    - #### reset

          public void reset()

      Prepares the meter for use in a new time period. There is no way to clear the meter, so just reset the span of time it will cover when it is next analyzed as starting at the current time. Set both the update and previous time stamps to the current time.
      Specified by:
        `reset` in interface `TimeStampedMetric`

    - #### setDescriptor

          public void setDescriptor(MeterDescriptor toSet)

      Sets the `MeterDescriptor` that specifies characteristics of this `TimeStampedMeter`.
      Parameters:
        `toSet` - the `MeterDescriptor` for this object

    - #### setPreviousTimeStamp

          public void setPreviousTimeStamp(long time)

      Description copied from interface: `TimeStampedMetric`
      Sets the previous time stamp.
      Specified by:
        `setPreviousTimeStamp` in interface `TimeStampedMetric`
      Parameters:
        `time` - previous time stamp

    - #### setUid

          public void setUid(String toSet)

      Description copied from interface: `TimeStampedMetric`
      Sets the UID of this object.
      Specified by:
        `setUid` in interface `TimeStampedMetric`
      Parameters:
        `toSet` - new UID for this object

    - #### setUpdateTimeStamp

          public void setUpdateTimeStamp(long time)

      Description copied from interface: `TimeStampedMetric`
      Sets the update time stamp.
      Specified by:
        `setUpdateTimeStamp` in interface `TimeStampedMetric`
      Parameters:
        `time` - update time stamp

    - #### toDebugString

          public String toDebugString()

      Gets a detailed representation of this object to facilitate debugging.
      Returns:
        debug representation of object

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### updateTimeStamp

          public void updateTimeStamp()

      Description copied from interface: `TimeStampedMetric`
      Convenience method that sets the update time stamp to the current time.
      Specified by:
        `updateTimeStamp` in interface `TimeStampedMetric`

Copyright © 2014. All Rights Reserved.