ReadHandleFactory 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 unable 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 |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| private static final int | |
| private static final int | |
| private final int | |
| private final int | |
| private final int | |
| private static final int[] |
| Access | Constructor and Description |
|---|---|
| public | |
| public | AdaptiveReadHandleFactory(int
the maximum number of messages to read per read loop invocation. maxMessagesPerRead)Creates a new predictor with the default parameters. |
| public | AdaptiveReadHandleFactory(int
the maximum number of messages to read per read loop invocation. maxMessagesPerRead, int the inclusive lower bound of the expected buffer size minimum, int the initial buffer size when no feedback was received initial, int the inclusive upper bound of the expected buffer size maximum)Creates a new predictor with the specified parameters. |
| Modifier and Type | Method and Description |
|---|---|
| private static int | |
| public MaxMessagesReadHandleFactory. | newMaxMessageHandle(int
the maximum number of messages to read per read loop. maxMessagesPerRead)Implements abstract io. MaxMessageReadHandle to use.
|
| DEFAULT_INITIAL | back to summary |
|---|---|
| pack-priv static final int DEFAULT_INITIAL | |
| DEFAULT_MAXIMUM | back to summary |
|---|---|
| pack-priv static final int DEFAULT_MAXIMUM | |
| DEFAULT_MINIMUM | back to summary |
|---|---|
| pack-priv static final int DEFAULT_MINIMUM | |
| INDEX_DECREMENT | back to summary |
|---|---|
| private static final int INDEX_DECREMENT | |
| INDEX_INCREMENT | back to summary |
|---|---|
| private static final int INDEX_INCREMENT | |
| initial | back to summary |
|---|---|
| private final int initial | |
| maxIndex | back to summary |
|---|---|
| private final int maxIndex | |
| minIndex | back to summary |
|---|---|
| private final int minIndex | |
| SIZE_TABLE | back to summary |
|---|---|
| private static final int[] SIZE_TABLE | |
| AdaptiveReadHandleFactory | back to summary |
|---|---|
| public AdaptiveReadHandleFactory() Creates a new predictor with the default parameters. With the default
parameters, the expected buffer size starts from | |
| AdaptiveReadHandleFactory | back to summary |
|---|---|
| public AdaptiveReadHandleFactory(int maxMessagesPerRead) Creates a new predictor with the default parameters. With the default
parameters, the expected buffer size starts from
| |
| AdaptiveReadHandleFactory | back to summary |
|---|---|
| public AdaptiveReadHandleFactory(int maxMessagesPerRead, int minimum, int initial, int maximum) Creates a new predictor with the specified parameters.
| |
| getSizeTableIndex | back to summary |
|---|---|
| private static int getSizeTableIndex(final int size) | |
| newMaxMessageHandle | back to summary |
|---|---|
| public MaxMessagesReadHandleFactory. Implements abstract io. Doc from io. Creates a new
| |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private int | |
| private final int | |
| private final int | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public int | estimatedBufferCapacity()
Implements io. |
| public boolean | lastRead(int
The number of bytes the read operation did attempt to read. attemptedBytesRead, int The number of bytes from the previous read operation. This may be negative if a
read error occurs. actualBytesRead, int The number of messages read. numMessagesRead)Overrides io. Implements io. ReadHandle of the last read operation and its result.
|
| public void | readComplete()
Overrides io. Implements io. |
| private void | |
| private int |
| decreaseNow | back to summary |
|---|---|
| private boolean decreaseNow | |
| index | back to summary |
|---|---|
| private int index | |
| maxIndex | back to summary |
|---|---|
| private final int maxIndex | |
| minIndex | back to summary |
|---|---|
| private final int minIndex | |
| nextReceiveBufferSize | back to summary |
|---|---|
| private int nextReceiveBufferSize | |
| totalBytesRead | back to summary |
|---|---|
| private int totalBytesRead | |
| ReadHandleImpl | back to summary |
|---|---|
| pack-priv ReadHandleImpl(int maxMessagesPerRead, int minIndex, int maxIndex, int initial) | |
| estimatedBufferCapacity | back to summary |
|---|---|
| public int estimatedBufferCapacity() Implements io. Doc from io. Guess the capacity for the next receive buffer that is probably large enough to read all inbound data and small enough not to waste its space.
| |
| lastRead | back to summary |
|---|---|
| public boolean lastRead(int attemptedBytesRead, int actualBytesRead, int numMessagesRead) Overrides io. Implements io. Doc from io. Notify the
| |
| readComplete | back to summary |
|---|---|
| public void readComplete() Overrides io. Implements io. Doc from io. Method that must be called once the read loop was completed.
| |
| record | back to summary |
|---|---|
| private void record(int actualReadBytes) | |
| totalBytesRead | back to summary |
|---|---|
| private int totalBytesRead() | |