TestNumReadsRecvByteBufAllocator Class — netty Architecture
Architecture documentation for the TestNumReadsRecvByteBufAllocator class in SocketReadPendingTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5fbbe960_f8e2_652c_f3ce_76e3819f8f44["TestNumReadsRecvByteBufAllocator"] 0a9d5e8f_8342_91e5_cfc3_dc36989130d7["SocketReadPendingTest.java"] 5fbbe960_f8e2_652c_f3ce_76e3819f8f44 -->|defined in| 0a9d5e8f_8342_91e5_cfc3_dc36989130d7 bb59e9fc_edbd_4704_8ee5_4d1bba52be6e["TestNumReadsRecvByteBufAllocator()"] 5fbbe960_f8e2_652c_f3ce_76e3819f8f44 -->|method| bb59e9fc_edbd_4704_8ee5_4d1bba52be6e 253a62ac_6415_0b08_8d21_0847456d6046["ExtendedHandle()"] 5fbbe960_f8e2_652c_f3ce_76e3819f8f44 -->|method| 253a62ac_6415_0b08_8d21_0847456d6046
Relationship Graph
Source Code
testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketReadPendingTest.java lines 144–212
private static final class TestNumReadsRecvByteBufAllocator implements RecvByteBufAllocator {
private final int numReads;
TestNumReadsRecvByteBufAllocator(int 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;
}
@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 testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketReadPendingTest.java.
Where is TestNumReadsRecvByteBufAllocator defined?
TestNumReadsRecvByteBufAllocator is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketReadPendingTest.java at line 144.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free