com.h3c.sdn.metric

## Class TimeStampedTimer

- java.lang.Object
- - com.codahale.metrics.Timer
  - - com.h3c.sdn.metric.TimeStampedTimer

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

      public class TimeStampedTimer
      extends com.codahale.metrics.Timer
      implements TimeStampedMetric

  Extension of Coda Hale `Timer` class that provides an association of sliding time window `Timer` values with time stamps.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.codahale.metrics.Timer

      `com.codahale.metrics.Timer.Context`

  - ### Constructor Summary

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `TimerDataPoint` | `extractDataPoint()` Extract a `TimerDataPoint` from this object.
    `double` | `get75thPercentile()` Gets the duration, in milliseconds, at the 75th percentile of all durations currently encompassed within the the sliding time window of this `TimeStampedTimer`.
    `double` | `get95thPercentile()` Gets the duration, in milliseconds, at the 95th percentile of all durations currently encompassed within the the sliding time window of this `TimeStampedTimer`.
    `double` | `get98thPercentile()` Gets the duration, in milliseconds, at the 98th percentile of all durations currently encompassed within the the sliding time window of this `TimeStampedTimer`.
    `double` | `get99thPercentile()` Gets the duration, in milliseconds, at the 99th percentile of all durations currently encompassed within the the sliding time window of this `TimeStampedTimer`.
    `long` | `getCount()`
    `TimerDescriptor` | `getDescriptor()` Gets the `MetricDescriptor` that describes this `TimeStampedMetric` object.
    `long` | `getMaximum()` Gets the maximum, in milliseconds, of all durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
    `double` | `getMean()` Gets the mean, in milliseconds, of the durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
    `double` | `getMedian()` Gets the median, in milliseconds, of all durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
    `long` | `getMinimum()` Gets the minimum, in milliseconds, of all durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
    `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` | `getPreviousTimeStamp()` Gets the previous time stamp.
    `double` | `getRate()` Gets the rate of durations for the timer.
    `int` | `getSlidingWindowMinutes()` Gets the number of minutes spanned by the sliding time window of this `TimeStampedTimer`.
    `double` | `getStandardDeviation()` Gets the standard deviation, in milliseconds, of the durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
    `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.
    `long[]` | `getValues()` Gets the actual millisecond durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
    `void` | `reset()` Prepares the timer for use in a new time period.
    `void` | `setDescriptor(TimerDescriptor toSet)` Sets the `TimerDescriptor` that specifies characteristics of this `TimeStampedTimer`.
    `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.
    `<T> T` | `time(Callable<T> event)`
    `String` | `toDebugString()` Gets a detailed representation of this object to facilitate debugging.
    `String` | `toString()`
    `void` | `update(int durationMs)` Adds a duration.
    `void` | `update(long durationMs)` Adds a duration.
    `void` | `updateTimeStamp()` Convenience method that sets the update time stamp to the current time.

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

      `getFifteenMinuteRate, getFiveMinuteRate, getMeanRate, getOneMinuteRate, getSnapshot, time, update`

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

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

- - ### Constructor Detail

    - #### TimeStampedTimer

          public TimeStampedTimer(MetricRegistry registry,
                          TimerDescriptor descriptor)

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

    - #### TimeStampedTimer

          public TimeStampedTimer(MetricRegistry registry,
                          TimerDescriptor descriptor,
                          String uid)

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

  - ### Method Detail

    - #### extractDataPoint

          public TimerDataPoint extractDataPoint()

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

    - #### get75thPercentile

          public double get75thPercentile()

      Gets the duration, in milliseconds, at the 75th percentile of all durations currently encompassed within the the sliding time window of this `TimeStampedTimer`.
      Returns:
        millisecond duration at 75th percentile

    - #### get95thPercentile

          public double get95thPercentile()

      Gets the duration, in milliseconds, at the 95th percentile of all durations currently encompassed within the the sliding time window of this `TimeStampedTimer`.
      Returns:
        millisecond duration at 95th percentile

    - #### get98thPercentile

          public double get98thPercentile()

      Gets the duration, in milliseconds, at the 98th percentile of all durations currently encompassed within the the sliding time window of this `TimeStampedTimer`.
      Returns:
        millisecond duration at 98th percentile

    - #### get99thPercentile

          public double get99thPercentile()

      Gets the duration, in milliseconds, at the 99th percentile of all durations currently encompassed within the the sliding time window of this `TimeStampedTimer`.
      Returns:
        millisecond duration at 99th percentile

    - #### getCount

          public long getCount()

      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.Timer`

    - #### getDescriptor

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

    - #### getMaximum

          public long getMaximum()

      Gets the maximum, in milliseconds, of all durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
      Returns:
        maximum of timer millisecond durations

    - #### getMean

          public double getMean()

      Gets the mean, in milliseconds, of the durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
      Returns:
        mean of timer millisecond durations

    - #### getMedian

          public double getMedian()

      Gets the median, in milliseconds, of all durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
      Returns:
        median millisecond duration (value at 50th percentile)

    - #### getMinimum

          public long getMinimum()

      Gets the minimum, in milliseconds, of all durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
      Returns:
        minimum of timer millisecond durations

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

    - #### getRate

          public double getRate()

      Gets the rate of durations for the timer. The rate returned is extracted from the Coda Hale base class depending upon the summary interval in minutes being applied to this `TimeStampedTimer`.
      Returns:
        duration rate corresponding to summary interval in minutes

    - #### getSlidingWindowMinutes

          public int getSlidingWindowMinutes()

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

    - #### getStandardDeviation

          public double getStandardDeviation()

      Gets the standard deviation, in milliseconds, of the durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
      Returns:
        standard deviation of timer millisecond durations

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

    - #### getValues

          public long[] getValues()

      Gets the actual millisecond durations currently encompassed within the sliding time window of this `TimeStampedTimer`.
      Returns:
        timer millisecond durations

    - #### reset

          public void reset()

      Prepares the timer for use in a new time period. There is no way to clear the timer, 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(TimerDescriptor toSet)

      Sets the `TimerDescriptor` that specifies characteristics of this `TimeStampedTimer`.
      Parameters:
        `toSet` - the `TimerDescriptor` 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

    - #### time

          public <T> T time(Callable<T> event)
                 throws Exception

      Overrides:
        `time` in class `com.codahale.metrics.Timer`
      Throws:
        `Exception`

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

    - #### update

          public void update(int durationMs)

      Adds a duration.
      Parameters:
        `durationMs` - the duration in milliseconds

    - #### update

          public void update(long durationMs)

      Adds a duration.
      Parameters:
        `durationMs` - the duration in milliseconds

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