@InterfaceAudience.Private public class WrapperAsyncFSOutput extends Object implements AsyncFSOutput
AsyncFSOutput wraps a FSDataOutputStream.| Modifier and Type | Field and Description | 
|---|---|
| private ByteArrayOutputStream | buffer | 
| private ExecutorService | executor | 
| private org.apache.hadoop.fs.FSDataOutputStream | out | 
| private long | syncedLength | 
| Constructor and Description | 
|---|
| WrapperAsyncFSOutput(org.apache.hadoop.fs.Path file,
                    org.apache.hadoop.fs.FSDataOutputStream out) | 
| Modifier and Type | Method and Description | 
|---|---|
| int | buffered()Return the current size of buffered data. | 
| void | close()Close the file. | 
| CompletableFuture<Long> | flush(boolean sync)Flush the buffer out. | 
| private void | flush0(CompletableFuture<Long> future,
      ByteArrayOutputStream buffer,
      boolean sync) | 
| org.apache.hadoop.hdfs.protocol.DatanodeInfo[] | getPipeline()Return current pipeline. | 
| long | getSyncedLength() | 
| boolean | isBroken()Whether the stream is broken. | 
| void | recoverAndClose(CancelableProgressable reporter)The close method when error occurred. | 
| void | write(byte[] b)Just call write(b, 0, b.length). | 
| void | write(byte[] b,
     int off,
     int len)Copy the data into the buffer. | 
| void | write(ByteBuffer bb)Copy the data in the given  bbinto the buffer. | 
| void | writeInt(int i)Write an int to the buffer. | 
private final org.apache.hadoop.fs.FSDataOutputStream out
private ByteArrayOutputStream buffer
private final ExecutorService executor
private volatile long syncedLength
public WrapperAsyncFSOutput(org.apache.hadoop.fs.Path file, org.apache.hadoop.fs.FSDataOutputStream out)
public void write(byte[] b)
AsyncFSOutputwrite in interface AsyncFSOutputAsyncFSOutput.write(byte[], int, int)public void write(byte[] b, int off, int len)
AsyncFSOutputAsyncFSOutput.flush(boolean) to flush the
 buffer manually.write in interface AsyncFSOutputpublic void writeInt(int i)
AsyncFSOutputwriteInt in interface AsyncFSOutputpublic void write(ByteBuffer bb)
AsyncFSOutputbb into the buffer.write in interface AsyncFSOutputpublic int buffered()
AsyncFSOutputbuffered in interface AsyncFSOutputpublic org.apache.hadoop.hdfs.protocol.DatanodeInfo[] getPipeline()
AsyncFSOutputgetPipeline in interface AsyncFSOutputprivate void flush0(CompletableFuture<Long> future, ByteArrayOutputStream buffer, boolean sync)
public CompletableFuture<Long> flush(boolean sync)
AsyncFSOutputflush in interface AsyncFSOutputsync - persistent the data to devicepublic void recoverAndClose(CancelableProgressable reporter) throws IOException
AsyncFSOutputrecoverAndClose in interface AsyncFSOutputIOExceptionpublic void close() throws IOException
AsyncFSOutputAsyncFSOutput.recoverAndClose(CancelableProgressable) if this method
 throws an exception.close in interface Closeableclose in interface AutoCloseableclose in interface AsyncFSOutputIOExceptionpublic boolean isBroken()
AsyncFSOutputisBroken in interface AsyncFSOutputpublic long getSyncedLength()
getSyncedLength in interface AsyncFSOutputCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.