List of usage examples for io.netty.buffer ByteBuf readLong
public abstract long readLong();
From source file:alluxio.network.protocol.RPCBlockReadRequest.java
License:Apache License
/** * Decodes the input {@link ByteBuf} into a {@link RPCBlockReadRequest} object and returns it. * * @param in the input {@link ByteBuf}/*from w w w . j a v a2 s . co m*/ * @return The decoded RPCBlockReadRequest object */ public static RPCBlockReadRequest decode(ByteBuf in) { long blockId = in.readLong(); long offset = in.readLong(); long length = in.readLong(); long lockId = in.readLong(); long sessionId = in.readLong(); return new RPCBlockReadRequest(blockId, offset, length, lockId, sessionId); }
From source file:alluxio.network.protocol.RPCBlockReadResponse.java
License:Apache License
/** * Decodes the input {@link ByteBuf} into a {@link RPCBlockReadResponse} object and returns it. * * @param in the input {@link ByteBuf}// w w w .j ava 2s . com * @return The decoded RPCBlockReadResponse object */ public static RPCBlockReadResponse decode(ByteBuf in) { long blockId = in.readLong(); long offset = in.readLong(); long length = in.readLong(); short status = in.readShort(); DataBuffer data = null; if (length > 0) { // use DataNettyBuffer instead of DataByteBuffer to avoid copying data = new DataNettyBuffer(in, (int) length); } return new RPCBlockReadResponse(blockId, offset, length, data, Status.fromShort(status)); }
From source file:alluxio.network.protocol.RPCBlockWriteRequest.java
License:Apache License
/** * Decodes the input {@link ByteBuf} into a {@link RPCBlockWriteRequest} object and returns it. * * @param in the input {@link ByteBuf}//w w w.jav a 2 s . co m * @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); }
From source file:alluxio.network.protocol.RPCBlockWriteResponse.java
License:Apache License
/** * Decodes the input {@link ByteBuf} into a {@link RPCBlockWriteResponse} object and returns it. * * @param in the input {@link ByteBuf}//from w w w . j a va2 s.co m * @return the decoded RPCBlockWriteResponse object */ public static RPCBlockWriteResponse decode(ByteBuf in) { long sessionId = in.readLong(); long blockId = in.readLong(); long offset = in.readLong(); long length = in.readLong(); short status = in.readShort(); return new RPCBlockWriteResponse(sessionId, blockId, offset, length, Status.fromShort(status)); }
From source file:alluxio.network.protocol.RPCFileReadRequest.java
License:Apache License
/** * Decodes the input {@link ByteBuf} into a {@link RPCFileReadRequest} object and returns it. * * @param in the input {@link ByteBuf}/*from w w w. j a v a 2s .co m*/ * @return The decoded RPCFileReadRequest object */ public static RPCFileReadRequest decode(ByteBuf in) { long tempUfsFileId = in.readLong(); long offset = in.readLong(); long length = in.readLong(); return new RPCFileReadRequest(tempUfsFileId, offset, length); }
From source file:alluxio.network.protocol.RPCFileReadResponse.java
License:Apache License
/** * Decodes the input {@link ByteBuf} into a {@link RPCFileReadResponse} object and returns it. * * @param in the input {@link ByteBuf}// w ww . j ava 2 s. c o m * @return The decoded RPCFileReadResponse object */ public static RPCFileReadResponse decode(ByteBuf in) { long tempUfsFileId = in.readLong(); long offset = in.readLong(); long length = in.readLong(); short status = in.readShort(); DataBuffer data = null; if (length > 0) { data = new DataNettyBuffer(in, (int) length); } return new RPCFileReadResponse(tempUfsFileId, offset, length, data, Status.fromShort(status)); }
From source file:alluxio.network.protocol.RPCFileWriteRequest.java
License:Apache License
/** * Decodes the input {@link ByteBuf} into a {@link RPCFileWriteRequest} object and returns it. * * @param in the input {@link ByteBuf}// w w w . ja v a2s .com * @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); }
From source file:alluxio.network.protocol.RPCFileWriteResponse.java
License:Apache License
/** * Decodes the input {@link ByteBuf} into a {@link RPCFileWriteResponse} object and returns it. * * @param in the input {@link ByteBuf}// w ww .j av a 2s . c om * @return the decoded RPCFileWriteResponse object */ public static RPCFileWriteResponse decode(ByteBuf in) { long tempUfsFileId = in.readLong(); long offset = in.readLong(); long length = in.readLong(); short status = in.readShort(); return new RPCFileWriteResponse(tempUfsFileId, offset, length, Status.fromShort(status)); }
From source file:alluxio.network.protocol.RPCUnderFileSystemBlockReadRequest.java
License:Apache License
/** * Decodes the input {@link ByteBuf} into a {@link RPCUnderFileSystemBlockReadRequest} object * and returns it./*ww w.jav a 2 s.co m*/ * * @param in the input {@link ByteBuf} * @return The decoded RPCBlockReadRequest object */ public static RPCUnderFileSystemBlockReadRequest decode(ByteBuf in) { long blockId = in.readLong(); long offset = in.readLong(); long length = in.readLong(); long sessionId = in.readLong(); boolean noCache = in.readBoolean(); return new RPCUnderFileSystemBlockReadRequest(blockId, offset, length, sessionId, noCache); }
From source file:appeng.core.sync.packets.PacketCompassRequest.java
License:Open Source License
public PacketCompassRequest(final ByteBuf stream) { this.attunement = stream.readLong(); this.cx = stream.readInt(); this.cz = stream.readInt(); this.cdy = stream.readInt(); }