Example usage for io.netty.buffer ByteBuf writeLong

List of usage examples for io.netty.buffer ByteBuf writeLong

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf writeLong.

Prototype

public abstract ByteBuf writeLong(long value);

Source Link

Document

Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.

Usage

From source file:alluxio.network.protocol.RPCBlockReadRequest.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mBlockId);
    out.writeLong(mOffset);/*from w  w w  . j  a  va  2 s . c  om*/
    out.writeLong(mLength);
    out.writeLong(mLockId);
    out.writeLong(mSessionId);
}

From source file:alluxio.network.protocol.RPCBlockReadResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mBlockId);
    out.writeLong(mOffset);//from   w  ww  . jav  a  2  s. c o m
    out.writeLong(mLength);
    out.writeShort(mStatus.getId());
    // The actual payload is not encoded here, since the RPCMessageEncoder will transfer it in a
    // more efficient way.
}

From source file:alluxio.network.protocol.RPCBlockWriteRequest.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mSessionId);
    out.writeLong(mBlockId);//from ww w. j a v  a  2s  .  c  o  m
    out.writeLong(mOffset);
    out.writeLong(mLength);
    // The actual payload is not encoded here, since the RPCMessageEncoder will transfer it in a
    // more efficient way.
}

From source file:alluxio.network.protocol.RPCBlockWriteResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mSessionId);
    out.writeLong(mBlockId);/*from   ww w . j ava 2s  . c o m*/
    out.writeLong(mOffset);
    out.writeLong(mLength);
    out.writeShort(mStatus.getId());
}

From source file:alluxio.network.protocol.RPCFileReadRequest.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mTempUfsFileId);
    out.writeLong(mOffset);
    out.writeLong(mLength);
}

From source file:alluxio.network.protocol.RPCFileReadResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mTempUfsFileId);
    out.writeLong(mOffset);/*w ww  .j  av  a2  s . c  o  m*/
    out.writeLong(mLength);
    out.writeShort(mStatus.getId());
    // The actual payload is not encoded here, since the RPCMessageEncoder will transfer it in a
    // more efficient way.
}

From source file:alluxio.network.protocol.RPCFileWriteRequest.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mTempUfsFileId);
    out.writeLong(mOffset);/*from  w ww.jav  a 2 s .c  o m*/
    out.writeLong(mLength);
    // The actual payload is not encoded here, since the RPCMessageEncoder will transfer it in a
    // more efficient way.
}

From source file:alluxio.network.protocol.RPCFileWriteResponse.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mTempUfsFileId);
    out.writeLong(mOffset);//from   w w w  .  ja v a 2  s.  co m
    out.writeLong(mLength);
    out.writeShort(mStatus.getId());
}

From source file:alluxio.network.protocol.RPCMessageEncoder.java

License:Apache License

@Override
protected void encode(ChannelHandlerContext ctx, RPCMessage in, List<Object> out) throws Exception {
    RPCRequest.Type type = in.getType();

    long bodyBytes = 0;
    DataBuffer payload = null;//from w w  w .  jav  a 2  s . c o m

    if (in.hasPayload()) {
        payload = in.getPayloadDataBuffer();
        bodyBytes = payload.getLength();
    }

    int lengthBytes = Longs.BYTES;
    int typeBytes = type.getEncodedLength();
    int messageBytes = in.getEncodedLength();

    int headerBytes = lengthBytes + typeBytes + messageBytes;
    long frameBytes = headerBytes + bodyBytes;

    // Write the header info into a buffer.
    // The format is: [frame length][message type][message][(optional) data]
    ByteBuf buffer = ctx.alloc().buffer();
    buffer.writeLong(frameBytes);
    type.encode(buffer);
    in.encode(buffer);

    // Output the header buffer.
    out.add(buffer);

    if (payload != null && bodyBytes > 0) {
        Object output = payload.getNettyOutput();
        Preconditions.checkArgument(output instanceof ByteBuf || output instanceof FileRegion,
                "The payload must be a ByteBuf or a FileRegion.");
        out.add(output);
    }

}

From source file:alluxio.network.protocol.RPCUnderFileSystemBlockReadRequest.java

License:Apache License

@Override
public void encode(ByteBuf out) {
    out.writeLong(mBlockId);
    out.writeLong(mOffset);// ww  w .jav  a 2 s.  c o  m
    out.writeLong(mLength);
    out.writeLong(mSessionId);
    out.writeBoolean(mNoCache);
}