TestNumReadsRecvByteBufAllocator Class — netty Architecture
Architecture documentation for the TestNumReadsRecvByteBufAllocator class in TestChannelInitializer.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD ead91d8a_8f94_e725_b13c_1ef2f0315bdd["TestNumReadsRecvByteBufAllocator"] a1d4214d_7c3f_2a95_0423_d9c11fead4b0["TestChannelInitializer.java"] ead91d8a_8f94_e725_b13c_1ef2f0315bdd -->|defined in| a1d4214d_7c3f_2a95_0423_d9c11fead4b0 28aa52f6_1180_e087_a53b_84ed9f6eb5d4["TestNumReadsRecvByteBufAllocator()"] ead91d8a_8f94_e725_b13c_1ef2f0315bdd -->|method| 28aa52f6_1180_e087_a53b_84ed9f6eb5d4 f1e0ebf3_4803_e35b_ca61_2d627c7fbced["ExtendedHandle()"] ead91d8a_8f94_e725_b13c_1ef2f0315bdd -->|method| f1e0ebf3_4803_e35b_ca61_2d627c7fbced
Relationship Graph
Source Code
codec-http2/src/test/java/io/netty/handler/codec/http2/TestChannelInitializer.java lines 53–121
static final class TestNumReadsRecvByteBufAllocator implements RecvByteBufAllocator {
private final AtomicInteger numReads;
private TestNumReadsRecvByteBufAllocator(AtomicInteger numReads) {
this.numReads = numReads;
}
@Override
public ExtendedHandle newHandle() {
return new ExtendedHandle() {
private int attemptedBytesRead;
private int lastBytesRead;
private int numMessagesRead;
@Override
public ByteBuf allocate(ByteBufAllocator alloc) {
return alloc.ioBuffer(guess(), guess());
}
@Override
public int guess() {
return 1; // only ever allocate buffers of size 1 to ensure the number of reads is controlled.
}
@Override
public void reset(ChannelConfig config) {
numMessagesRead = 0;
}
@Override
public void incMessagesRead(int numMessages) {
numMessagesRead += numMessages;
}
@Override
public void lastBytesRead(int bytes) {
lastBytesRead = bytes;
}
@Override
public int lastBytesRead() {
return lastBytesRead;
}
@Override
public void attemptedBytesRead(int bytes) {
attemptedBytesRead = bytes;
}
@Override
public int attemptedBytesRead() {
return attemptedBytesRead;
}
@Override
public boolean continueReading() {
return numMessagesRead < numReads.get();
}
@Override
public boolean continueReading(UncheckedBooleanSupplier maybeMoreDataSupplier) {
return continueReading();
}
@Override
public void readComplete() {
// Nothing needs to be done or adjusted after each read cycle is completed.
}
};
}
}
Source
Frequently Asked Questions
What is the TestNumReadsRecvByteBufAllocator class?
TestNumReadsRecvByteBufAllocator is a class in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/TestChannelInitializer.java.
Where is TestNumReadsRecvByteBufAllocator defined?
TestNumReadsRecvByteBufAllocator is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/TestChannelInitializer.java at line 53.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free