Class WrapperAsyncFSOutput
java.lang.Object
org.apache.hadoop.hbase.io.asyncfs.WrapperAsyncFSOutput
- All Implemented Interfaces:
Closeable
,AutoCloseable
,AsyncFSOutput
An
AsyncFSOutput
wraps a FSDataOutputStream
.-
Field Summary
Modifier and TypeFieldDescriptionprivate ByteArrayOutputStream
private final ExecutorService
private final org.apache.hadoop.fs.FSDataOutputStream
private long
-
Constructor Summary
ConstructorDescriptionWrapperAsyncFSOutput
(org.apache.hadoop.fs.Path file, org.apache.hadoop.fs.FSDataOutputStream out) -
Method Summary
Modifier and TypeMethodDescriptionint
buffered()
Return the current size of buffered data.void
close()
Close the file.flush
(boolean sync) Flush the buffer out.private void
flush0
(CompletableFuture<Long> future, ByteArrayOutputStream buffer, boolean sync) org.apache.hadoop.hdfs.protocol.DatanodeInfo[]
Return current pipeline.long
Returns byteSize success synced to underlying filesystem.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 givenbb
into the buffer.void
writeInt
(int i) Write an int to the buffer.
-
Field Details
-
out
-
buffer
-
executor
-
syncedLength
-
-
Constructor Details
-
WrapperAsyncFSOutput
public WrapperAsyncFSOutput(org.apache.hadoop.fs.Path file, org.apache.hadoop.fs.FSDataOutputStream out)
-
-
Method Details
-
write
Description copied from interface:AsyncFSOutput
Just call write(b, 0, b.length).- Specified by:
write
in interfaceAsyncFSOutput
- See Also:
-
write
Description copied from interface:AsyncFSOutput
Copy the data into the buffer. Note that you need to callAsyncFSOutput.flush(boolean)
to flush the buffer manually.- Specified by:
write
in interfaceAsyncFSOutput
-
writeInt
Description copied from interface:AsyncFSOutput
Write an int to the buffer.- Specified by:
writeInt
in interfaceAsyncFSOutput
-
write
Description copied from interface:AsyncFSOutput
Copy the data in the givenbb
into the buffer.- Specified by:
write
in interfaceAsyncFSOutput
-
buffered
Description copied from interface:AsyncFSOutput
Return the current size of buffered data.- Specified by:
buffered
in interfaceAsyncFSOutput
-
getPipeline
Description copied from interface:AsyncFSOutput
Return current pipeline. Empty array if no pipeline.- Specified by:
getPipeline
in interfaceAsyncFSOutput
-
flush0
-
flush
Description copied from interface:AsyncFSOutput
Flush the buffer out.- Specified by:
flush
in interfaceAsyncFSOutput
- Parameters:
sync
- persistent the data to device- Returns:
- A CompletableFuture that hold the acked length after flushing.
-
recoverAndClose
Description copied from interface:AsyncFSOutput
The close method when error occurred.- Specified by:
recoverAndClose
in interfaceAsyncFSOutput
- Throws:
IOException
-
close
Description copied from interface:AsyncFSOutput
Close the file. You should callAsyncFSOutput.recoverAndClose(CancelableProgressable)
if this method throws an exception.- Specified by:
close
in interfaceAsyncFSOutput
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
isBroken
Description copied from interface:AsyncFSOutput
Whether the stream is broken.- Specified by:
isBroken
in interfaceAsyncFSOutput
-
getSyncedLength
Description copied from interface:AsyncFSOutput
Returns byteSize success synced to underlying filesystem.- Specified by:
getSyncedLength
in interfaceAsyncFSOutput
-