Top Description Inners Fields Constructors Methods
io.netty.channel

public Class AdaptiveRecvByteBufAllocator

extends DefaultMaxMessagesRecvByteBufAllocator
Class Inheritance
Imports
java.util.ArrayList, .List

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 and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
public static final AdaptiveRecvByteBufAllocator
DEFAULT

Deprecated There is state for maxMessagesPerRead() which is typically based upon channel type.
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[]

Constructor Summary

AccessConstructor and Description
public
AdaptiveRecvByteBufAllocator()

Creates a new predictor with the default parameters.

public
AdaptiveRecvByteBufAllocator(int
the inclusive lower bound of the expected buffer size
minimum
,
int
the initial buffer size when no feed back was received
initial
,
int
the inclusive upper bound of the expected buffer size
maximum
)

Creates a new predictor with the specified parameters.

Method Summary

Modifier and TypeMethod and Description
private static int
getSizeTableIndex(final int size)

public RecvByteBufAllocator.Handle
newHandle()

Implements io.netty.channel.RecvByteBufAllocator.newHandle.

Deprecated as a consequence of RecvByteBufAllocator.Handle being deprecated.
Creates a new handle.
public AdaptiveRecvByteBufAllocator
respectMaybeMoreData(boolean
  • 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 our maxMessagesPerRead() quantum and have to wait for the selector to notify us of more data.
  • false to keep reading (up to maxMessagesPerRead()) or until there is no data when we attempt to read.
respectMaybeMoreData
)

Overrides io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator.respectMaybeMoreData.

Determine if future instances of newHandle() will stop reading if we think there is no more data.
Inherited from io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator:
maxMessagesPerReadmaxMessagesPerReadrespectMaybeMoreData

Field Detail

DEFAULTback to summary
public static final AdaptiveRecvByteBufAllocator DEFAULT

Deprecated

There is state for maxMessagesPerRead() which is typically based upon channel type.

Annotations
@Deprecated
DEFAULT_INITIALback to summary
pack-priv static final int DEFAULT_INITIAL
DEFAULT_MAXIMUMback to summary
pack-priv static final int DEFAULT_MAXIMUM
DEFAULT_MINIMUMback to summary
pack-priv static final int DEFAULT_MINIMUM
INDEX_DECREMENTback to summary
private static final int INDEX_DECREMENT
INDEX_INCREMENTback to summary
private static final int INDEX_INCREMENT
initialback to summary
private final int initial
maxIndexback to summary
private final int maxIndex
minIndexback to summary
private final int minIndex
SIZE_TABLEback to summary
private static final int[] SIZE_TABLE

Constructor Detail

AdaptiveRecvByteBufAllocatorback to summary
public AdaptiveRecvByteBufAllocator()

Creates a new predictor with the default parameters. With the default parameters, the expected buffer size starts from 1024, does not go down below 64, and does not go up above 65536.

AdaptiveRecvByteBufAllocatorback to summary
public AdaptiveRecvByteBufAllocator(int minimum, int initial, int maximum)

Creates a new predictor with the specified parameters.

Parameters
minimum:int

the inclusive lower bound of the expected buffer size

initial:int

the initial buffer size when no feed back was received

maximum:int

the inclusive upper bound of the expected buffer size

Method Detail

getSizeTableIndexback to summary
private static int getSizeTableIndex(final int size)
newHandleback to summary
public RecvByteBufAllocator.Handle newHandle()

Implements io.netty.channel.RecvByteBufAllocator.newHandle.

Doc from io.netty.channel.RecvByteBufAllocator.newHandle.

Deprecated

as a consequence of RecvByteBufAllocator.Handle being deprecated. See corresponding docs for further information.

Creates a new handle. The handle provides the actual operations and keeps the internal information which is required for predicting an optimal buffer capacity.

Annotations
@SuppressWarnings:deprecation
@Override
respectMaybeMoreDataback to summary
public AdaptiveRecvByteBufAllocator respectMaybeMoreData(boolean respectMaybeMoreData)

Overrides io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator.respectMaybeMoreData.

Doc from io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator.respectMaybeMoreData.

Determine if future instances of newHandle() will stop reading if we think there is no more data.

Parameters
respectMaybeMoreData:boolean

  • 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 our maxMessagesPerRead() quantum and have to wait for the selector to notify us of more data.
  • false to keep reading (up to maxMessagesPerRead()) or until there is no data when we attempt to read.
Returns:AdaptiveRecvByteBufAllocator

this.

Annotations
@Override
io.netty.channel back to summary

private final Class AdaptiveRecvByteBufAllocator.HandleImpl

extends MaxMessageHandle
Class Inheritance

Deprecated

as a consequence of DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle being deprecated. See corresponding docs for further information.

Field Summary

Modifier and TypeField and Description
private boolean
private int
private final int
private final int
private int

Constructor Summary

AccessConstructor and Description
pack-priv
HandleImpl(int minIndex, int maxIndex, int initial)

Method Summary

Modifier and TypeMethod and Description
public int
guess()

Implements io.netty.channel.RecvByteBufAllocator.Handle.guess.

Similar to allocate(ByteBufAllocator) except that it does not allocate anything but just tells the capacity.
public void
lastBytesRead(int
The number of bytes from the previous read operation. This may be negative if an read error occurs. If a negative value is seen it is expected to be return on the next call to lastBytesRead(). A negative value will signal a termination condition enforced externally to this class and is not required to be enforced in continueReading().
bytes
)

Overrides io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle.lastBytesRead.

Implements io.netty.channel.RecvByteBufAllocator.Handle.lastBytesRead.

Set the bytes that have been read for the last read operation.
public void
private void
record(int actualReadBytes)

Inherited from io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle:
allocateattemptedBytesReadattemptedBytesReadcontinueReadingcontinueReadingincMessagesReadlastBytesReadresettotalBytesRead

Field Detail

decreaseNowback to summary
private boolean decreaseNow
indexback to summary
private int index
maxIndexback to summary
private final int maxIndex
minIndexback to summary
private final int minIndex
nextReceiveBufferSizeback to summary
private int nextReceiveBufferSize

Constructor Detail

HandleImplback to summary
pack-priv HandleImpl(int minIndex, int maxIndex, int initial)

Method Detail

guessback to summary
public int guess()

Implements io.netty.channel.RecvByteBufAllocator.Handle.guess.

Doc from io.netty.channel.RecvByteBufAllocator.Handle.guess.

Similar to allocate(ByteBufAllocator) except that it does not allocate anything but just tells the capacity.

Annotations
@Override
lastBytesReadback to summary
public void lastBytesRead(int bytes)

Overrides io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle.lastBytesRead.

Implements io.netty.channel.RecvByteBufAllocator.Handle.lastBytesRead.

Doc from io.netty.channel.RecvByteBufAllocator.Handle.lastBytesRead.

Set the bytes that have been read for the last read operation. This may be used to increment the number of bytes that have been read.

Parameters
bytes:int

The number of bytes from the previous read operation. This may be negative if an read error occurs. If a negative value is seen it is expected to be return on the next call to lastBytesRead(). A negative value will signal a termination condition enforced externally to this class and is not required to be enforced in continueReading().

Annotations
@Override
readCompleteback to summary
public void readComplete()

Overrides io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle.readComplete.

Implements io.netty.channel.RecvByteBufAllocator.Handle.readComplete.

Doc from io.netty.channel.RecvByteBufAllocator.Handle.readComplete.

The read has completed.

Annotations
@Override
recordback to summary
private void record(int actualReadBytes)