DurationInfo (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: DurationInfo

Package org.apache.hadoop.util

# Class DurationInfo

java.lang.Object
org.apache.hadoop.util.OperationDuration
org.apache.hadoop.util.DurationInfo

All Implemented Interfaces:
  `AutoCloseable`

@Public @Unstable public class DurationInfo extends OperationDuration implements AutoCloseable
A duration with logging of final state at info or debug in the `close()` call. This allows it to be used in a try-with-resources clause, and have the duration automatically logged.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DurationInfo(org.slf4j.Logger log, boolean logAtInfo, String format, Object... args)`
  Create the duration text from a `String.format()` code call and log either at info or debug.
  `DurationInfo(org.slf4j.Logger log, String format, Object... args)`
  Create the duration text from a `String.format()` code call; log output at info level.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `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`

- ## Constructor Details

  - ### DurationInfo

    public DurationInfo(org.slf4j.Logger log, String format, Object... args)
    Create the duration text from a `String.format()` code call; log output at info level.
    Parameters:
      `log` - log to write to
      `format` - format string
      `args` - list of arguments

  - ### DurationInfo

    public DurationInfo(org.slf4j.Logger log, boolean logAtInfo, String format, Object... args)
    Create the duration text from a `String.format()` code call and log either at info or debug.
    Parameters:
      `log` - log to write to
      `logAtInfo` - should the log be at info, rather than debug
      `format` - format string
      `args` - list of arguments

- ## Method Details

  - ### 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.

  - ### close

    public void close()
    Specified by:
      `close` in interface `AutoCloseable`