@InterfaceAudience.Private public class FanOutOneBlockAsyncDFSOutput extends Object implements AsyncFSOutput
Use the createOutput method in FanOutOneBlockAsyncDFSOutputHelper to create. The mainly
usage of this class is implementing WAL, so we only expose a little HDFS configurations in the
method. And we place it here under io package because we want to make it independent of WAL
implementation thus easier to move it to HDFS project finally.
Note that, although we support pipelined flush, i.e, write new data and then flush before the previous flush succeeds, the implementation is not thread safe, so you should not call its methods concurrently.
Advantages compare to DFSOutputStream:
| 限定符和类型 | 方法和说明 |
|---|---|
int |
buffered()
Return the current size of buffered data.
|
void |
close()
End the current block and complete file at namenode.
|
CompletableFuture<Long> |
flush(boolean syncBlock)
Flush the buffer out to datanodes.
|
org.apache.hadoop.hdfs.protocol.DatanodeInfo[] |
getPipeline()
Return current pipeline.
|
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
bb into the buffer. |
void |
writeInt(int i)
Write an int to the buffer.
|
public void writeInt(int i)
AsyncFSOutputwriteInt 在接口中 AsyncFSOutputpublic void write(ByteBuffer bb)
AsyncFSOutputbb into the buffer.write 在接口中 AsyncFSOutputpublic void write(byte[] b)
AsyncFSOutputwrite 在接口中 AsyncFSOutputAsyncFSOutput.write(byte[], int, int)public void write(byte[] b,
int off,
int len)
AsyncFSOutputAsyncFSOutput.flush(boolean) to flush the
buffer manually.write 在接口中 AsyncFSOutputpublic int buffered()
AsyncFSOutputbuffered 在接口中 AsyncFSOutputpublic org.apache.hadoop.hdfs.protocol.DatanodeInfo[] getPipeline()
AsyncFSOutputgetPipeline 在接口中 AsyncFSOutputpublic CompletableFuture<Long> flush(boolean syncBlock)
flush 在接口中 AsyncFSOutputsyncBlock - will call hsync if true, otherwise hflush.public void recoverAndClose(CancelableProgressable reporter) throws IOException
recoverAndClose 在接口中 AsyncFSOutputIOExceptionpublic void close()
throws IOException
recoverAndClose(CancelableProgressable) if this method throws an exception.close 在接口中 Closeableclose 在接口中 AutoCloseableclose 在接口中 AsyncFSOutputIOExceptionpublic boolean isBroken()
AsyncFSOutputisBroken 在接口中 AsyncFSOutputCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.