Top Description Fields Constructors Methods
net.sf.ehcache.util.counter.sampled

public Class SampledCounterImpl

extends CounterImpl
implements SampledCounter
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.util.counter.sampled.SampledCounter, net.sf.ehcache.util.counter.Counter
Known Direct Subclasses
net.sf.ehcache.util.counter.sampled.SampledRateCounterImpl
Imports
java.util.TimerTask, net.sf.ehcache.util.CircularLossyQueue, net.sf.ehcache.util.counter.CounterImpl

An implementation of SampledCounter
Author
Abhishek Sanoujam
Since
1.7

Field Summary

Modifier and TypeField and Description
protected final CircularLossyQueue<TimeStampedCounterValue>
history

The history of this counter

private final long
private static final int
protected final boolean
resetOnSample

Should the counter reset on each sample?

private final TimerTask

Constructor Summary

AccessConstructor and Description
public
SampledCounterImpl(SampledCounterConfig config)

todo GL how many threads is this creating?

public
SampledCounterImpl(long
sampling interval in seconds
intervalInSeconds
,
int
size of history sample
historySize
,
boolean
true to reset value on sample
resetOnSample
,
long
initial value
initValue
,
boolean
true to record smaple immediately
sampleNow
)

Constructor accepting raw config values.

Method Summary

Modifier and TypeMethod and Description
public TimeStampedCounterValue[]
public long
getAndReset()

Implements net.sf.ehcache.util.counter.sampled.SampledCounter.getAndReset.

Returns the current value of the counter and resets it to 0
public long

Returns:

the sampling thread interval in millis
getIntervalMillis
()

Returns the sampling thread interval in millis

public TimeStampedCounterValue
public TimerTask

Returns:

the timer task for this sampled counter
getTimerTask
()

Returns the timer task for this sampled counter

pack-priv void
public void
Inherited from net.sf.ehcache.util.counter.CounterImpl:
decrementdecrementgetAndSetgetValueincrementincrementsetValue

Field Detail

historyback to summary
protected final CircularLossyQueue<TimeStampedCounterValue> history

The history of this counter

intervalMillisback to summary
private final long intervalMillis
MILLIS_PER_SECback to summary
private static final int MILLIS_PER_SEC
resetOnSampleback to summary
protected final boolean resetOnSample

Should the counter reset on each sample?

samplerTaskback to summary
private final TimerTask samplerTask

Constructor Detail

SampledCounterImplback to summary
public SampledCounterImpl(SampledCounterConfig config)

todo GL how many threads is this creating? Constructor accepting a SampledCounterConfig

SampledCounterImplback to summary
public SampledCounterImpl(long intervalInSeconds, int historySize, boolean resetOnSample, long initValue, boolean sampleNow)

Constructor accepting raw config values.

Parameters
intervalInSeconds:long

sampling interval in seconds

historySize:int

size of history sample

resetOnSample:boolean

true to reset value on sample

initValue:long

initial value

sampleNow:boolean

true to record smaple immediately

Method Detail

getAllSampleValuesback to summary
public TimeStampedCounterValue[] getAllSampleValues()

Implements net.sf.ehcache.util.counter.sampled.SampledCounter.getAllSampleValues.

Doc from net.sf.ehcache.util.counter.sampled.SampledCounter.getAllSampleValues.

Returns all samples in history

Returns:TimeStampedCounterValue[]

An array containing the TimeStampedCounterValue's

getAndResetback to summary
public long getAndReset()

Implements net.sf.ehcache.util.counter.sampled.SampledCounter.getAndReset.

Doc from net.sf.ehcache.util.counter.sampled.SampledCounter.getAndReset.

Returns the current value of the counter and resets it to 0

Returns:long

current value of the counter

getIntervalMillisback to summary
public long getIntervalMillis()

Returns the sampling thread interval in millis

Returns:long

the sampling thread interval in millis

getMostRecentSampleback to summary
public TimeStampedCounterValue getMostRecentSample()

Implements net.sf.ehcache.util.counter.sampled.SampledCounter.getMostRecentSample.

Doc from net.sf.ehcache.util.counter.sampled.SampledCounter.getMostRecentSample.

Returns the most recent sampled value

Returns:TimeStampedCounterValue

Value of the most recent sampled value

getTimerTaskback to summary
public TimerTask getTimerTask()

Returns the timer task for this sampled counter

Returns:TimerTask

the timer task for this sampled counter

recordSampleback to summary
pack-priv void recordSample()
shutdownback to summary
public void shutdown()

Implements net.sf.ehcache.util.counter.sampled.SampledCounter.shutdown.

Doc from net.sf.ehcache.util.counter.sampled.SampledCounter.shutdown.

Shutdown this counter