Class NettyDataBuffer
- java.lang.Object
-
- alluxio.network.protocol.databuffer.NettyDataBuffer
-
- All Implemented Interfaces:
DataBuffer
public final class NettyDataBuffer extends java.lang.Object implements DataBuffer
A DataBuffer with the underlying data being aByteBuf
.
-
-
Constructor Summary
Constructors Constructor Description NettyDataBuffer(io.netty.buffer.ByteBuf bytebuf)
Constructor for creating a NettyDataBuffer, by passing a Netty ByteBuf.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getLength()
Returns the length of the data.java.lang.Object
getNettyOutput()
Returns an object for writing to a netty channel.java.nio.ByteBuffer
getReadOnlyByteBuffer()
Returns aByteBuffer
for read-only access to the data.int
readableBytes()
void
readBytes(byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).void
readBytes(java.io.OutputStream outputStream, int length)
Transfers this buffer's data to the given stream.void
readBytes(java.nio.ByteBuffer outputBuf)
Transfers this buffer's data to the givenByteBuffer
.void
release()
Release the Netty ByteBuf.
-
-
-
Method Detail
-
getNettyOutput
public java.lang.Object getNettyOutput()
Description copied from interface:DataBuffer
Returns an object for writing to a netty channel.- Specified by:
getNettyOutput
in interfaceDataBuffer
- Returns:
- the netty buffer
-
getLength
public long getLength()
Description copied from interface:DataBuffer
Returns the length of the data.- Specified by:
getLength
in interfaceDataBuffer
- Returns:
- the length of the data in bytes
-
getReadOnlyByteBuffer
public java.nio.ByteBuffer getReadOnlyByteBuffer()
Description copied from interface:DataBuffer
Returns aByteBuffer
for read-only access to the data.- Specified by:
getReadOnlyByteBuffer
in interfaceDataBuffer
- Returns:
- a read-only ByteBuffer representing the data
-
readBytes
public void readBytes(byte[] dst, int dstIndex, int length)
Description copied from interface:DataBuffer
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).- Specified by:
readBytes
in interfaceDataBuffer
- Parameters:
dst
- the destinationdstIndex
- the first index of the destinationlength
- the number of bytes to transfer
-
readBytes
public void readBytes(java.io.OutputStream outputStream, int length) throws java.io.IOException
Description copied from interface:DataBuffer
Transfers this buffer's data to the given stream.- Specified by:
readBytes
in interfaceDataBuffer
- Parameters:
outputStream
- the stream to transfer data tolength
- length of the data to be transferred- Throws:
java.io.IOException
-
readBytes
public void readBytes(java.nio.ByteBuffer outputBuf)
Description copied from interface:DataBuffer
Transfers this buffer's data to the givenByteBuffer
.- Specified by:
readBytes
in interfaceDataBuffer
- Parameters:
outputBuf
- the buffer to transfer data to
-
readableBytes
public int readableBytes()
- Specified by:
readableBytes
in interfaceDataBuffer
- Returns:
- the number of readable bytes remaining
-
release
public void release()
Release the Netty ByteBuf.- Specified by:
release
in interfaceDataBuffer
-
-