Package org.apache.hadoop.metrics2.lib
Class MutableStat
java.lang.Object
org.apache.hadoop.metrics2.lib.MutableMetric
org.apache.hadoop.metrics2.lib.MutableStat
- Direct Known Subclasses:
MutableRate
A mutable metric with stats.
Useful for keeping throughput/latency stats.
-
Constructor Summary
ConstructorsConstructorDescriptionMutableStat(String name, String description, String sampleName, String valueName) Construct a snapshot stat metric with extended stat off by defaultMutableStat(String name, String description, String sampleName, String valueName, boolean extended) Construct a sample statistics metric -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(long value) Add a snapshot to the metric.voidadd(long numSamples, long sum) Add a number of samples and their sum to the running stat Note that although use of this method will preserve accurate mean values, large values for numSamples may result in inaccurate variance values due to the use of a single step of the Welford method for variance calculation.longorg.apache.hadoop.metrics2.util.SampleStatlastStat()Return a SampleStat object that supports calls like StdDev and Mean.voidReset the all time min max of the metricvoidsetExtended(boolean extended) Set whether to display the extended stats (stdev, min/max etc.) or notvoidsetUpdateTimeStamp(boolean updateTimeStamp) Set whether to update the snapshot time or not.voidsnapshot(MetricsRecordBuilder builder, boolean all) Get a snapshot of the metrictoString()Methods inherited from class org.apache.hadoop.metrics2.lib.MutableMetric
changed, clearChanged, setChanged, snapshot
-
Constructor Details
-
MutableStat
public MutableStat(String name, String description, String sampleName, String valueName, boolean extended) Construct a sample statistics metric- Parameters:
name- of the metricdescription- of the metricsampleName- of the metric (e.g. "Ops")valueName- of the metric (e.g. "Time", "Latency")extended- create extended stats (stdev, min/max etc.) by default.
-
MutableStat
Construct a snapshot stat metric with extended stat off by default- Parameters:
name- of the metricdescription- of the metricsampleName- of the metric (e.g. "Ops")valueName- of the metric (e.g. "Time", "Latency")
-
-
Method Details
-
setExtended
public void setExtended(boolean extended) Set whether to display the extended stats (stdev, min/max etc.) or not- Parameters:
extended- enable/disable displaying extended stats
-
setUpdateTimeStamp
public void setUpdateTimeStamp(boolean updateTimeStamp) Set whether to update the snapshot time or not.- Parameters:
updateTimeStamp- enable update stats snapshot timestamp
-
add
public void add(long numSamples, long sum) Add a number of samples and their sum to the running stat Note that although use of this method will preserve accurate mean values, large values for numSamples may result in inaccurate variance values due to the use of a single step of the Welford method for variance calculation.- Parameters:
numSamples- number of samplessum- of the samples
-
add
public void add(long value) Add a snapshot to the metric.- Parameters:
value- of the metric
-
snapshot
Description copied from class:MutableMetricGet a snapshot of the metric- Specified by:
snapshotin classMutableMetric- Parameters:
builder- the metrics record builderall- if true, snapshot unchanged metrics as well
-
lastStat
public org.apache.hadoop.metrics2.util.SampleStat lastStat()Return a SampleStat object that supports calls like StdDev and Mean.- Returns:
- SampleStat
-
resetMinMax
public void resetMinMax()Reset the all time min max of the metric -
getSnapshotTimeStamp
public long getSnapshotTimeStamp()- Returns:
- Return the SampleStat snapshot timestamp.
-
toString
-