Class ByteStreamWriterImpl
- java.lang.Object
-
- java.io.OutputStream
-
- io.pravega.client.byteStream.ByteStreamWriter
-
- io.pravega.client.byteStream.impl.ByteStreamWriterImpl
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class ByteStreamWriterImpl extends ByteStreamWriter
-
-
Constructor Summary
Constructors Constructor Description ByteStreamWriterImpl(@NonNull SegmentOutputStream out, @NonNull SegmentMetadataClient meta)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Flushes the buffer and closes the writer.voidcloseAndSeal()Closes the writer similar toByteStreamWriter.close()but also seals it so that no future writes can ever be made.longfetchTailOffset()This makes a synchronous RPC call to the server to obtain the total number of bytes written to the segment in its history.voidflush()Blocks until all data written has been durably persisted.voidtruncateDataBefore(long offset)This makes a synchronous RPC call to the server to truncate the segment at the provided offset.voidwrite(byte[] b, int off, int len)Writes the provided data to the segment.voidwrite(int b)voidwrite(java.nio.ByteBuffer src)Similar toByteStreamWriter.write(byte[], int, int)Writes the provided data to the segment.
-
-
-
Constructor Detail
-
ByteStreamWriterImpl
@ConstructorProperties({"out","meta"}) public ByteStreamWriterImpl(@NonNull @NonNull SegmentOutputStream out, @NonNull @NonNull SegmentMetadataClient meta)
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(java.nio.ByteBuffer src) throws java.io.IOExceptionDescription copied from class:ByteStreamWriterSimilar toByteStreamWriter.write(byte[], int, int)Writes the provided data to the segment. The data is buffered internally to avoid blocking. As such it cannot be assumed to be durably stored until a flush completes. It is intended that this method not block, but it may in the event that the server becomes disconnected for sufficiently long or is sufficiently slow that that backlog of data to be written becomes a memory issue.- Specified by:
writein classByteStreamWriter- Parameters:
src- The bytes to write.- Throws:
java.io.IOException- If for any reason an error occurs writing the data, including if the stream is sealed.
-
write
public void write(byte[] b, int off, int len) throws java.io.IOExceptionDescription copied from class:ByteStreamWriterWrites the provided data to the segment. The data is buffered internally to avoid blocking. As such it cannot be assumed to be durably stored until a flush completes. It is intended that this method not block, but it may in the event that the server becomes disconnected for sufficiently long or is sufficiently slow that that backlog of data to be written becomes a memory issue.- Specified by:
writein classByteStreamWriter- Throws:
java.io.IOException- See Also:
OutputStream.write(byte[], int, int)
-
close
public void close() throws java.io.IOExceptionDescription copied from class:ByteStreamWriterFlushes the buffer and closes the writer. If there is data to flush, this is a blocking method.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classByteStreamWriter- Throws:
java.io.IOException- See Also:
OutputStream.close()
-
flush
public void flush() throws java.io.IOExceptionDescription copied from class:ByteStreamWriterBlocks until all data written has been durably persisted.- Specified by:
flushin interfacejava.io.Flushable- Specified by:
flushin classByteStreamWriter- Throws:
java.io.IOException- If for any reason the flush fails including if the stream is sealed.- See Also:
OutputStream.flush()
-
closeAndSeal
public void closeAndSeal() throws java.io.IOExceptionDescription copied from class:ByteStreamWriterCloses the writer similar toByteStreamWriter.close()but also seals it so that no future writes can ever be made.- Specified by:
closeAndSealin classByteStreamWriter- Throws:
java.io.IOException- If for any reason the flush fails including if the stream is sealed.
-
fetchTailOffset
public long fetchTailOffset()
Description copied from class:ByteStreamWriterThis makes a synchronous RPC call to the server to obtain the total number of bytes written to the segment in its history. This is the sum total of the bytes written in all calls toOutputStream.write(byte[])that have been flushed. It does not include data that was passed toOutputStream.write(byte[])but which has not yet been persisted.- Specified by:
fetchTailOffsetin classByteStreamWriter- Returns:
- The tail offset
-
truncateDataBefore
public void truncateDataBefore(long offset)
Description copied from class:ByteStreamWriterThis makes a synchronous RPC call to the server to truncate the segment at the provided offset.- Specified by:
truncateDataBeforein classByteStreamWriter- Parameters:
offset- The truncation offset.
-
-