use of alluxio.network.protocol.databuffer.DataByteBuffer in project alluxio by Alluxio.
the class RPCBlockWriteRequest method decode.
/**
* Decodes the input {@link ByteBuf} into a {@link RPCBlockWriteRequest} object and returns it.
*
* @param in the input {@link ByteBuf}
* @return The decoded RPCBlockWriteRequest object
*/
public static RPCBlockWriteRequest decode(ByteBuf in) {
long sessionId = in.readLong();
long blockId = in.readLong();
long offset = in.readLong();
long length = in.readLong();
// TODO(gene): Look into accessing Netty ByteBuf directly, to avoid copying the data.
// Length will always be greater than 0 if the request is not corrupted. If length is negative,
// ByteBuffer.allocate will fail. If length is 0 this will become a no-op but still go through
// the necessary calls to validate the sessionId/blockId. If length is positive, the request
// will proceed as normal
ByteBuffer buffer = ByteBuffer.allocate((int) length);
in.readBytes(buffer);
DataByteBuffer data = new DataByteBuffer(buffer, (int) length);
return new RPCBlockWriteRequest(sessionId, blockId, offset, length, data);
}
use of alluxio.network.protocol.databuffer.DataByteBuffer in project alluxio by Alluxio.
the class RPCFileWriteRequest method decode.
/**
* Decodes the input {@link ByteBuf} into a {@link RPCFileWriteRequest} object and returns it.
*
* @param in the input {@link ByteBuf}
* @return The decoded RPCFileWriteRequest object
*/
public static RPCFileWriteRequest decode(ByteBuf in) {
long tempUfsFileId = in.readLong();
long offset = in.readLong();
long length = in.readLong();
// TODO(gene): Look into accessing Netty ByteBuf directly, to avoid copying the data.
// Length will always be greater than 0 if the request is not corrupted. If length is negative,
// ByteBuffer.allocate will fail. If length is 0 this will become a no-op but still go through
// the necessary calls to validate the tempUfsFileId. If length is positive, the request will
// proceed as normal
ByteBuffer buffer = ByteBuffer.allocate((int) length);
in.readBytes(buffer);
DataByteBuffer data = new DataByteBuffer(buffer, (int) length);
return new RPCFileWriteRequest(tempUfsFileId, offset, length, data);
}
Aggregations