Home / Class/ IoUringAdaptiveBufferRingAllocatorTest Class — netty Architecture

IoUringAdaptiveBufferRingAllocatorTest Class — netty Architecture

Architecture documentation for the IoUringAdaptiveBufferRingAllocatorTest class in IoUringAdaptiveBufferRingAllocatorTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  532266ae_9a19_f7f1_79fa_00f339859d6d["IoUringAdaptiveBufferRingAllocatorTest"]
  87cd6321_9278_e662_9e17_364082dd27e5["IoUringAdaptiveBufferRingAllocatorTest.java"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|defined in| 87cd6321_9278_e662_9e17_364082dd27e5
  01feb284_b7f0_1af5_544a_6b2a21fedfcb["rampUpWhenLargeDataPending()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| 01feb284_b7f0_1af5_544a_6b2a21fedfcb
  24515e64_f051_0dee_37e3_0e6a53888236["lastPartialReadDoesNotRampDown()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| 24515e64_f051_0dee_37e3_0e6a53888236
  ec623a32_eef3_9037_555f_afffc4800095["lastPartialReadCanRampUp()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| ec623a32_eef3_9037_555f_afffc4800095
  729f62b9_75e3_52cf_3816_4da594c5eea6["doesNotExceedMaximum()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| 729f62b9_75e3_52cf_3816_4da594c5eea6
  1f40a908_45ad_1434_a86a_a8c3a8859689["doesSetCorrectMinBounds()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| 1f40a908_45ad_1434_a86a_a8c3a8859689
  52c3d85d_0822_25f8_1f16_21efada11a2e["throwsIfInitialIsBiggerThenMaximum()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| 52c3d85d_0822_25f8_1f16_21efada11a2e
  3a5422dd_a2fb_50e8_7cd0_64a982f276fb["throwsIfInitialIsSmallerThenMinimum()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| 3a5422dd_a2fb_50e8_7cd0_64a982f276fb
  ec4332dd_24bb_a44f_edbc_3ff40110f49c["throwsIfMinimumIsBiggerThenMaximum()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| ec4332dd_24bb_a44f_edbc_3ff40110f49c
  736fe095_d68b_e38f_fd45_287d9989d67f["allocReadExpected()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| 736fe095_d68b_e38f_fd45_287d9989d67f
  cf42edfa_132a_3dd8_b2d2_a0241b7b8d39["allocRead()"]
  532266ae_9a19_f7f1_79fa_00f339859d6d -->|method| cf42edfa_132a_3dd8_b2d2_a0241b7b8d39

Relationship Graph

Source Code

transport-native-io_uring/src/test/java/io/netty/channel/uring/IoUringAdaptiveBufferRingAllocatorTest.java lines 25–103

public class IoUringAdaptiveBufferRingAllocatorTest {

    @Test
    public void rampUpWhenLargeDataPending() {
        IoUringAdaptiveBufferRingAllocator allocator = new IoUringAdaptiveBufferRingAllocator(
                UnpooledByteBufAllocator.DEFAULT, 64, 512, 1024 * 1024 * 10);
        // Simulate that there is always more data when we attempt to read so we should always ramp up.
        allocReadExpected(allocator, 512);
        allocReadExpected(allocator, 8192);
        allocReadExpected(allocator, 131072);
        allocReadExpected(allocator, 2097152);
    }

    @Test
    public void lastPartialReadDoesNotRampDown() {
        IoUringAdaptiveBufferRingAllocator allocator = new IoUringAdaptiveBufferRingAllocator(
                UnpooledByteBufAllocator.DEFAULT, 64, 512, 1024 * 1024 * 10);
        allocReadExpected(allocator, 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(allocator, 8192, 1);
    }

    @Test
    public void lastPartialReadCanRampUp() {
        IoUringAdaptiveBufferRingAllocator allocator = new IoUringAdaptiveBufferRingAllocator(
                UnpooledByteBufAllocator.DEFAULT, 64, 512, 1024 * 1024 * 10);
        allocReadExpected(allocator, 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(allocator, 8192, 8191);
    }

    @Test
    public void doesNotExceedMaximum() {
        IoUringAdaptiveBufferRingAllocator allocator = new IoUringAdaptiveBufferRingAllocator(
                UnpooledByteBufAllocator.DEFAULT, 64, 9000, 9000);
        allocReadExpected(allocator, 8192);
    }

    @Test
    public void doesSetCorrectMinBounds() {
        IoUringAdaptiveBufferRingAllocator allocator = new IoUringAdaptiveBufferRingAllocator(
                UnpooledByteBufAllocator.DEFAULT, 81, 95, 95);
        allocReadExpected(allocator, 81);
    }

    @Test
    public void throwsIfInitialIsBiggerThenMaximum() {
        assertThrows(IllegalArgumentException.class,
                () -> new IoUringAdaptiveBufferRingAllocator(UnpooledByteBufAllocator.DEFAULT, 64, 4096 , 1024));
    }

    @Test
    public void throwsIfInitialIsSmallerThenMinimum() {
        assertThrows(IllegalArgumentException.class,
                () -> new IoUringAdaptiveBufferRingAllocator(UnpooledByteBufAllocator.DEFAULT, 512, 64 , 1024));
    }

    @Test
    public void throwsIfMinimumIsBiggerThenMaximum() {
        assertThrows(IllegalArgumentException.class,
                () -> new IoUringAdaptiveBufferRingAllocator(UnpooledByteBufAllocator.DEFAULT, 2048, 64 , 1024));
    }

    private static void allocReadExpected(IoUringAdaptiveBufferRingAllocator allocator,
                                          int expectedSize) {
        allocRead(allocator, expectedSize, expectedSize);
    }

    private static void allocRead(IoUringAdaptiveBufferRingAllocator allocator,
                                  int expectedBufferSize,
                                  int lastRead) {
        ByteBuf buf = allocator.allocate();
        assertEquals(expectedBufferSize, buf.capacity());
        allocator.lastBytesRead(expectedBufferSize, lastRead);
        buf.release();
    }
}

Frequently Asked Questions

What is the IoUringAdaptiveBufferRingAllocatorTest class?
IoUringAdaptiveBufferRingAllocatorTest is a class in the netty codebase, defined in transport-native-io_uring/src/test/java/io/netty/channel/uring/IoUringAdaptiveBufferRingAllocatorTest.java.
Where is IoUringAdaptiveBufferRingAllocatorTest defined?
IoUringAdaptiveBufferRingAllocatorTest is defined in transport-native-io_uring/src/test/java/io/netty/channel/uring/IoUringAdaptiveBufferRingAllocatorTest.java at line 25.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free