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

Package org.apache.hadoop.fs.statistics

# Class BufferedIOStatisticsOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.BufferedOutputStream
org.apache.hadoop.fs.statistics.BufferedIOStatisticsOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`, `IOStatisticsSource`, `StreamCapabilities`, `Syncable`

public class BufferedIOStatisticsOutputStream extends BufferedOutputStream implements IOStatisticsSource, Syncable, StreamCapabilities
An extension of `BufferedOutputStream` which implements `IOStatisticsSource` and forwards requests for the `IOStatistics` to the wrapped stream. This should be used when any output stream needs buffering while allowing the inner stream to be a source of statistics. It also implements `StreamCapabilities` and `Syncable` and forwards to to the inner stream, if possible.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface org.apache.hadoop.fs.StreamCapabilities

  `StreamCapabilities.StreamCapability`

- ## Field Summary

  ### Fields inherited from class java.io.BufferedOutputStream

  `buf, count`

  ### Fields inherited from class java.io.FilterOutputStream

  `out`

  ### Fields inherited from interface org.apache.hadoop.fs.StreamCapabilities

  `ABORTABLE_STREAM, DROPBEHIND, HFLUSH, HSYNC, IOSTATISTICS, IOSTATISTICS_CONTEXT, PREADBYTEBUFFER, READAHEAD, READBYTEBUFFER, UNBUFFER, VECTOREDIO, VECTOREDIO_BUFFERS_SLICED`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BufferedIOStatisticsOutputStream(OutputStream out, boolean downgradeSyncable)`
  Construct with default buffer size.
  `BufferedIOStatisticsOutputStream(OutputStream out, int size, boolean downgradeSyncable)`
  Construct with custom buffer size.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `IOStatistics`
  `getIOStatistics()`
  Ask the inner stream for their IOStatistics.
  `boolean`
  `hasCapability(String capability)`
  If the inner stream supports `StreamCapabilities`, forward the probe to it.
  `void`
  `hflush()`
  If the inner stream is Syncable, flush the buffer and then invoke the inner stream's hflush() operation.
  `void`
  `hsync()`
  If the inner stream is Syncable, flush the buffer and then invoke the inner stream's hsync() operation.

  ### Methods inherited from class java.io.BufferedOutputStream

  `flush, write, write`

  ### Methods inherited from class java.io.FilterOutputStream

  `close, write`

  ### Methods inherited from class java.io.OutputStream

  `nullOutputStream`

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

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

- ## Constructor Details

  - ### BufferedIOStatisticsOutputStream

    public BufferedIOStatisticsOutputStream(OutputStream out, boolean downgradeSyncable)
    Construct with default buffer size.
    Parameters:
      `out` - output stream to buffer
      `downgradeSyncable` - should Syncable calls downgrade?

  - ### BufferedIOStatisticsOutputStream

    public BufferedIOStatisticsOutputStream(OutputStream out, int size, boolean downgradeSyncable)
    Construct with custom buffer size.
    Parameters:
      `out` - output stream to buffer
      `size` - buffer.
      `downgradeSyncable` - should Syncable calls downgrade?

- ## Method Details

  - ### getIOStatistics

    public IOStatistics getIOStatistics()
    Ask the inner stream for their IOStatistics.
    Specified by:
      `getIOStatistics` in interface `IOStatisticsSource`
    Returns:
      any IOStatistics offered by the inner stream.

  - ### hasCapability

    public boolean hasCapability(String capability)
    If the inner stream supports `StreamCapabilities`, forward the probe to it. Otherwise: return false.
    Specified by:
      `hasCapability` in interface `StreamCapabilities`
    Parameters:
      `capability` - string to query the stream support for.
    Returns:
      true if a capability is known to be supported.

  - ### hflush

    public void hflush() throws IOException
    If the inner stream is Syncable, flush the buffer and then invoke the inner stream's hflush() operation. Otherwise: throw an exception, unless the stream was constructed with `downgradeSyncable` set to true, in which case the stream is just flushed.
    Specified by:
      `hflush` in interface `Syncable`
    Throws:
      `IOException` - IO Problem
      `UnsupportedOperationException` - if the inner class is not syncable

  - ### hsync

    public void hsync() throws IOException
    If the inner stream is Syncable, flush the buffer and then invoke the inner stream's hsync() operation. Otherwise: throw an exception, unless the stream was constructed with `downgradeSyncable` set to true, in which case the stream is just flushed.
    Specified by:
      `hsync` in interface `Syncable`
    Throws:
      `IOException` - IO Problem
      `UnsupportedOperationException` - if the inner class is not syncable