DefaultMaxMessagesRecvByteBufAllocator Class — netty Architecture
Architecture documentation for the DefaultMaxMessagesRecvByteBufAllocator class in DefaultMaxMessagesRecvByteBufAllocator.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c2cbc84f_5b25_787d_46d1_dabc917cffeb["DefaultMaxMessagesRecvByteBufAllocator"] dbaa41b6_d847_4a41_5726_7a88eeb05f45["DefaultMaxMessagesRecvByteBufAllocator.java"] c2cbc84f_5b25_787d_46d1_dabc917cffeb -->|defined in| dbaa41b6_d847_4a41_5726_7a88eeb05f45 cfeb7aaf_4d1d_c665_a1bd_2795997dcd34["DefaultMaxMessagesRecvByteBufAllocator()"] c2cbc84f_5b25_787d_46d1_dabc917cffeb -->|method| cfeb7aaf_4d1d_c665_a1bd_2795997dcd34 464cb610_8be3_873a_cf0a_c67da1a30e22["maxMessagesPerRead()"] c2cbc84f_5b25_787d_46d1_dabc917cffeb -->|method| 464cb610_8be3_873a_cf0a_c67da1a30e22 076fe437_03cc_542f_9224_6b55a97c22b1["MaxMessagesRecvByteBufAllocator()"] c2cbc84f_5b25_787d_46d1_dabc917cffeb -->|method| 076fe437_03cc_542f_9224_6b55a97c22b1 25e96eec_b981_690b_8c9f_a58bf8067b11["respectMaybeMoreData()"] c2cbc84f_5b25_787d_46d1_dabc917cffeb -->|method| 25e96eec_b981_690b_8c9f_a58bf8067b11
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/DefaultMaxMessagesRecvByteBufAllocator.java lines 28–171
public abstract class DefaultMaxMessagesRecvByteBufAllocator implements MaxMessagesRecvByteBufAllocator {
private final boolean ignoreBytesRead;
private volatile int maxMessagesPerRead;
private volatile boolean respectMaybeMoreData = true;
public DefaultMaxMessagesRecvByteBufAllocator() {
this(1);
}
public DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead) {
this(maxMessagesPerRead, false);
}
DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead, boolean ignoreBytesRead) {
this.ignoreBytesRead = ignoreBytesRead;
maxMessagesPerRead(maxMessagesPerRead);
}
@Override
public int maxMessagesPerRead() {
return maxMessagesPerRead;
}
@Override
public MaxMessagesRecvByteBufAllocator maxMessagesPerRead(int maxMessagesPerRead) {
checkPositive(maxMessagesPerRead, "maxMessagesPerRead");
this.maxMessagesPerRead = maxMessagesPerRead;
return this;
}
/**
* Determine if future instances of {@link #newHandle()} will stop reading if we think there is no more data.
* @param respectMaybeMoreData
* <ul>
* <li>{@code 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 {@link #maxMessagesPerRead()}
* quantum and have to wait for the selector to notify us of more data.</li>
* <li>{@code false} to keep reading (up to {@link #maxMessagesPerRead()}) or until there is no data when we
* attempt to read.</li>
* </ul>
* @return {@code this}.
*/
public DefaultMaxMessagesRecvByteBufAllocator respectMaybeMoreData(boolean respectMaybeMoreData) {
this.respectMaybeMoreData = respectMaybeMoreData;
return this;
}
/**
* Get if future instances of {@link #newHandle()} will stop reading if we think there is no more data.
* @return
* <ul>
* <li>{@code 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 {@link #maxMessagesPerRead()}
* quantum and have to wait for the selector to notify us of more data.</li>
* <li>{@code false} to keep reading (up to {@link #maxMessagesPerRead()}) or until there is no data when we
* attempt to read.</li>
* </ul>
*/
public final boolean respectMaybeMoreData() {
return respectMaybeMoreData;
}
/**
* Focuses on enforcing the maximum messages per read condition for {@link #continueReading()}.
*/
public abstract class MaxMessageHandle implements ExtendedHandle {
private ChannelConfig config;
private int maxMessagePerRead;
private int totalMessages;
private int totalBytesRead;
private int attemptedBytesRead;
private int lastBytesRead;
private final boolean respectMaybeMoreData = DefaultMaxMessagesRecvByteBufAllocator.this.respectMaybeMoreData;
private final UncheckedBooleanSupplier defaultMaybeMoreSupplier = new UncheckedBooleanSupplier() {
@Override
public boolean get() {
return attemptedBytesRead == lastBytesRead;
}
};
/**
Source
Frequently Asked Questions
What is the DefaultMaxMessagesRecvByteBufAllocator class?
DefaultMaxMessagesRecvByteBufAllocator is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/DefaultMaxMessagesRecvByteBufAllocator.java.
Where is DefaultMaxMessagesRecvByteBufAllocator defined?
DefaultMaxMessagesRecvByteBufAllocator is defined in transport/src/main/java/io/netty/channel/DefaultMaxMessagesRecvByteBufAllocator.java at line 28.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free