com.bigdata.counters
Class HistoryInstrument<T>

java.lang.Object
  extended by com.bigdata.counters.HistoryInstrument<T>
Type Parameters:
T - Which must be Double, Long, or String.
All Implemented Interfaces:
IInstrument<T>

public class HistoryInstrument<T>
extends Object
implements IInstrument<T>

A history instrument which aggregates samples into a circular buffer with a specified sample period. Old samples are overwritten (or cleared in the case of missed samples) only as new samples arrive. The value reported for a given moment is the average of the samples which were aggregated into the same slot in the underlying History.

Version:
$Id: HistoryInstrument.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
 History<T> days
           
 History<T> hours
           
protected static org.apache.log4j.Logger log
           
 History<T> minutes
           
 
Constructor Summary
HistoryInstrument(History<T> minutes)
           
 
Method Summary
 void add(long timestamp, T value)
          Adds the sample to the history.
 History<T> getHistory()
          Return the history data.
 History<T> getHistory(PeriodEnum basePeriod)
          Return the History for the specified base period.
 T getValue()
          Return the last value.
 long lastModified()
          Return the timestamp associated with the last value.
 void setValue(T value, long timestamp)
          Adds the sample to the history.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log

minutes

public final History<T> minutes

hours

public final History<T> hours

days

public final History<T> days
Constructor Detail

HistoryInstrument

public HistoryInstrument(History<T> minutes)
Method Detail

getHistory

public History<T> getHistory()
Return the history data.


getHistory

public History<T> getHistory(PeriodEnum basePeriod)
Return the History for the specified base period.

Parameters:
basePeriod - The base period.
Returns:
The history having samples with that base period.

getValue

public T getValue()
Return the last value.

Specified by:
getValue in interface IInstrument<T>

lastModified

public long lastModified()
Return the timestamp associated with the last value.

Specified by:
lastModified in interface IInstrument<T>

add

public void add(long timestamp,
                T value)
Adds the sample to the history. Samples in the same slot are averaged.

Parameters:
timestamp - The timestamp.
value - The value of the counter as of that timestamp.

setValue

public void setValue(T value,
                     long timestamp)
Adds the sample to the history. Samples in the same slot are averaged.

Specified by:
setValue in interface IInstrument<T>
Parameters:
value - The sampled value.
timestamp - The timestamp for that sample.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.