Top Description Inners Fields Constructors Methods
io.netty.channel

public abstract Class DefaultMaxMessagesRecvByteBufAllocator

extends Object
implements MaxMessagesRecvByteBufAllocator
Class Inheritance
All Implemented Interfaces
io.netty.channel.MaxMessagesRecvByteBufAllocator, io.netty.channel.RecvByteBufAllocator
Known Direct Subclasses
io.netty.channel.ServerChannelRecvByteBufAllocator, io.netty.channel.AdaptiveRecvByteBufAllocator, io.netty.channel.FixedRecvByteBufAllocator
Static Imports
io.netty.util.internal.ObjectUtil.checkPositive

Default implementation of MaxMessagesRecvByteBufAllocator which respects ChannelConfig#isAutoRead() and also prevents overflow.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract class
DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle

Deprecated as a consequence of RecvByteBufAllocator.ExtendedHandle being deprecated.
Focuses on enforcing the maximum messages per read condition for continueReading().

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
public
pack-priv
DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead, boolean ignoreBytesRead)

Method Summary

Modifier and TypeMethod and Description
public int
maxMessagesPerRead()

Implements io.netty.channel.MaxMessagesRecvByteBufAllocator.maxMessagesPerRead.

Returns the maximum number of messages to read per read loop.
public MaxMessagesRecvByteBufAllocator
maxMessagesPerRead(int maxMessagesPerRead)

Implements io.netty.channel.MaxMessagesRecvByteBufAllocator.maxMessagesPerRead.

Sets the maximum number of messages to read per read loop.
public DefaultMaxMessagesRecvByteBufAllocator

Returns:

this.
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
)

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

public final boolean

Returns:

  • 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
()

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ignoreBytesReadback to summary
private final boolean ignoreBytesRead
maxMessagesPerReadback to summary
private volatile int maxMessagesPerRead
respectMaybeMoreDataback to summary
private volatile boolean respectMaybeMoreData

Constructor Detail

DefaultMaxMessagesRecvByteBufAllocatorback to summary
public DefaultMaxMessagesRecvByteBufAllocator()
DefaultMaxMessagesRecvByteBufAllocatorback to summary
public DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead)
DefaultMaxMessagesRecvByteBufAllocatorback to summary
pack-priv DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead, boolean ignoreBytesRead)

Method Detail

maxMessagesPerReadback to summary
public int maxMessagesPerRead()

Implements io.netty.channel.MaxMessagesRecvByteBufAllocator.maxMessagesPerRead.

Doc from io.netty.channel.MaxMessagesRecvByteBufAllocator.maxMessagesPerRead.

Returns the maximum number of messages 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 multiple messages.

Annotations
@Override
maxMessagesPerReadback to summary
public MaxMessagesRecvByteBufAllocator maxMessagesPerRead(int maxMessagesPerRead)

Implements io.netty.channel.MaxMessagesRecvByteBufAllocator.maxMessagesPerRead.

Doc from io.netty.channel.MaxMessagesRecvByteBufAllocator.maxMessagesPerRead.

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

Annotations
@Override
respectMaybeMoreDataback to summary
public DefaultMaxMessagesRecvByteBufAllocator respectMaybeMoreData(boolean 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:DefaultMaxMessagesRecvByteBufAllocator

this.

respectMaybeMoreDataback to summary
public final boolean respectMaybeMoreData()

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

Returns: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.
io.netty.channel back to summary

public abstract Class DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle

extends Object
implements ExtendedHandle
Class Inheritance
  • java.lang.Object
  • io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle
All Implemented Interfaces
io.netty.channel.RecvByteBufAllocator.ExtendedHandle, io.netty.channel.RecvByteBufAllocator.Handle
Known Direct Subclasses
io.netty.channel.AdaptiveRecvByteBufAllocator.HandleImpl, io.netty.channel.FixedRecvByteBufAllocator.HandleImpl

Deprecated

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

Focuses on enforcing the maximum messages per read condition for continueReading().

Field Summary

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

Constructor Summary

AccessConstructor and Description
public

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 int
attemptedBytesRead()

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

Get how many bytes the read operation will (or did) attempt to read.
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 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 final 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 final 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.

Only ChannelConfig#getMaxMessagesPerRead() is used.
protected final int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attemptedBytesReadback to summary
private int attemptedBytesRead
configback to summary
private ChannelConfig config
defaultMaybeMoreSupplierback to summary
private final UncheckedBooleanSupplier defaultMaybeMoreSupplier
lastBytesReadback to summary
private int lastBytesRead
maxMessagePerReadback to summary
private int maxMessagePerRead
respectMaybeMoreDataback to summary
private final boolean respectMaybeMoreData
totalBytesReadback to summary
private int totalBytesRead
totalMessagesback to summary
private int totalMessages

Constructor Detail

MaxMessageHandleback to summary
public MaxMessageHandle()

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 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
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
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
incMessagesReadback to summary
public final 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 final 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.

Only ChannelConfig#getMaxMessagesPerRead() is used.

Parameters
config:ChannelConfig

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

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

Annotations
@Override
totalBytesReadback to summary
protected final int totalBytesRead()