Package io.netty.channel
Class AdaptiveRecvByteBufAllocator
java.lang.Object
io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator
io.netty.channel.AdaptiveRecvByteBufAllocator
- All Implemented Interfaces:
MaxMessagesRecvByteBufAllocator
,RecvByteBufAllocator
The
RecvByteBufAllocator
that automatically increases and
decreases the predicted buffer size on feed back.
It gradually increases the expected number of readable bytes if the previous read fully filled the allocated buffer. It gradually decreases the expected number of readable bytes if the read operation was not able to fill a certain amount of the allocated buffer two times consecutively. Otherwise, it keeps returning the same prediction.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator
DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle
Nested classes/interfaces inherited from interface io.netty.channel.RecvByteBufAllocator
RecvByteBufAllocator.DelegatingHandle, RecvByteBufAllocator.ExtendedHandle, RecvByteBufAllocator.Handle
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AdaptiveRecvByteBufAllocator
Deprecated.static final int
static final int
static final int
private static final int
private static final int
private final int
private final int
private final int
private final int
private final int
private static final int[]
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new predictor with the default parameters.AdaptiveRecvByteBufAllocator
(int minimum, int initial, int maximum) Creates a new predictor with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
getSizeTableIndex
(int size) Creates a new handle.respectMaybeMoreData
(boolean respectMaybeMoreData) Determine if future instances ofRecvByteBufAllocator.newHandle()
will stop reading if we think there is no more data.Methods inherited from class io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator
maxMessagesPerRead, maxMessagesPerRead, respectMaybeMoreData
-
Field Details
-
DEFAULT_MINIMUM
public static final int DEFAULT_MINIMUM- See Also:
-
DEFAULT_INITIAL
public static final int DEFAULT_INITIAL- See Also:
-
DEFAULT_MAXIMUM
public static final int DEFAULT_MAXIMUM- See Also:
-
INDEX_INCREMENT
private static final int INDEX_INCREMENT- See Also:
-
INDEX_DECREMENT
private static final int INDEX_DECREMENT- See Also:
-
SIZE_TABLE
private static final int[] SIZE_TABLE -
DEFAULT
Deprecated.There is state forDefaultMaxMessagesRecvByteBufAllocator.maxMessagesPerRead()
which is typically based upon channel type. -
minIndex
private final int minIndex -
maxIndex
private final int maxIndex -
initialIndex
private final int initialIndex -
minCapacity
private final int minCapacity -
maxCapacity
private final int maxCapacity
-
-
Constructor Details
-
AdaptiveRecvByteBufAllocator
public AdaptiveRecvByteBufAllocator()Creates a new predictor with the default parameters. With the default parameters, the expected buffer size starts from1024
, does not go down below64
, and does not go up above65536
. -
AdaptiveRecvByteBufAllocator
public AdaptiveRecvByteBufAllocator(int minimum, int initial, int maximum) Creates a new predictor with the specified parameters.- Parameters:
minimum
- the inclusive lower bound of the expected buffer sizeinitial
- the initial buffer size when no feed back was receivedmaximum
- the inclusive upper bound of the expected buffer size
-
-
Method Details
-
getSizeTableIndex
private static int getSizeTableIndex(int size) -
newHandle
Description copied from interface:RecvByteBufAllocator
Creates a new handle. The handle provides the actual operations and keeps the internal information which is required for predicting an optimal buffer capacity. -
respectMaybeMoreData
Description copied from class:DefaultMaxMessagesRecvByteBufAllocator
Determine if future instances ofRecvByteBufAllocator.newHandle()
will stop reading if we think there is no more data.- Overrides:
respectMaybeMoreData
in classDefaultMaxMessagesRecvByteBufAllocator
- Parameters:
respectMaybeMoreData
-true
to stop reading if we think there is no more data. This may save a system call to read from the socket, but if data has arrived in a racy fashion we may give up ourDefaultMaxMessagesRecvByteBufAllocator.maxMessagesPerRead()
quantum and have to wait for the selector to notify us of more data.false
to keep reading (up toDefaultMaxMessagesRecvByteBufAllocator.maxMessagesPerRead()
) or until there is no data when we attempt to read.
- Returns:
this
.
-
DefaultMaxMessagesRecvByteBufAllocator.maxMessagesPerRead()
which is typically based upon channel type.