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 classes/interfaces inherited from class DefaultMaxMessagesRecvByteBufAllocator
DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandleNested classes/interfaces inherited from interface RecvByteBufAllocator
RecvByteBufAllocator.DelegatingHandle, RecvByteBufAllocator.ExtendedHandle, RecvByteBufAllocator.Handle -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AdaptiveRecvByteBufAllocatorDeprecated.static final intstatic final intstatic 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 TypeMethodDescriptionCreates 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 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:
-
DEFAULT
Deprecated.There is state forDefaultMaxMessagesRecvByteBufAllocator.maxMessagesPerRead()which is typically based upon channel type.
-
-
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
-
newHandle
Description copied from interface:RecvByteBufAllocatorCreates 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:DefaultMaxMessagesRecvByteBufAllocatorDetermine if future instances ofRecvByteBufAllocator.newHandle()will stop reading if we think there is no more data.- Overrides:
respectMaybeMoreDatain classDefaultMaxMessagesRecvByteBufAllocator- Parameters:
respectMaybeMoreData-trueto 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.falseto 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.