AdaptiveRecvByteBufAllocatorTest Class — netty Architecture
Architecture documentation for the AdaptiveRecvByteBufAllocatorTest class in AdaptiveRecvByteBufAllocatorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5011819c_2beb_6635_01ff_c14382c1d5a5["AdaptiveRecvByteBufAllocatorTest"] e89da929_7e79_87f3_bd2a_56718231076f["AdaptiveRecvByteBufAllocatorTest.java"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|defined in| e89da929_7e79_87f3_bd2a_56718231076f 25ceefba_fadb_9014_1ede_71361d3d4c67["setup()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| 25ceefba_fadb_9014_1ede_71361d3d4c67 017fec3b_bf20_e9e5_7120_482a58b464f0["rampUpBeforeReadCompleteWhenLargeDataPending()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| 017fec3b_bf20_e9e5_7120_482a58b464f0 7208538e_b76b_2c1a_f85f_e92baeb770f6["memoryAllocationIntervalsTest()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| 7208538e_b76b_2c1a_f85f_e92baeb770f6 e6657a90_81d4_457e_efc2_a708c011c893["computingNext()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| e6657a90_81d4_457e_efc2_a708c011c893 4d09daaf_19e6_d91b_b08d_0d8958843b49["lastPartialReadDoesNotRampDown()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| 4d09daaf_19e6_d91b_b08d_0d8958843b49 2f3076f0_ee77_2120_4c99_02a0890d4925["lastPartialReadCanRampUp()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| 2f3076f0_ee77_2120_4c99_02a0890d4925 33c1adff_8ea2_727e_0d9d_9f71cbaa89a4["doesNotExceedMaximum()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| 33c1adff_8ea2_727e_0d9d_9f71cbaa89a4 423a2a76_951e_d63f_81eb_a18638e9ebe1["doesSetCorrectMinBounds()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| 423a2a76_951e_d63f_81eb_a18638e9ebe1 a4fabb23_550d_9c00_f7a9_8c40ce6d0251["throwsIfInitialIsBiggerThenMaximum()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| a4fabb23_550d_9c00_f7a9_8c40ce6d0251 ddf9aa52_a317_ec3e_cfa6_c431de33cc80["throwsIfInitialIsSmallerThenMinimum()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| ddf9aa52_a317_ec3e_cfa6_c431de33cc80 c545a560_97a9_7516_ab21_4c07a5ad34db["throwsIfMinimumIsBiggerThenMaximum()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| c545a560_97a9_7516_ab21_4c07a5ad34db 1c4fca03_b029_5a21_08c8_7ddda96ef416["allocReadExpected()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| 1c4fca03_b029_5a21_08c8_7ddda96ef416 f1b65935_c236_8693_58bc_5537b238709a["allocRead()"] 5011819c_2beb_6635_01ff_c14382c1d5a5 -->|method| f1b65935_c236_8693_58bc_5537b238709a
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/AdaptiveRecvByteBufAllocatorTest.java lines 31–168
public class AdaptiveRecvByteBufAllocatorTest {
@Mock
private ChannelConfig config;
private final ByteBufAllocator alloc = UnpooledByteBufAllocator.DEFAULT;
private RecvByteBufAllocator.ExtendedHandle handle;
@BeforeEach
public void setup() {
config = mock(ChannelConfig.class);
when(config.isAutoRead()).thenReturn(true);
AdaptiveRecvByteBufAllocator recvByteBufAllocator = new AdaptiveRecvByteBufAllocator(64, 512, 1024 * 1024 * 10);
handle = (RecvByteBufAllocator.ExtendedHandle) recvByteBufAllocator.newHandle();
handle.reset(config);
}
@Test
public void rampUpBeforeReadCompleteWhenLargeDataPending() {
// Simulate that there is always more data when we attempt to read so we should always ramp up.
allocReadExpected(handle, alloc, 512);
allocReadExpected(handle, alloc, 8192);
allocReadExpected(handle, alloc, 131072);
allocReadExpected(handle, alloc, 2097152);
handle.readComplete();
handle.reset(config);
allocReadExpected(handle, alloc, 8388608);
}
@Test
public void memoryAllocationIntervalsTest() {
computingNext(512, 512);
computingNext(8192, 1110);
computingNext(8192, 1200);
computingNext(4096, 1300);
computingNext(4096, 1500);
computingNext(2048, 1700);
computingNext(2048, 1550);
computingNext(2048, 2000);
computingNext(2048, 1900);
}
private void computingNext(long expectedSize, int actualReadBytes) {
assertEquals(expectedSize, handle.guess());
handle.reset(config);
handle.lastBytesRead(actualReadBytes);
handle.readComplete();
}
@Test
public void lastPartialReadDoesNotRampDown() {
allocReadExpected(handle, alloc, 512);
// Simulate there is just 1 byte remaining which is unread. However the total bytes in the current read cycle
// means that we should stay at the current step for the next ready cycle.
allocRead(handle, alloc, 8192, 1);
handle.readComplete();
handle.reset(config);
allocReadExpected(handle, alloc, 8192);
}
@Test
public void lastPartialReadCanRampUp() {
allocReadExpected(handle, alloc, 512);
// We simulate there is just 1 less byte than we try to read, but because of the adaptive steps the total amount
// of bytes read for this read cycle steps up to prepare for the next read cycle.
allocRead(handle, alloc, 8192, 8191);
handle.readComplete();
handle.reset(config);
allocReadExpected(handle, alloc, 131072);
}
@Test
public void doesNotExceedMaximum() {
AdaptiveRecvByteBufAllocator recvByteBufAllocator = new AdaptiveRecvByteBufAllocator(64, 9000, 9000);
RecvByteBufAllocator.ExtendedHandle handle =
(RecvByteBufAllocator.ExtendedHandle) recvByteBufAllocator.newHandle();
handle.reset(config);
allocReadExpected(handle, alloc, 8192);
}
Source
Frequently Asked Questions
What is the AdaptiveRecvByteBufAllocatorTest class?
AdaptiveRecvByteBufAllocatorTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/AdaptiveRecvByteBufAllocatorTest.java.
Where is AdaptiveRecvByteBufAllocatorTest defined?
AdaptiveRecvByteBufAllocatorTest is defined in transport/src/test/java/io/netty/channel/AdaptiveRecvByteBufAllocatorTest.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free