com.h3c.sdn.metric

## Class TimeStampedRollingCounter

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

- All Implemented Interfaces:
    TimeStampedMetric

      public class TimeStampedRollingCounter
      extends Object
      implements TimeStampedMetric

  A rolling (asymptotically increasing) counter metric whose value is computed as a delta between 64-bit counter snapshots over a period of time.

- - ### Constructor Summary

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `RollingCounterDataPoint` | `extractDataPoint()` Extract a `RollingCounterDataPoint` from this object.
    `long` | `getDelta()` Computes and returns the delta between the latest and previous value snapshots.
    `RollingCounterDescriptor` | `getDescriptor()` Gets the `MetricDescriptor` that describes this `TimeStampedMetric` object.
    `long` | `getLatestSnapshot()` Gets the latest value snapshot for the rolling counter.
    `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` | `getPreviousSnapshot()` Gets the previous value snapshot for the rolling counter.
    `long` | `getPreviousTimeStamp()` Gets the previous time stamp.
    `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` | `reset()` Prepares the rolling counter for use in a new time period by saving the most recent value snapshot as the previous snapshot, and saving the most recent time stamp as the previous time stamp.
    `void` | `setDescriptor(RollingCounterDescriptor toSet)` Sets the `RollingCounterDescriptor` that specifies characteristics of this `TimeStampedRollingCounter`.
    `void` | `setLatestSnapshot(long toSet)` Sets the latest value snapshot for the rolling counter.
    `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 java.lang.Object

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

- - ### Constructor Detail

    - #### TimeStampedRollingCounter

          public TimeStampedRollingCounter(MetricRegistry registry,
                                   RollingCounterDescriptor descriptor)

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

    - #### TimeStampedRollingCounter

          public TimeStampedRollingCounter(MetricRegistry registry,
                                   RollingCounterDescriptor descriptor,
                                   String uid)

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

  - ### Method Detail

    - #### extractDataPoint

          public RollingCounterDataPoint extractDataPoint()

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

    - #### getDelta

          public long getDelta()

      Computes and returns the delta between the latest and previous value snapshots.
      Returns:
        delta

    - #### getDescriptor

          public RollingCounterDescriptor 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`

    - #### getLatestSnapshot

          public long getLatestSnapshot()

      Gets the latest value snapshot for the rolling counter.
      Returns:
        latest snapshot

    - #### 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

    - #### getPreviousTimeStamp

          public long getPreviousTimeStamp()

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

    - #### getPreviousSnapshot

          public long getPreviousSnapshot()

      Gets the previous value snapshot for the rolling counter.
      Returns:
        previous snapshot

    - #### 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

    - #### reset

          public void reset()

      Prepares the rolling counter for use in a new time period by saving the most recent value snapshot as the previous snapshot, and saving the most recent time stamp as the previous time stamp.
      Specified by:
        `reset` in interface `TimeStampedMetric`

    - #### setDescriptor

          public void setDescriptor(RollingCounterDescriptor toSet)

      Sets the `RollingCounterDescriptor` that specifies characteristics of this `TimeStampedRollingCounter`.
      Parameters:
        `toSet` - the `RollingCounterDescriptor` for this object

    - #### setLatestSnapshot

          public void setLatestSnapshot(long toSet)

      Sets the latest value snapshot for the rolling counter.
      Parameters:
        `toSet` - latest snapshot

    - #### 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.