HdfsDataOutputStream (Apache Hadoop HDFS Client 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.client, class: HdfsDataOutputStream

Package org.apache.hadoop.hdfs.client

# Class HdfsDataOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.DataOutputStream
org.apache.hadoop.fs.FSDataOutputStream
org.apache.hadoop.hdfs.client.HdfsDataOutputStream

All Implemented Interfaces:
  `Closeable`, `DataOutput`, `Flushable`, `AutoCloseable`, `org.apache.hadoop.fs.Abortable`, `org.apache.hadoop.fs.CanSetDropBehind`, `org.apache.hadoop.fs.statistics.IOStatisticsSource`, `org.apache.hadoop.fs.StreamCapabilities`, `org.apache.hadoop.fs.Syncable`

@Public @Evolving public class HdfsDataOutputStream extends org.apache.hadoop.fs.FSDataOutputStream
The Hdfs implementation of `FSDataOutputStream`.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `HdfsDataOutputStream.SyncFlag`

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

  `org.apache.hadoop.fs.Abortable.AbortableResult`

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

  `org.apache.hadoop.fs.StreamCapabilities.StreamCapability`

- ## Field Summary

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

  `written`

  ### 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
  `HdfsDataOutputStream(org.apache.hadoop.crypto.CryptoOutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats)`
  `HdfsDataOutputStream(org.apache.hadoop.crypto.CryptoOutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats, long startPosition)`
  `HdfsDataOutputStream(DFSOutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats)`
  `HdfsDataOutputStream(DFSOutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats, long startPosition)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getCurrentBlockReplication()`
  Get the actual number of replicas of the current block.
  `void`
  `hsync(EnumSet<HdfsDataOutputStream.SyncFlag> syncFlags)`
  Sync buffered data to DataNodes (flush to disk devices).

  ### Methods inherited from class org.apache.hadoop.fs.FSDataOutputStream

  `abort, close, getIOStatistics, getPos, getWrappedStream, hasCapability, hflush, hsync, setDropBehind, toString`

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

  `flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF`

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

  `write`

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

  `nullOutputStream`

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

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

  ### Methods inherited from interface java.io.DataOutput

  `write`

- ## Constructor Details

  - ### HdfsDataOutputStream

    public HdfsDataOutputStream(DFSOutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats, long startPosition) throws IOException
    Throws:
      `IOException`

  - ### HdfsDataOutputStream

    public HdfsDataOutputStream(DFSOutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats) throws IOException
    Throws:
      `IOException`

  - ### HdfsDataOutputStream

    public HdfsDataOutputStream(org.apache.hadoop.crypto.CryptoOutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats, long startPosition) throws IOException
    Throws:
      `IOException`

  - ### HdfsDataOutputStream

    public HdfsDataOutputStream(org.apache.hadoop.crypto.CryptoOutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats) throws IOException
    Throws:
      `IOException`

- ## Method Details

  - ### getCurrentBlockReplication

    public int getCurrentBlockReplication() throws IOException
    Get the actual number of replicas of the current block. This can be different from the designated replication factor of the file because the namenode does not maintain replication for the blocks which are currently being written to. Depending on the configuration, the client may continue to write to a block even if a few datanodes in the write pipeline have failed, or the client may add a new datanodes once a datanode has failed.
    Returns:
      the number of valid replicas of the current block
    Throws:
      `IOException`

  - ### hsync

    public void hsync(EnumSet<HdfsDataOutputStream.SyncFlag> syncFlags) throws IOException
    Sync buffered data to DataNodes (flush to disk devices).
    Parameters:
      `syncFlags` - Indicate the detailed semantic and actions of the hsync.
    Throws:
      `IOException`
    See Also:
      - `FSDataOutputStream.hsync()`