DefaultMaxBytesRecvByteBufAllocator Class — netty Architecture
Architecture documentation for the DefaultMaxBytesRecvByteBufAllocator class in DefaultMaxBytesRecvByteBufAllocator.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a6fffba9_29a8_b949_2c80_f2125cda627f["DefaultMaxBytesRecvByteBufAllocator"] a07ae128_e91d_b91d_d244_c168b2593fa8["DefaultMaxBytesRecvByteBufAllocator.java"] a6fffba9_29a8_b949_2c80_f2125cda627f -->|defined in| a07ae128_e91d_b91d_d244_c168b2593fa8 6515f8a3_c96f_d2db_e34e_fbcc71228ed5["DefaultMaxBytesRecvByteBufAllocator()"] a6fffba9_29a8_b949_2c80_f2125cda627f -->|method| 6515f8a3_c96f_d2db_e34e_fbcc71228ed5 c0cbcf79_d20b_e4dc_5c63_9e10f1c2e738["Handle()"] a6fffba9_29a8_b949_2c80_f2125cda627f -->|method| c0cbcf79_d20b_e4dc_5c63_9e10f1c2e738 e28f8fd4_317f_9494_c541_63c5e8551cfa["maxBytesPerRead()"] a6fffba9_29a8_b949_2c80_f2125cda627f -->|method| e28f8fd4_317f_9494_c541_63c5e8551cfa 1ea9bc6a_23b6_bb79_891e_6a19cfdbb77f["maxBytesPerIndividualRead()"] a6fffba9_29a8_b949_2c80_f2125cda627f -->|method| 1ea9bc6a_23b6_bb79_891e_6a19cfdbb77f b8fc490c_cc7c_0510_249d_074e5f61af33["maxBytesPerReadPair()"] a6fffba9_29a8_b949_2c80_f2125cda627f -->|method| b8fc490c_cc7c_0510_249d_074e5f61af33 7eb09b0b_cb8c_5235_37aa_026e65773764["checkMaxBytesPerReadPair()"] a6fffba9_29a8_b949_2c80_f2125cda627f -->|method| 7eb09b0b_cb8c_5235_37aa_026e65773764
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/DefaultMaxBytesRecvByteBufAllocator.java lines 31–195
public class DefaultMaxBytesRecvByteBufAllocator implements MaxBytesRecvByteBufAllocator {
private volatile int maxBytesPerRead;
private volatile int maxBytesPerIndividualRead;
private final class HandleImpl implements ExtendedHandle {
private int individualReadMax;
private int bytesToRead;
private int lastBytesRead;
private int attemptBytesRead;
private final UncheckedBooleanSupplier defaultMaybeMoreSupplier = new UncheckedBooleanSupplier() {
@Override
public boolean get() {
return attemptBytesRead == lastBytesRead;
}
};
@Override
public ByteBuf allocate(ByteBufAllocator alloc) {
return alloc.ioBuffer(guess());
}
@Override
public int guess() {
return Math.min(individualReadMax, bytesToRead);
}
@Override
public void reset(ChannelConfig config) {
bytesToRead = maxBytesPerRead();
individualReadMax = maxBytesPerIndividualRead();
}
@Override
public void incMessagesRead(int amt) {
}
@Override
public void lastBytesRead(int bytes) {
lastBytesRead = bytes;
// Ignore if bytes is negative, the interface contract states it will be detected externally after call.
// The value may be "invalid" after this point, but it doesn't matter because reading will be stopped.
bytesToRead -= bytes;
}
@Override
public int lastBytesRead() {
return lastBytesRead;
}
@Override
public boolean continueReading() {
return continueReading(defaultMaybeMoreSupplier);
}
@Override
public boolean continueReading(UncheckedBooleanSupplier maybeMoreDataSupplier) {
// Keep reading if we are allowed to read more bytes, and our last read filled up the buffer we provided.
return bytesToRead > 0 && maybeMoreDataSupplier.get();
}
@Override
public void readComplete() {
}
@Override
public void attemptedBytesRead(int bytes) {
attemptBytesRead = bytes;
}
@Override
public int attemptedBytesRead() {
return attemptBytesRead;
}
}
public DefaultMaxBytesRecvByteBufAllocator() {
this(64 * 1024, 64 * 1024);
}
public DefaultMaxBytesRecvByteBufAllocator(int maxBytesPerRead, int maxBytesPerIndividualRead) {
checkMaxBytesPerReadPair(maxBytesPerRead, maxBytesPerIndividualRead);
Source
Frequently Asked Questions
What is the DefaultMaxBytesRecvByteBufAllocator class?
DefaultMaxBytesRecvByteBufAllocator is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/DefaultMaxBytesRecvByteBufAllocator.java.
Where is DefaultMaxBytesRecvByteBufAllocator defined?
DefaultMaxBytesRecvByteBufAllocator is defined in transport/src/main/java/io/netty/channel/DefaultMaxBytesRecvByteBufAllocator.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free