/** * Return {@link ByteBuf} that is a {@link ByteBuf#slice()} for the frame data * * <p>If no data is present, the ByteBuf will have 0 capacity. * * @return ByteBuf containing the data */ public ByteBuf sliceData() { return FrameHeaderFlyweight.sliceFrameData(content); }
/** * Return frame stream identifier * * @return frame stream identifier */ public int getStreamId() { return FrameHeaderFlyweight.streamId(content); }
static int dataLength(final ByteBuf byteBuf, final FrameType frameType, final int payloadOffset) { final int frameLength = frameLength(byteBuf); final int metadataLength = metadataFieldLength(byteBuf, frameType, frameLength); return frameLength - metadataLength - payloadOffset; }
public static int encode(final ByteBuf byteBuf, int flags, final ByteBuf data) { final int frameLength = computeFrameLength(data.readableBytes()); int length = FrameHeaderFlyweight.encodeFrameHeader(byteBuf, frameLength, flags, FrameType.KEEPALIVE, 0); // We don't support resumability, last position is always zero byteBuf.setLong(length, 0); length += Long.BYTES; length += FrameHeaderFlyweight.encodeData(byteBuf, length, data); return length; }
public static int encode( final ByteBuf byteBuf, final int streamId, final int errorCode, final ByteBuf data) { final int frameLength = computeFrameLength(data.readableBytes()); int length = FrameHeaderFlyweight.encodeFrameHeader(byteBuf, frameLength, 0, FrameType.ERROR, streamId); byteBuf.setInt(ERROR_CODE_FIELD_OFFSET, errorCode); length += Integer.BYTES; length += FrameHeaderFlyweight.encodeData(byteBuf, length, data); return length; }
public static int encode( final ByteBuf byteBuf, final int ttl, final int numRequests, final ByteBuf metadata) { final int frameLength = computeFrameLength(metadata.readableBytes()); int length = FrameHeaderFlyweight.encodeFrameHeader(byteBuf, frameLength, 0, FrameType.LEASE, 0); byteBuf.setInt(TTL_FIELD_OFFSET, ttl); byteBuf.setInt(NUM_REQUESTS_FIELD_OFFSET, numRequests); length += Integer.BYTES * 2; length += FrameHeaderFlyweight.encodeMetadata(byteBuf, FrameType.LEASE, length, metadata); return length; }
public static int payloadLength(final ByteBuf byteBuf) { final int frameLength = frameLength(byteBuf); final int payloadOffset = payloadOffset(byteBuf); return frameLength - payloadOffset; }
public static int dataLength(final ByteBuf byteBuf, final FrameType frameType) { return dataLength(byteBuf, frameType, payloadOffset(byteBuf)); }
public static int encode(final ByteBuf byteBuf, final int streamId, final int requestN) { final int frameLength = computeFrameLength(); int length = FrameHeaderFlyweight.encodeFrameHeader( byteBuf, frameLength, 0, FrameType.REQUEST_N, streamId); byteBuf.setInt(REQUEST_N_FIELD_OFFSET, requestN); return length + Integer.BYTES; }
public static int dataOffset(ByteBuf byteBuf, FrameType frameType, int frameLength) { return payloadOffset(byteBuf) + metadataFieldLength(byteBuf, frameType, frameLength); } }
/** * Return frame {@link FrameType} * * @return frame type */ public FrameType getType() { return FrameHeaderFlyweight.frameType(content); }
/** * Return the flags field for the frame * * @return frame flags field value */ public int flags() { return FrameHeaderFlyweight.flags(content); }
public static int computeFrameLength(final int metadataLength) { int length = FrameHeaderFlyweight.computeFrameHeaderLength(FrameType.LEASE, metadataLength, 0); return length + Integer.BYTES * 2; }
public static int frameLength(final ByteBuf byteBuf) { // frame length field was excluded from the length so we will add it to represent // the entire block return decodeLength(byteBuf, FRAME_LENGTH_FIELD_OFFSET) + FRAME_LENGTH_SIZE; }
public static int metadataOffset(final ByteBuf byteBuf) { return payloadOffset(byteBuf); }
private static int metadataMimetypeOffset(final ByteBuf byteBuf) { return VARIABLE_DATA_OFFSET + resumeTokenTotalLength(byteBuf); }
public static int computeFrameLength(final int dataLength) { return FrameHeaderFlyweight.computeFrameHeaderLength(FrameType.SETUP, null, dataLength) + Long.BYTES; }
public static int computeFrameLength(final int dataLength) { int length = FrameHeaderFlyweight.computeFrameHeaderLength(FrameType.ERROR, null, dataLength); return length + Integer.BYTES; }
public static int computeFrameLength() { int length = FrameHeaderFlyweight.computeFrameHeaderLength(FrameType.REQUEST_N, 0, 0); return length + Integer.BYTES; }