public class AdaptiveRecvByteBufAllocator extends java.lang.Object implements RecvByteBufAllocator
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.
Modifier and Type | Class and Description |
---|---|
private static class |
AdaptiveRecvByteBufAllocator.HandleImpl |
RecvByteBufAllocator.Handle
Modifier and Type | Field and Description |
---|---|
static AdaptiveRecvByteBufAllocator |
DEFAULT |
(package private) static int |
DEFAULT_INITIAL |
(package private) static int |
DEFAULT_MAXIMUM |
(package private) static int |
DEFAULT_MINIMUM |
private static int |
INDEX_DECREMENT |
private static int |
INDEX_INCREMENT |
private int |
initial |
private int |
maxIndex |
private int |
minIndex |
private static int[] |
SIZE_TABLE |
Modifier | Constructor and Description |
---|---|
private |
AdaptiveRecvByteBufAllocator()
Creates a new predictor with the default parameters.
|
|
AdaptiveRecvByteBufAllocator(int minimum,
int initial,
int maximum)
Creates a new predictor with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
private static int |
getSizeTableIndex(int size) |
RecvByteBufAllocator.Handle |
newHandle()
Creates a new handle.
|
static final int DEFAULT_MINIMUM
static final int DEFAULT_INITIAL
static final int DEFAULT_MAXIMUM
private static final int INDEX_INCREMENT
private static final int INDEX_DECREMENT
private static final int[] SIZE_TABLE
public static final AdaptiveRecvByteBufAllocator DEFAULT
private final int minIndex
private final int maxIndex
private final int initial
private AdaptiveRecvByteBufAllocator()
1024
, does not
go down below 64
, and does not go up above 65536
.public AdaptiveRecvByteBufAllocator(int minimum, int initial, int maximum)
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 sizeprivate static int getSizeTableIndex(int size)
public RecvByteBufAllocator.Handle newHandle()
RecvByteBufAllocator
newHandle
in interface RecvByteBufAllocator