public abstract class BufferedBlockOutStream extends OutputStream implements Cancelable
TachyonBlockStore.getOutStream(long, long, java.lang.String)
. Only one BlockOutStream should be opened for a
block. This class is not thread safe and should only be used by one thread.
The type of BlockOutStream returned will depend on the user configuration and cluster setup. A
LocalBlockOutStream
is returned if the client is co-located with a Tachyon worker and the
user has enabled this optimization. Otherwise, a RemoteBlockOutStream
will be returned
which will write the data through a Tachyon worker.
Modifier and Type | Field and Description |
---|---|
protected long |
mBlockId
The block id of the block being written
|
protected long |
mBlockSize
Size of the block
|
protected ByteBuffer |
mBuffer
Java heap buffer to store writes before flushing them to the backing store.
|
protected boolean |
mClosed
If the stream is closed, this can only go from false to true
|
protected BlockStoreContext |
mContext
Block store context
|
protected long |
mFlushedBytes
Number of bytes flushed to the under storage system.
|
protected long |
mWrittenBytes
Number of bytes written, including unflushed bytes
|
Constructor and Description |
---|
BufferedBlockOutStream(long blockId,
long blockSize) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkIfClosed()
Convenience method for checking the state of the stream.
|
long |
remaining() |
protected abstract void |
unBufferedWrite(byte[] b,
int off,
int len)
Writes the data in the byte array directly to the backing store.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
close, flush
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cancel
protected final long mBlockId
protected final long mBlockSize
protected final BlockStoreContext mContext
protected final ByteBuffer mBuffer
protected boolean mClosed
protected long mFlushedBytes
protected long mWrittenBytes
public BufferedBlockOutStream(long blockId, long blockSize)
public long remaining()
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
protected void checkIfClosed()
protected abstract void unBufferedWrite(byte[] b, int off, int len) throws IOException
b
- the data that should be writtenoff
- the offset into the data to start writing fromlen
- the length to writeIOException
- if the write does not succeedCopyright © 2015. All Rights Reserved.