Top Description Inners Fields Constructors Methods
io.netty.channel

public Class DefaultMaxBytesRecvByteBufAllocator

extends Object
implements MaxBytesRecvByteBufAllocator
Class Inheritance
All Implemented Interfaces
io.netty.channel.MaxBytesRecvByteBufAllocator, io.netty.channel.RecvByteBufAllocator
Static Imports
io.netty.util.internal.ObjectUtil.checkPositive

The RecvByteBufAllocator that yields a buffer size prediction based upon decrementing the value from the max bytes per read.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private volatile int
private volatile int

Constructor Summary

AccessConstructor and Description
public
public
DefaultMaxBytesRecvByteBufAllocator(int maxBytesPerRead, int maxBytesPerIndividualRead)

Method Summary

Modifier and TypeMethod and Description
private static void
checkMaxBytesPerReadPair(int maxBytesPerRead, int maxBytesPerIndividualRead)

public int
maxBytesPerIndividualRead()

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerIndividualRead.

Returns the maximum number of bytes to read per individual read operation.
public DefaultMaxBytesRecvByteBufAllocator
maxBytesPerIndividualRead(int maxBytesPerIndividualRead)

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerIndividualRead.

Sets the maximum number of bytes to read per individual read operation.
public int
maxBytesPerRead()

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerRead.

Returns the maximum number of bytes to read per read loop.
public DefaultMaxBytesRecvByteBufAllocator
maxBytesPerRead(int maxBytesPerRead)

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerRead.

Sets the maximum number of bytes to read per read loop.
public synchronized Map.Entry<Integer, Integer>
maxBytesPerReadPair()

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerReadPair.

Atomic way to get the maximum number of bytes to read for a read loop and per individual read operation.
public DefaultMaxBytesRecvByteBufAllocator
maxBytesPerReadPair(int maxBytesPerRead, int maxBytesPerIndividualRead)

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerReadPair.

Sets the maximum number of bytes to read for a read loop and per individual read operation.
public RecvByteBufAllocator.Handle
newHandle()

Implements io.netty.channel.RecvByteBufAllocator.newHandle.

Deprecated as a consequence of RecvByteBufAllocator.Handle being deprecated.
Creates a new handle.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

maxBytesPerIndividualReadback to summary
private volatile int maxBytesPerIndividualRead
maxBytesPerReadback to summary
private volatile int maxBytesPerRead

Constructor Detail

DefaultMaxBytesRecvByteBufAllocatorback to summary
public DefaultMaxBytesRecvByteBufAllocator()
DefaultMaxBytesRecvByteBufAllocatorback to summary
public DefaultMaxBytesRecvByteBufAllocator(int maxBytesPerRead, int maxBytesPerIndividualRead)

Method Detail

checkMaxBytesPerReadPairback to summary
private static void checkMaxBytesPerReadPair(int maxBytesPerRead, int maxBytesPerIndividualRead)
maxBytesPerIndividualReadback to summary
public int maxBytesPerIndividualRead()

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerIndividualRead.

Doc from io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerIndividualRead.

Returns the maximum number of bytes to read per individual read operation. a channelRead() event. If this value is greater than 1, an event loop might attempt to read multiple times to procure bytes.

Annotations
@Override
maxBytesPerIndividualReadback to summary
public DefaultMaxBytesRecvByteBufAllocator maxBytesPerIndividualRead(int maxBytesPerIndividualRead)

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerIndividualRead.

Doc from io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerIndividualRead.

Sets the maximum number of bytes to read per individual read operation. If this value is greater than 1, an event loop might attempt to read multiple times to procure bytes.

Annotations
@Override
maxBytesPerReadback to summary
public int maxBytesPerRead()

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerRead.

Doc from io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerRead.

Returns the maximum number of bytes to read per read loop. a channelRead() event. If this value is greater than 1, an event loop might attempt to read multiple times to procure bytes.

Annotations
@Override
maxBytesPerReadback to summary
public DefaultMaxBytesRecvByteBufAllocator maxBytesPerRead(int maxBytesPerRead)

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerRead.

Doc from io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerRead.

Sets the maximum number of bytes to read per read loop. If this value is greater than 1, an event loop might attempt to read multiple times to procure bytes.

Annotations
@Override
maxBytesPerReadPairback to summary
public synchronized Map.Entry<Integer, Integer> maxBytesPerReadPair()

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerReadPair.

Doc from io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerReadPair.

Atomic way to get the maximum number of bytes to read for a read loop and per individual read operation. If this value is greater than 1, an event loop might attempt to read multiple times to procure bytes.

Returns:Map.Entry<Integer, Integer>

The Key is from maxBytesPerRead(). The Value is from maxBytesPerIndividualRead()

Annotations
@Override
maxBytesPerReadPairback to summary
public DefaultMaxBytesRecvByteBufAllocator maxBytesPerReadPair(int maxBytesPerRead, int maxBytesPerIndividualRead)

Implements io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerReadPair.

Doc from io.netty.channel.MaxBytesRecvByteBufAllocator.maxBytesPerReadPair.

Sets the maximum number of bytes to read for a read loop and per individual read operation. If this value is greater than 1, an event loop might attempt to read multiple times to procure bytes.

Parameters
maxBytesPerRead:int

see maxBytesPerRead(int)

maxBytesPerIndividualRead:int

see maxBytesPerIndividualRead(int)

Annotations
@Override
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
io.netty.channel back to summary

private final Class DefaultMaxBytesRecvByteBufAllocator.HandleImpl

extends Object
implements ExtendedHandle
Class Inheritance
  • java.lang.Object
  • io.netty.channel.DefaultMaxBytesRecvByteBufAllocator.HandleImpl
All Implemented Interfaces
io.netty.channel.RecvByteBufAllocator.ExtendedHandle, io.netty.channel.RecvByteBufAllocator.Handle

Deprecated

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

Field Summary

Modifier and TypeField and Description
private int
private int
private final UncheckedBooleanSupplier
private int
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ByteBuf
allocate(ByteBufAllocator alloc)

Implements io.netty.channel.RecvByteBufAllocator.Handle.allocate.

Creates a new receive buffer whose capacity is probably large enough to read all inbound data and small enough not to waste its space.
public void
attemptedBytesRead(int
How many bytes the read operation will (or did) attempt to read.
bytes
)

Implements io.netty.channel.RecvByteBufAllocator.Handle.attemptedBytesRead.

Set how many bytes the read operation will (or did) attempt to read.
public int
attemptedBytesRead()

Implements io.netty.channel.RecvByteBufAllocator.Handle.attemptedBytesRead.

Get how many bytes the read operation will (or did) attempt to read.
public boolean
continueReading()

Implements io.netty.channel.RecvByteBufAllocator.Handle.continueReading.

Determine if the current read loop should continue.
public boolean
continueReading(UncheckedBooleanSupplier
A supplier that determines if there maybe more data to read.
maybeMoreDataSupplier
)

Implements io.netty.channel.RecvByteBufAllocator.ExtendedHandle.continueReading.

Same as Handle#continueReading() except "more data" is determined by the supplier parameter.
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
incMessagesRead(int
The amount to increment by.
amt
)

Implements io.netty.channel.RecvByteBufAllocator.Handle.incMessagesRead.

Increment the number of messages that have been read for the current read loop.
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
)

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

Set the bytes that have been read for the last read operation.
public int
lastBytesRead()

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

Get the amount of bytes for the previous read operation.
public void
public void
reset(ChannelConfig
The channel configuration which may impact this object's behavior.
config
)

Implements io.netty.channel.RecvByteBufAllocator.Handle.reset.

Reset any counters that have accumulated and recommend how many messages/bytes should be read for the next read loop.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attemptBytesReadback to summary
private int attemptBytesRead
bytesToReadback to summary
private int bytesToRead
defaultMaybeMoreSupplierback to summary
private final UncheckedBooleanSupplier defaultMaybeMoreSupplier
individualReadMaxback to summary
private int individualReadMax
lastBytesReadback to summary
private int lastBytesRead

Constructor Detail

HandleImplback to summary
private HandleImpl()

Method Detail

allocateback to summary
public ByteBuf allocate(ByteBufAllocator alloc)

Implements io.netty.channel.RecvByteBufAllocator.Handle.allocate.

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

Creates a new receive buffer whose capacity is probably large enough to read all inbound data and small enough not to waste its space.

Annotations
@Override
attemptedBytesReadback to summary
public void attemptedBytesRead(int bytes)

Implements io.netty.channel.RecvByteBufAllocator.Handle.attemptedBytesRead.

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

Set how many bytes the read operation will (or did) attempt to read.

Parameters
bytes:int

How many bytes the read operation will (or did) attempt to read.

Annotations
@Override
attemptedBytesReadback to summary
public int attemptedBytesRead()

Implements io.netty.channel.RecvByteBufAllocator.Handle.attemptedBytesRead.

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

Get how many bytes the read operation will (or did) attempt to read.

Returns:int

How many bytes the read operation will (or did) attempt to read.

Annotations
@Override
continueReadingback to summary
public boolean continueReading()

Implements io.netty.channel.RecvByteBufAllocator.Handle.continueReading.

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

Determine if the current read loop should continue.

Returns:boolean

true if the read loop should continue reading. false if the read loop is complete.

Annotations
@Override
continueReadingback to summary
public boolean continueReading(UncheckedBooleanSupplier maybeMoreDataSupplier)

Implements io.netty.channel.RecvByteBufAllocator.ExtendedHandle.continueReading.

Doc from io.netty.channel.RecvByteBufAllocator.ExtendedHandle.continueReading.

Same as Handle#continueReading() except "more data" is determined by the supplier parameter.

Parameters
maybeMoreDataSupplier:UncheckedBooleanSupplier

A supplier that determines if there maybe more data to read.

Annotations
@Override
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
incMessagesReadback to summary
public void incMessagesRead(int amt)

Implements io.netty.channel.RecvByteBufAllocator.Handle.incMessagesRead.

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

Increment the number of messages that have been read for the current read loop.

Parameters
amt:int

The amount to increment by.

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

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
lastBytesReadback to summary
public int lastBytesRead()

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

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

Get the amount of bytes for the previous read operation.

Returns:int

The amount of bytes for the previous read operation.

Annotations
@Override
readCompleteback to summary
public void readComplete()

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

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

The read has completed.

Annotations
@Override
resetback to summary
public void reset(ChannelConfig config)

Implements io.netty.channel.RecvByteBufAllocator.Handle.reset.

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

Reset any counters that have accumulated and recommend how many messages/bytes should be read for the next read loop.

This may be used by continueReading() to determine if the read operation should complete.

This is only ever a hint and may be ignored by the implementation.
Parameters
config:ChannelConfig

The channel configuration which may impact this object's behavior.

Annotations
@Override