com.twitter.common.stats
Class MovingWindowDelta<T extends Number>

java.lang.Object
  extended by com.twitter.common.stats.StatImpl<T>
      extended by com.twitter.common.stats.SampledStat<Long>
          extended by com.twitter.common.stats.MovingWindowDelta<T>
All Implemented Interfaces:
Stat<Long>

public class MovingWindowDelta<T extends Number>
extends SampledStat<Long>

Delta over the most recent k sample periods. If you use this class with a counter, you can get the cumulation of counts in a sliding window. One sample period is the time in between doSample() calls.


Method Summary
 Long doSample()
           
static
<T extends Number>
MovingWindowDelta<T>
of(String name, Supplier<T> inputAccessor)
          Create a new MovingWindowDelta instance using the default window size (currently 60).
static
<T extends Number>
MovingWindowDelta<T>
of(String name, Supplier<T> inputAccessor, int windowSize)
          Create a new MovingWindowDelta instance.
 
Methods inherited from class com.twitter.common.stats.SampledStat
read, sample
 
Methods inherited from class com.twitter.common.stats.StatImpl
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.twitter.common.stats.Stat
getName
 

Method Detail

of

public static <T extends Number> MovingWindowDelta<T> of(String name,
                                                         Supplier<T> inputAccessor,
                                                         int windowSize)
Create a new MovingWindowDelta instance.

Type Parameters:
T - The type of the value.
Parameters:
name - The name of the value to be tracked.
inputAccessor - The accessor of the value.
windowSize - How many sample periods shall we use to calculate delta.
Returns:
The created MovingWindowSum instance.

of

public static <T extends Number> MovingWindowDelta<T> of(String name,
                                                         Supplier<T> inputAccessor)
Create a new MovingWindowDelta instance using the default window size (currently 60).

Type Parameters:
T - The type of the value.
Parameters:
name - The name of the value to be tracked.
inputAccessor - The accessor of the value.
Returns:
The created MovingWindowSum instance.

doSample

public Long doSample()
Specified by:
doSample in class SampledStat<Long>