StatisticDurationTracker (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.fs.statistics.impl, class: StatisticDurationTracker

Package org.apache.hadoop.fs.statistics.impl

# Class StatisticDurationTracker

java.lang.Object
org.apache.hadoop.util.OperationDuration
org.apache.hadoop.fs.statistics.impl.StatisticDurationTracker

All Implemented Interfaces:
  `AutoCloseable`, `DurationTracker`

public class StatisticDurationTracker extends OperationDuration implements DurationTracker
Track the duration of an object. When closed the min/max/mean statistics are updated. In the constructor, the counter with name of 'key' is incremented -default is by 1, but can be set to other values, including 0.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StatisticDurationTracker(IOStatisticsStore iostats, String key)`
  Constructor -increments the counter by 1.
  `StatisticDurationTracker(IOStatisticsStore iostats, String key, long count)`
  Constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Set the finished time and then update the statistics.
  `void`
  `failed()`
  The operation failed.
  `String`
  `toString()`
  Return the duration as `OperationDuration.humanTime(long)`.

  ### Methods inherited from class org.apache.hadoop.util.OperationDuration

  `asDuration, finished, getDurationString, humanTime, time, value`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.apache.hadoop.fs.statistics.DurationTracker

  `asDuration`

- ## Constructor Details

  - ### StatisticDurationTracker

    public StatisticDurationTracker(IOStatisticsStore iostats, String key)
    Constructor -increments the counter by 1.
    Parameters:
      `iostats` - statistics to update
      `key` - prefix of values.

  - ### StatisticDurationTracker

    public StatisticDurationTracker(IOStatisticsStore iostats, String key, long count)
    Constructor. If the supplied count is greater than zero, the counter of the key name is updated.
    Parameters:
      `iostats` - statistics to update
      `key` - Key to use as prefix of values.
      `count` - #of times to increment the matching counter.

- ## Method Details

  - ### failed

    public void failed()
    Description copied from interface: `DurationTracker`
    The operation failed. Failure statistics will be updated.
    Specified by:
      `failed` in interface `DurationTracker`

  - ### close

    public void close()
    Set the finished time and then update the statistics. If the operation failed then the key + .failures counter will be incremented by one. The operation min/mean/max values will be updated with the duration; on a failure these will all be the .failures metrics.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `DurationTracker`

  - ### toString

    public String toString()
    Description copied from class: `OperationDuration`
    Return the duration as `OperationDuration.humanTime(long)`.
    Overrides:
      `toString` in class `OperationDuration`
    Returns:
      a printable duration.