Home / Class/ FixedChannelPoolTest Class — netty Architecture

FixedChannelPoolTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  92761f16_3144_6791_29c9_00f65a091a8f["FixedChannelPoolTest"]
  c0a64ccf_3c6e_7ec5_4abb_4a32cf1ed47c["FixedChannelPoolTest.java"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|defined in| c0a64ccf_3c6e_7ec5_4abb_4a32cf1ed47c
  e013b86c_2349_5996_9bca_b7d4cdf4b63e["createEventLoop()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| e013b86c_2349_5996_9bca_b7d4cdf4b63e
  431c734b_d595_e471_3e2f_5901f936910e["destroyEventLoop()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| 431c734b_d595_e471_3e2f_5901f936910e
  576ed140_663c_f8e2_b028_2d5c2b4ccf92["testAcquire()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| 576ed140_663c_f8e2_b028_2d5c2b4ccf92
  6a563213_a1be_1d43_45e8_9a9b98d08cce["testAcquireTimeout()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| 6a563213_a1be_1d43_45e8_9a9b98d08cce
  ae75385d_a095_6a0c_46cf_a6a22931e4c6["testAcquireWithZeroTimeout()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| ae75385d_a095_6a0c_46cf_a6a22931e4c6
  a7422301_805d_ae43_e86e_f77af3710c4a["testAcquireNewConnection()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| a7422301_805d_ae43_e86e_f77af3710c4a
  9e21d0db_818b_0f13_e98e_aea6a10925af["testAcquireNewConnectionWhen()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| 9e21d0db_818b_0f13_e98e_aea6a10925af
  82019ee6_5d4f_c4b5_7480_632eda0746a8["testAcquireBoundQueue()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| 82019ee6_5d4f_c4b5_7480_632eda0746a8
  1b444c67_fffc_d292_f06b_0f7e7d1d9c5d["testReleaseDifferentPool()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| 1b444c67_fffc_d292_f06b_0f7e7d1d9c5d
  9812b8f7_e117_7c30_8945_83a446456b32["testReleaseAfterClosePool()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| 9812b8f7_e117_7c30_8945_83a446456b32
  4a72657c_5d29_d461_8cea_127825a39655["testReleaseClosed()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| 4a72657c_5d29_d461_8cea_127825a39655
  d0a16da7_afe7_d156_2605_c6ea99ba11b8["testCloseAsync()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| d0a16da7_afe7_d156_2605_c6ea99ba11b8
  4a3002ce_9a79_62e8_9aca_5fa1761a2a43["testChannelAcquiredException()"]
  92761f16_3144_6791_29c9_00f65a091a8f -->|method| 4a3002ce_9a79_62e8_9aca_5fa1761a2a43

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/pool/FixedChannelPoolTest.java lines 55–466

public class FixedChannelPoolTest {
    private static EventLoopGroup group;

    @BeforeAll
    public static void createEventLoop() {
        group = new MultiThreadIoEventLoopGroup(LocalIoHandler.newFactory());
    }

    @AfterAll
    public static void destroyEventLoop() {
        if (group != null) {
            group.shutdownGracefully();
        }
    }

    @Test
    public void testAcquire() throws Exception {
        Tuple t = bootstrap();

        // Start server
        Channel sc = t.sb.bind(t.address).syncUninterruptibly().channel();
        CountingChannelPoolHandler handler = new CountingChannelPoolHandler();

        ChannelPool pool = new FixedChannelPool(t.cb, handler, 1, Integer.MAX_VALUE);

        Channel channel = pool.acquire().syncUninterruptibly().getNow();
        Future<Channel> future = pool.acquire();
        assertFalse(future.isDone());

        pool.release(channel).syncUninterruptibly();
        assertTrue(future.await(1, TimeUnit.SECONDS));

        Channel channel2 = future.getNow();
        assertSame(channel, channel2);
        assertEquals(1, handler.channelCount());

        assertEquals(2, handler.acquiredCount());
        assertEquals(1, handler.releasedCount());

        sc.close().syncUninterruptibly();
        channel2.close().syncUninterruptibly();
        pool.close();
    }

    @Test
    public void testAcquireTimeout() throws Exception {
        testAcquireTimeout(500);
    }

    @Test
    public void testAcquireWithZeroTimeout() throws Exception {
        testAcquireTimeout(0);
    }

    private void testAcquireTimeout(long timeoutMillis) throws Exception {
        Tuple t = bootstrap();

        // Start server
        Channel sc = t.sb.bind(t.address).syncUninterruptibly().channel();
        ChannelPoolHandler handler = new TestChannelPoolHandler();
        ChannelPool pool = new FixedChannelPool(t.cb, handler, ChannelHealthChecker.ACTIVE,
                AcquireTimeoutAction.FAIL, timeoutMillis, 1, Integer.MAX_VALUE);

        Channel channel = pool.acquire().syncUninterruptibly().getNow();
        final Future<Channel> future = pool.acquire();
        assertThrows(TimeoutException.class, new Executable() {
            @Override
            public void execute() throws Throwable {
                future.syncUninterruptibly();
            }
        });
        sc.close().syncUninterruptibly();
        channel.close().syncUninterruptibly();
        pool.close();
    }

    @Test
    public void testAcquireNewConnection() throws Exception {
        Tuple t = bootstrap();

        // Start server

Frequently Asked Questions

What is the FixedChannelPoolTest class?
FixedChannelPoolTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/pool/FixedChannelPoolTest.java.
Where is FixedChannelPoolTest defined?
FixedChannelPoolTest is defined in transport/src/test/java/io/netty/channel/pool/FixedChannelPoolTest.java at line 55.

Analyze Your Own Codebase

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

Try Supermodel Free