Home / Class/ TestByteBufAllocator Class — netty Architecture

TestByteBufAllocator Class — netty Architecture

Architecture documentation for the TestByteBufAllocator class in SSLEngineTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  36746ada_c520_ff41_b142_9731cc8488a6["TestByteBufAllocator"]
  859a13fc_5d1f_4d06_dca1_2d4d0f57be71["SSLEngineTest.java"]
  36746ada_c520_ff41_b142_9731cc8488a6 -->|defined in| 859a13fc_5d1f_4d06_dca1_2d4d0f57be71
  d074ce38_190b_dae8_46f6_82b7c5e7ecaf["TestByteBufAllocator()"]
  36746ada_c520_ff41_b142_9731cc8488a6 -->|method| d074ce38_190b_dae8_46f6_82b7c5e7ecaf
  efa54912_e079_cd32_6bf8_7fc6ce087a3c["ByteBuf()"]
  36746ada_c520_ff41_b142_9731cc8488a6 -->|method| efa54912_e079_cd32_6bf8_7fc6ce087a3c
  ecd99504_0536_2926_feda_c49ce31e9837["CompositeByteBuf()"]
  36746ada_c520_ff41_b142_9731cc8488a6 -->|method| ecd99504_0536_2926_feda_c49ce31e9837
  7d65f68c_b0b2_8456_956d_a4c616504cf8["isDirectBufferPooled()"]
  36746ada_c520_ff41_b142_9731cc8488a6 -->|method| 7d65f68c_b0b2_8456_956d_a4c616504cf8
  258c899a_cb55_6fc1_f5d7_8d2a20ee71b1["calculateNewCapacity()"]
  36746ada_c520_ff41_b142_9731cc8488a6 -->|method| 258c899a_cb55_6fc1_f5d7_8d2a20ee71b1

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java lines 324–486

    private static final class TestByteBufAllocator implements ByteBufAllocator {

        private final ByteBufAllocator allocator;
        private final BufferType type;

        TestByteBufAllocator(ByteBufAllocator allocator, BufferType type) {
            this.allocator = allocator;
            this.type = type;
        }

        @Override
        public ByteBuf buffer() {
            switch (type) {
                case Direct:
                    return allocator.directBuffer();
                case Heap:
                    return allocator.heapBuffer();
                case Mixed:
                    return ThreadLocalRandom.current().nextBoolean() ?
                            allocator.directBuffer() : allocator.heapBuffer();
                default:
                    throw new Error("Unexpected buffer type: " + type);
            }
        }

        @Override
        public ByteBuf buffer(int initialCapacity) {
            switch (type) {
                case Direct:
                    return allocator.directBuffer(initialCapacity);
                case Heap:
                    return allocator.heapBuffer(initialCapacity);
                case Mixed:
                    return ThreadLocalRandom.current().nextBoolean() ?
                            allocator.directBuffer(initialCapacity) : allocator.heapBuffer(initialCapacity);
                default:
                    throw new Error("Unexpected buffer type: " + type);
            }
        }

        @Override
        public ByteBuf buffer(int initialCapacity, int maxCapacity) {
            switch (type) {
                case Direct:
                    return allocator.directBuffer(initialCapacity, maxCapacity);
                case Heap:
                    return allocator.heapBuffer(initialCapacity, maxCapacity);
                case Mixed:
                    return ThreadLocalRandom.current().nextBoolean() ?
                            allocator.directBuffer(initialCapacity, maxCapacity) :
                            allocator.heapBuffer(initialCapacity, maxCapacity);
                default:
                    throw new Error("Unexpected buffer type: " + type);
            }
        }

        @Override
        public ByteBuf ioBuffer() {
            return allocator.ioBuffer();
        }

        @Override
        public ByteBuf ioBuffer(int initialCapacity) {
            return allocator.ioBuffer(initialCapacity);
        }

        @Override
        public ByteBuf ioBuffer(int initialCapacity, int maxCapacity) {
            return allocator.ioBuffer(initialCapacity, maxCapacity);
        }

        @Override
        public ByteBuf heapBuffer() {
            return allocator.heapBuffer();
        }

        @Override
        public ByteBuf heapBuffer(int initialCapacity) {
            return allocator.heapBuffer(initialCapacity);
        }

Frequently Asked Questions

What is the TestByteBufAllocator class?
TestByteBufAllocator is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java.
Where is TestByteBufAllocator defined?
TestByteBufAllocator is defined in handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java at line 324.

Analyze Your Own Codebase

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

Try Supermodel Free