Package org.apache.hadoop.fs.statistics
Class IOStatisticsSnapshot
java.lang.Object
org.apache.hadoop.fs.statistics.IOStatisticsSnapshot
- All Implemented Interfaces:
Serializable,IOStatistics,IOStatisticsAggregator,IOStatisticsSetters
@Public
@Evolving
public final class IOStatisticsSnapshot
extends Object
implements IOStatistics, Serializable, IOStatisticsAggregator, IOStatisticsSetters
Snapshot of statistics from a different source.
It is serializable so that frameworks which can use java serialization
to propagate data (Spark, Flink...) can send the statistics
back. For this reason, TreeMaps are explicitly used as field types,
even though IDEs can recommend use of Map instead.
For security reasons, untrusted java object streams should never be
deserialized. If for some reason this is required, use
requiredSerializationClasses() to get the list of classes
used when deserializing instances of this object.
It is annotated for correct serializations with jackson2.
- See Also:
-
Field Summary
Fields inherited from interface org.apache.hadoop.fs.statistics.IOStatistics
MAX_UNSET_VALUE, MIN_UNSET_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionConstruct.IOStatisticsSnapshot(IOStatistics source) Construct, taking a snapshot of the source statistics data if the source is non-null. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaggregate(IOStatistics source) Aggregate the current statistics with the source reference passed in.voidclear()Clear all the maps.counters()Map of counters.gauges()Map of gauges.maximums()Map of maximums.Map of meanStatistics.minimums()Map of minimums.What classes are needed to deserialize this class?static org.apache.hadoop.util.JsonSerialization<IOStatisticsSnapshot>Get a JSON serializer for this class.voidsetCounter(String key, long value) Set a counter.voidSet a gauge.voidsetMaximum(String key, long value) Set a maximum.voidsetMeanStatistic(String key, MeanStatistic value) Set a mean statistic to a given value.voidsetMinimum(String key, long value) Set a minimum.voidsnapshot(IOStatistics source) Take a snapshot.toString()
-
Constructor Details
-
IOStatisticsSnapshot
public IOStatisticsSnapshot()Construct. -
IOStatisticsSnapshot
Construct, taking a snapshot of the source statistics data if the source is non-null. If the source is null, the empty maps are created- Parameters:
source- statistics source. Nullable.
-
-
Method Details
-
clear
public void clear()Clear all the maps. -
snapshot
Take a snapshot. This completely overwrites the map data with the statistics from the source.- Parameters:
source- statistics source.
-
aggregate
Aggregate the current statistics with the source reference passed in. The operation is synchronized.- Specified by:
aggregatein interfaceIOStatisticsAggregator- Parameters:
source- source; may be null- Returns:
- true if a merge took place.
-
counters
Description copied from interface:IOStatisticsMap of counters.- Specified by:
countersin interfaceIOStatistics- Returns:
- the current map of counters.
-
gauges
Description copied from interface:IOStatisticsMap of gauges.- Specified by:
gaugesin interfaceIOStatistics- Returns:
- the current map of gauges.
-
minimums
Description copied from interface:IOStatisticsMap of minimums.- Specified by:
minimumsin interfaceIOStatistics- Returns:
- the current map of minimums.
-
maximums
Description copied from interface:IOStatisticsMap of maximums.- Specified by:
maximumsin interfaceIOStatistics- Returns:
- the current map of maximums.
-
meanStatistics
Description copied from interface:IOStatisticsMap of meanStatistics.- Specified by:
meanStatisticsin interfaceIOStatistics- Returns:
- the current map of MeanStatistic statistics.
-
setCounter
Description copied from interface:IOStatisticsSettersSet a counter. No-op if the counter is unknown.- Specified by:
setCounterin interfaceIOStatisticsSetters- Parameters:
key- statistics keyvalue- value to set
-
setGauge
Description copied from interface:IOStatisticsSettersSet a gauge.- Specified by:
setGaugein interfaceIOStatisticsSetters- Parameters:
key- statistics keyvalue- value to set
-
setMaximum
Description copied from interface:IOStatisticsSettersSet a maximum.- Specified by:
setMaximumin interfaceIOStatisticsSetters- Parameters:
key- statistics keyvalue- value to set
-
setMinimum
Description copied from interface:IOStatisticsSettersSet a minimum.- Specified by:
setMinimumin interfaceIOStatisticsSetters- Parameters:
key- statistics keyvalue- value to set
-
setMeanStatistic
Description copied from interface:IOStatisticsSettersSet a mean statistic to a given value.- Specified by:
setMeanStatisticin interfaceIOStatisticsSetters- Parameters:
key- statistic keyvalue- new value.
-
toString
-
serializer
Get a JSON serializer for this class.- Returns:
- a serializer.
-
requiredSerializationClasses
What classes are needed to deserialize this class? Needed to securely unmarshall this from untrusted sources.- Returns:
- a list of required classes to deserialize the data.
-