Package io.pravega.shared.protocol.netty
Class ByteBufWrapper
- java.lang.Object
-
- io.pravega.common.util.AbstractBufferView
-
- io.pravega.shared.protocol.netty.ByteBufWrapper
-
- All Implemented Interfaces:
io.pravega.common.util.BufferView
@NotThreadSafe public class ByteBufWrapper extends io.pravega.common.util.AbstractBufferView implements io.pravega.common.util.BufferViewBufferViewwrapper forByteBufinstances.
-
-
Constructor Summary
Constructors Constructor Description ByteBufWrapper(@NonNull io.netty.buffer.ByteBuf buf)Creates a new instance of theByteBufWrapperwrapping the givenByteBuf.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <ExceptionT extends java.lang.Exception>
voidcollect(io.pravega.common.util.BufferView.Collector<ExceptionT> bufferCollector)voidcopyTo(java.io.OutputStream target)intcopyTo(java.nio.ByteBuffer byteBuffer)intgetAllocatedLength()io.pravega.common.util.BufferView.ReadergetBufferViewReader()byte[]getCopy()intgetLength()java.io.InputStreamgetReader()java.io.InputStreamgetReader(int offset, int length)java.util.Iterator<java.nio.ByteBuffer>iterateBuffers()voidrelease()InvokesReferenceCounted.release()on the underlying buffer, but only ifReferenceCounted.refCnt()is non-zero.voidretain()InvokesByteBuf.retain()on the underlying buffer.io.pravega.common.util.BufferViewslice(int offset, int length)java.lang.StringtoString()
-
-
-
Constructor Detail
-
ByteBufWrapper
public ByteBufWrapper(@NonNull @NonNull io.netty.buffer.ByteBuf buf)Creates a new instance of theByteBufWrapperwrapping the givenByteBuf. This instance will begin at the given buffer'sByteBuf.readerIndex()and will have a length equal toByteBuf.readableBytes().- Parameters:
buf- TheByteBufto wrap. A read-only duplicate will be made of this buffer; any changes made to theByteBuf.readerIndex()orByteBuf.writerIndex()to this object will not be reflected in thisByteBufWrapperinstance. ThisByteBufreference count will be incremented by 1 to reflect the new reference added by this wrapper. Invokerelease()to release that reference.
-
-
Method Detail
-
retain
public void retain()
InvokesByteBuf.retain()on the underlying buffer.- Specified by:
retainin interfaceio.pravega.common.util.BufferView
-
release
public void release()
InvokesReferenceCounted.release()on the underlying buffer, but only ifReferenceCounted.refCnt()is non-zero. As opposed fromReferenceCounted.release(), this method will not throw if invoked too many times.- Specified by:
releasein interfaceio.pravega.common.util.BufferView
-
collect
public <ExceptionT extends java.lang.Exception> void collect(io.pravega.common.util.BufferView.Collector<ExceptionT> bufferCollector) throws ExceptionT extends java.lang.Exception- Specified by:
collectin interfaceio.pravega.common.util.BufferView- Throws:
ExceptionT extends java.lang.Exception
-
iterateBuffers
public java.util.Iterator<java.nio.ByteBuffer> iterateBuffers()
- Specified by:
iterateBuffersin interfaceio.pravega.common.util.BufferView
-
getLength
public int getLength()
- Specified by:
getLengthin interfaceio.pravega.common.util.BufferView
-
getAllocatedLength
public int getAllocatedLength()
- Specified by:
getAllocatedLengthin interfaceio.pravega.common.util.BufferView
-
getBufferViewReader
public io.pravega.common.util.BufferView.Reader getBufferViewReader()
- Specified by:
getBufferViewReaderin interfaceio.pravega.common.util.BufferView
-
getReader
public java.io.InputStream getReader()
- Specified by:
getReaderin interfaceio.pravega.common.util.BufferView
-
getReader
public java.io.InputStream getReader(int offset, int length)- Specified by:
getReaderin interfaceio.pravega.common.util.BufferView
-
slice
public io.pravega.common.util.BufferView slice(int offset, int length)- Specified by:
slicein interfaceio.pravega.common.util.BufferView
-
getCopy
public byte[] getCopy()
- Specified by:
getCopyin interfaceio.pravega.common.util.BufferView
-
copyTo
public void copyTo(java.io.OutputStream target) throws java.io.IOException- Specified by:
copyToin interfaceio.pravega.common.util.BufferView- Throws:
java.io.IOException
-
copyTo
public int copyTo(java.nio.ByteBuffer byteBuffer)
- Specified by:
copyToin interfaceio.pravega.common.util.BufferView
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-