Package org.mockserver.netty.unification
Class BinaryAwareRecvByteBufAllocator
java.lang.Object
org.mockserver.netty.unification.BinaryAwareRecvByteBufAllocator
- All Implemented Interfaces:
io.netty.channel.MaxMessagesRecvByteBufAllocator,io.netty.channel.RecvByteBufAllocator
public final class BinaryAwareRecvByteBufAllocator
extends Object
implements io.netty.channel.MaxMessagesRecvByteBufAllocator
Sizes the buffer each read of an accepted connection is given: as the channel's own allocator does (adaptive,
following recent reads down to 64 bytes) until the connection is found to be binary, then
BINARY_READ_SIZE for every read, so that a binary message is not cut by a buffer that has followed
small messages down. It also knows when the channel is inside a read loop. One instance per channel, installed
before its first read: Netty takes the handle once, on that read, and the native transports wrap it, so only
this object can be told, or asked.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.RecvByteBufAllocator
io.netty.channel.RecvByteBufAllocator.DelegatingHandle, io.netty.channel.RecvByteBufAllocator.ExtendedHandle, io.netty.channel.RecvByteBufAllocator.Handle -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe largest buffer Netty's adaptive allocator grows to, so no read is larger than one it could already be. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinstall(io.netty.channel.Channel channel) Wraps the channel's allocator.static booleanisReading(io.netty.channel.Channel channel) Whether the channel is inside a read loop: from its first read until just before its channelReadComplete.intio.netty.channel.MaxMessagesRecvByteBufAllocatormaxMessagesPerRead(int maxMessagesPerRead) io.netty.channel.RecvByteBufAllocator.Handlestatic voidreadWholeMessages(io.netty.channel.Channel channel) Every later read of the channel is givenBINARY_READ_SIZE.
-
Field Details
-
BINARY_READ_SIZE
public static final int BINARY_READ_SIZEThe largest buffer Netty's adaptive allocator grows to, so no read is larger than one it could already be.- See Also:
-
-
Method Details
-
install
public static void install(io.netty.channel.Channel channel) Wraps the channel's allocator. Has no effect on the reads of a channel that has already been read. -
readWholeMessages
public static void readWholeMessages(io.netty.channel.Channel channel) Every later read of the channel is givenBINARY_READ_SIZE. Call on the channel's event loop. -
isReading
public static boolean isReading(io.netty.channel.Channel channel) Whether the channel is inside a read loop: from its first read until just before its channelReadComplete. -
maxMessagesPerRead
public int maxMessagesPerRead()- Specified by:
maxMessagesPerReadin interfaceio.netty.channel.MaxMessagesRecvByteBufAllocator
-
maxMessagesPerRead
public io.netty.channel.MaxMessagesRecvByteBufAllocator maxMessagesPerRead(int maxMessagesPerRead) - Specified by:
maxMessagesPerReadin interfaceio.netty.channel.MaxMessagesRecvByteBufAllocator
-
newHandle
public io.netty.channel.RecvByteBufAllocator.Handle newHandle()- Specified by:
newHandlein interfaceio.netty.channel.RecvByteBufAllocator
-