IOStatisticsContext (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.fs.statistics, interface: IOStatisticsContext

Package org.apache.hadoop.fs.statistics

# Interface IOStatisticsContext

All Superinterfaces:
  `IOStatisticsSource`

All Known Implementing Classes:
  `IOStatisticsContextImpl`

public interface IOStatisticsContext extends IOStatisticsSource
An interface defined to capture thread-level IOStatistics by using per thread context.

The aggregator should be collected in their constructor by statistics-generating classes to obtain the aggregator to update across all threads.

The `snapshot()` call creates a snapshot of the statistics;

The `reset()` call resets the statistics in the context so that later snapshots will get the incremental data.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `enabled()`
  Static probe to check if the thread-level IO statistics enabled.
  `IOStatisticsAggregator`
  `getAggregator()`
  Get the IOStatisticsAggregator for the context.
  `static IOStatisticsContext`
  `getCurrentIOStatisticsContext()`
  Get the context's IOStatisticsContext.
  `long`
  `getID()`
  Get a unique ID for this context, for logging purposes.
  `void`
  `reset()`
  Reset the context's IOStatistics.
  `static void`
  `setThreadIOStatisticsContext(IOStatisticsContext statisticsContext)`
  Set the IOStatisticsContext for the current thread.
  `IOStatisticsSnapshot`
  `snapshot()`
  Capture the snapshot of the context's IOStatistics.

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

  `getIOStatistics`

- ## Method Details

  - ### getAggregator

    IOStatisticsAggregator getAggregator()
    Get the IOStatisticsAggregator for the context.
    Returns:
      return the aggregator for the context.

  - ### snapshot

    IOStatisticsSnapshot snapshot()
    Capture the snapshot of the context's IOStatistics.
    Returns:
      IOStatisticsSnapshot for the context.

  - ### getID

    long getID()
    Get a unique ID for this context, for logging purposes.
    Returns:
      an ID unique for all contexts in this process.

  - ### reset

    void reset()
    Reset the context's IOStatistics.

  - ### getCurrentIOStatisticsContext

    static IOStatisticsContext getCurrentIOStatisticsContext()
    Get the context's IOStatisticsContext.
    Returns:
      instance of IOStatisticsContext for the context.

  - ### setThreadIOStatisticsContext

    static void setThreadIOStatisticsContext(IOStatisticsContext statisticsContext)
    Set the IOStatisticsContext for the current thread.
    Parameters:
      `statisticsContext` - IOStatistics context instance for the current thread. If null, the context is reset.

  - ### enabled

    static boolean enabled()
    Static probe to check if the thread-level IO statistics enabled.
    Returns:
      if the thread-level IO statistics enabled.