public abstract class SampledStat extends Object implements MeasurableStat
All the samples are combined to produce the measurement. When a window is complete the oldest sample is cleared and recycled to begin recording the next sample. Subclasses of this class define different statistics measured using this basic pattern.
Modifier and Type | Class and Description |
---|---|
protected static class |
SampledStat.Sample |
Modifier and Type | Field and Description |
---|---|
protected List<SampledStat.Sample> |
samples |
Constructor and Description |
---|
SampledStat(double initialValue) |
Modifier and Type | Method and Description |
---|---|
abstract double |
combine(List<SampledStat.Sample> samples,
MetricConfig config,
long now) |
SampledStat.Sample |
current(long timeMs) |
double |
measure(MetricConfig config,
long now)
Measure this quantity and return the result as a double
|
protected SampledStat.Sample |
newSample(long timeMs) |
SampledStat.Sample |
oldest(long now) |
protected void |
purgeObsoleteSamples(MetricConfig config,
long now) |
void |
record(MetricConfig config,
double value,
long timeMs)
Record the given value
|
String |
toString() |
protected abstract void |
update(SampledStat.Sample sample,
MetricConfig config,
double value,
long timeMs) |
protected List<SampledStat.Sample> samples
public void record(MetricConfig config, double value, long timeMs)
Stat
protected SampledStat.Sample newSample(long timeMs)
public double measure(MetricConfig config, long now)
Measurable
measure
in interface Measurable
config
- The configuration for this metricnow
- The POSIX time in milliseconds the measurement is being takenpublic SampledStat.Sample current(long timeMs)
public SampledStat.Sample oldest(long now)
protected abstract void update(SampledStat.Sample sample, MetricConfig config, double value, long timeMs)
public abstract double combine(List<SampledStat.Sample> samples, MetricConfig config, long now)
protected void purgeObsoleteSamples(MetricConfig config, long now)