@Override public RequestChannelFrame createFragment( ByteBufAllocator byteBufAllocator, @Nullable ByteBuf metadata, @Nullable ByteBuf data) { return createRequestChannelFrame( byteBufAllocator, true, isCompleteFlagSet(), getInitialRequestN(), metadata, data); }
ByteBuf byteBuf = createFrameTypeAndFlags(byteBufAllocator, FrameType.REQUEST_CHANNEL); byteBuf = setFollowsFlag(byteBuf); byteBuf = setFlag(byteBuf, FLAG_COMPLETE); byteBuf = appendMetadata(byteBufAllocator, byteBuf, metadata); byteBuf = appendData(byteBuf, data); return RECYCLER.get().setByteBuf(byteBuf);
/** * Returns the initial requestN. * * @return the initial requestN */ public int getInitialRequestN() { return getByteBuf().getInt(OFFSET_INITIAL_REQUEST_N); }
@Override public String toString() { return "RequestChannelFrame{" + "follows=" + isFollowsFlagSet() + ", complete=" + isCompleteFlagSet() + ", initialRequestN=" + getInitialRequestN() + ", metadata=" + mapMetadata(ByteBufUtil::hexDump) + ", data=" + mapData(ByteBufUtil::hexDump) + '}'; } }
/** * Returns a test instance of {@link RequestChannelFrame}. * * @return a test instance of {@link RequestChannelFrame} */ public static RequestChannelFrame createTestRequestChannelFrame() { return createRequestChannelFrame(DEFAULT, false, false, 1, (ByteBuf) null, null); }
/** * Creates the {@code REQUEST_CHANNEL} frame. * * @param byteBufAllocator the {@code ByteBufAllocator} to use * @param follows whether to set the Follows flag * @param complete whether to set the Complete flag * @param initialRequestN the initial requestN * @param metadata the metadata * @param data the data * @return the {@code REQUEST_CHANNEL} frame * @throws NullPointerException if {@code byteBufAllocator} is {@code null} */ public static RequestChannelFrame createRequestChannelFrame( ByteBufAllocator byteBufAllocator, boolean follows, boolean complete, int initialRequestN, @Nullable String metadata, @Nullable String data) { ByteBuf metadataByteBuf = getUtf8AsByteBuf(metadata); ByteBuf dataByteBuf = getUtf8AsByteBuf(data); try { return createRequestChannelFrame( byteBufAllocator, follows, complete, initialRequestN, metadataByteBuf, dataByteBuf); } finally { release(metadataByteBuf); release(dataByteBuf); } }
@Override public @Nullable ByteBuf getUnsafeMetadata() { return getMetadata(OFFSET_METADATA_LENGTH); }
@Override public ByteBuf getUnsafeData() { return getData(OFFSET_METADATA_LENGTH); }
@Override public String toString() { return "RequestChannelFrame{" + "follows=" + isFollowsFlagSet() + ", complete=" + isCompleteFlagSet() + ", initialRequestN=" + getInitialRequestN() + ", metadata=" + mapMetadata(ByteBufUtil::hexDump) + ", data=" + mapData(ByteBufUtil::hexDump) + '}'; } }
public static RequestChannelFrame createTestRequestChannelFrame() { return createRequestChannelFrame(DEFAULT, false, false, 1, (ByteBuf) null, null); }
/** * Creates the {@code REQUEST_CHANNEL} frame. * * @param byteBufAllocator the {@code ByteBufAllocator} to use * @param follows whether to set the Follows flag * @param complete whether to set the Complete flag * @param initialRequestN the initial requestN * @param metadata the metadata * @param data the data * @return the {@code REQUEST_CHANNEL} frame * @throws NullPointerException if {@code byteBufAllocator} is {@code null} */ public static RequestChannelFrame createRequestChannelFrame( ByteBufAllocator byteBufAllocator, boolean follows, boolean complete, int initialRequestN, @Nullable String metadata, @Nullable String data) { ByteBuf metadataByteBuf = getUtf8AsByteBuf(metadata); ByteBuf dataByteBuf = getUtf8AsByteBuf(data); try { return createRequestChannelFrame( byteBufAllocator, follows, complete, initialRequestN, metadataByteBuf, dataByteBuf); } finally { release(metadataByteBuf); release(dataByteBuf); } }
@Override public @Nullable ByteBuf getUnsafeMetadata() { return getMetadata(OFFSET_METADATA_LENGTH); }
@Override public ByteBuf getUnsafeData() { return getData(OFFSET_METADATA_LENGTH); }
ByteBuf byteBuf = createFrameTypeAndFlags(byteBufAllocator, FrameType.REQUEST_CHANNEL); byteBuf = setFollowsFlag(byteBuf); byteBuf = setFlag(byteBuf, FLAG_COMPLETE); byteBuf = appendMetadata(byteBufAllocator, byteBuf, metadata); byteBuf = appendData(byteBuf, data); return RECYCLER.get().setByteBuf(byteBuf);
@Override public RequestChannelFrame createNonFragment( ByteBufAllocator byteBufAllocator, @Nullable ByteBuf metadata, @Nullable ByteBuf data) { return createRequestChannelFrame( byteBufAllocator, false, isCompleteFlagSet(), getInitialRequestN(), metadata, data); }
@DisplayName("createRequestChannelFrame throws NullPointerException with null byteBufAllocator") @Test void createRequestChannelFrameNullByteBufAllocator() { assertThatNullPointerException() .isThrownBy(() -> createRequestChannelFrame(null, false, false, 100, (ByteBuf) null, null)) .withMessage("byteBufAllocator must not be null"); }
/** * Returns the initial requestN. * * @return the initial requestN */ public int getInitialRequestN() { return getByteBuf().getInt(OFFSET_INITIAL_REQUEST_N); }
@Override public RequestChannelFrame createFragment( ByteBufAllocator byteBufAllocator, @Nullable ByteBuf metadata, @Nullable ByteBuf data) { return createRequestChannelFrame( byteBufAllocator, true, isCompleteFlagSet(), getInitialRequestN(), metadata, data); }
return createRequestStreamFrame(byteBuf); case REQUEST_CHANNEL: return createRequestChannelFrame(byteBuf); case REQUEST_N: return createRequestNFrame(byteBuf);
@Override public RequestChannelFrame createNonFragment( ByteBufAllocator byteBufAllocator, @Nullable ByteBuf metadata, @Nullable ByteBuf data) { return createRequestChannelFrame( byteBufAllocator, false, isCompleteFlagSet(), getInitialRequestN(), metadata, data); }