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:
  • Constructor Details

    • IOStatisticsSnapshot

      public IOStatisticsSnapshot()
      Construct.
    • IOStatisticsSnapshot

      public IOStatisticsSnapshot(IOStatistics source)
      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

      public void snapshot(IOStatistics source)
      Take a snapshot. This completely overwrites the map data with the statistics from the source.
      Parameters:
      source - statistics source.
    • aggregate

      public boolean aggregate(@Nullable IOStatistics source)
      Aggregate the current statistics with the source reference passed in. The operation is synchronized.
      Specified by:
      aggregate in interface IOStatisticsAggregator
      Parameters:
      source - source; may be null
      Returns:
      true if a merge took place.
    • counters

      public Map<String,Long> counters()
      Description copied from interface: IOStatistics
      Map of counters.
      Specified by:
      counters in interface IOStatistics
      Returns:
      the current map of counters.
    • gauges

      public Map<String,Long> gauges()
      Description copied from interface: IOStatistics
      Map of gauges.
      Specified by:
      gauges in interface IOStatistics
      Returns:
      the current map of gauges.
    • minimums

      public Map<String,Long> minimums()
      Description copied from interface: IOStatistics
      Map of minimums.
      Specified by:
      minimums in interface IOStatistics
      Returns:
      the current map of minimums.
    • maximums

      public Map<String,Long> maximums()
      Description copied from interface: IOStatistics
      Map of maximums.
      Specified by:
      maximums in interface IOStatistics
      Returns:
      the current map of maximums.
    • meanStatistics

      public Map<String,MeanStatistic> meanStatistics()
      Description copied from interface: IOStatistics
      Map of meanStatistics.
      Specified by:
      meanStatistics in interface IOStatistics
      Returns:
      the current map of MeanStatistic statistics.
    • setCounter

      public void setCounter(String key, long value)
      Description copied from interface: IOStatisticsSetters
      Set a counter. No-op if the counter is unknown.
      Specified by:
      setCounter in interface IOStatisticsSetters
      Parameters:
      key - statistics key
      value - value to set
    • setGauge

      public void setGauge(String key, long value)
      Description copied from interface: IOStatisticsSetters
      Set a gauge.
      Specified by:
      setGauge in interface IOStatisticsSetters
      Parameters:
      key - statistics key
      value - value to set
    • setMaximum

      public void setMaximum(String key, long value)
      Description copied from interface: IOStatisticsSetters
      Set a maximum.
      Specified by:
      setMaximum in interface IOStatisticsSetters
      Parameters:
      key - statistics key
      value - value to set
    • setMinimum

      public void setMinimum(String key, long value)
      Description copied from interface: IOStatisticsSetters
      Set a minimum.
      Specified by:
      setMinimum in interface IOStatisticsSetters
      Parameters:
      key - statistics key
      value - value to set
    • setMeanStatistic

      public void setMeanStatistic(String key, MeanStatistic value)
      Description copied from interface: IOStatisticsSetters
      Set a mean statistic to a given value.
      Specified by:
      setMeanStatistic in interface IOStatisticsSetters
      Parameters:
      key - statistic key
      value - new value.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • serializer

      public static org.apache.hadoop.util.JsonSerialization<IOStatisticsSnapshot> serializer()
      Get a JSON serializer for this class.
      Returns:
      a serializer.
    • requiredSerializationClasses

      public static List<Class> 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.