Home / Function/ buddyAllocationConsistency() — netty Function Reference

buddyAllocationConsistency() — netty Function Reference

Architecture documentation for the buddyAllocationConsistency() function in AdaptiveByteBufAllocatorTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  93c45167_8267_1dcc_a3b9_24fbc36946f7["buddyAllocationConsistency()"]
  b5780ec9_74a4_594b_4225_0099765d71e7["AdaptiveByteBufAllocatorTest"]
  93c45167_8267_1dcc_a3b9_24fbc36946f7 -->|defined in| b5780ec9_74a4_594b_4225_0099765d71e7
  aa738b31_7adc_d18f_9ebe_6964a3faaa4b["shuffle()"]
  93c45167_8267_1dcc_a3b9_24fbc36946f7 -->|calls| aa738b31_7adc_d18f_9ebe_6964a3faaa4b
  style 93c45167_8267_1dcc_a3b9_24fbc36946f7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorTest.java lines 395–448

    @RepeatedTest(100)
    void buddyAllocationConsistency(RepetitionInfo info) {
        SplittableRandom rng = new SplittableRandom(info.getCurrentRepetition());
        AdaptiveByteBufAllocator allocator = newAllocator(true);
        int small = 32768;
        int large = 2 * small;
        int xlarge = 2 * large;

        int[] allocationSizes = {
                small, small, small, small, small, small, small, small,
                large, large, large, large,
                xlarge, xlarge,
        };

        shuffle(rng, allocationSizes);

        ByteBuf[] bufs = new ByteBuf[allocationSizes.length];
        Arrays.setAll(bufs, i -> allocator.buffer(allocationSizes[i], allocationSizes[i]));

        shuffle(rng, bufs);

        int[] reallocations = new int[bufs.length / 2];
        for (int i = 0; i < reallocations.length; i++) {
            reallocations[i] = bufs[i].capacity();
            bufs[i].release();
            bufs[i] = null;
        }
        for (int i = 0; i < reallocations.length; i++) {
            assertNull(bufs[i]);
            bufs[i] = allocator.buffer(reallocations[i], reallocations[i]);
        }

        for (int i = 0; i < bufs.length; i++) {
            while (bufs[i].isWritable()) {
                bufs[i].writeByte(i + 1);
            }
        }
        try {
            for (int i = 0; i < bufs.length; i++) {
                while (bufs[i].isReadable()) {
                    int b = Byte.toUnsignedInt(bufs[i].readByte());
                    if (b != i + 1) {
                        fail("Expected byte " + (i + 1) +
                                " at index " + (bufs[i].readerIndex() - 1) +
                                " but got " + b);
                    }
                }
            }
        } finally {
            for (ByteBuf buf : bufs) {
                buf.release();
            }
        }
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does buddyAllocationConsistency() do?
buddyAllocationConsistency() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorTest.java.
Where is buddyAllocationConsistency() defined?
buddyAllocationConsistency() is defined in buffer/src/test/java/io/netty/buffer/AdaptiveByteBufAllocatorTest.java at line 395.
What does buddyAllocationConsistency() call?
buddyAllocationConsistency() calls 1 function(s): shuffle.

Analyze Your Own Codebase

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

Try Supermodel Free