Package io.netty.channel
Class AdaptiveRecvByteBufAllocator
- java.lang.Object
-
- io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator
-
- io.netty.channel.AdaptiveRecvByteBufAllocator
-
- All Implemented Interfaces:
MaxMessagesRecvByteBufAllocator
,RecvByteBufAllocator
public class AdaptiveRecvByteBufAllocator extends DefaultMaxMessagesRecvByteBufAllocator
TheRecvByteBufAllocator
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 io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator
DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle
-
Nested classes/interfaces inherited from interface io.netty.channel.RecvByteBufAllocator
RecvByteBufAllocator.DelegatingHandle, RecvByteBufAllocator.ExtendedHandle, RecvByteBufAllocator.Handle
-
-
Field Summary
Fields Modifier and Type Field Description static AdaptiveRecvByteBufAllocator
DEFAULT
Deprecated.There is state forDefaultMaxMessagesRecvByteBufAllocator.maxMessagesPerRead()
which is typically based upon channel type.static int
DEFAULT_INITIAL
static int
DEFAULT_MAXIMUM
static int
DEFAULT_MINIMUM
-
Constructor Summary
Constructors Constructor Description AdaptiveRecvByteBufAllocator()
Creates a new predictor with the default parameters.AdaptiveRecvByteBufAllocator(int minimum, int initial, int maximum)
Creates a new predictor with the specified parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RecvByteBufAllocator.Handle
newHandle()
Creates a new handle.AdaptiveRecvByteBufAllocator
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 Detail
-
DEFAULT_MINIMUM
public static final int DEFAULT_MINIMUM
- See Also:
- Constant Field Values
-
DEFAULT_INITIAL
public static final int DEFAULT_INITIAL
- See Also:
- Constant Field Values
-
DEFAULT_MAXIMUM
public static final int DEFAULT_MAXIMUM
- See Also:
- Constant Field Values
-
DEFAULT
@Deprecated public static final AdaptiveRecvByteBufAllocator DEFAULT
Deprecated.There is state forDefaultMaxMessagesRecvByteBufAllocator.maxMessagesPerRead()
which is typically based upon channel type.
-
-
Constructor Detail
-
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 Detail
-
newHandle
public RecvByteBufAllocator.Handle 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
public AdaptiveRecvByteBufAllocator respectMaybeMoreData(boolean 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
.
-
-