Home / Function/ testSocketReuse() — netty Function Reference

testSocketReuse() — netty Function Reference

Architecture documentation for the testSocketReuse() function in LocalTransportThreadModelTest2.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  48439426_aca2_f365_76b8_0bb2924f04f9["testSocketReuse()"]
  466017c7_8ea0_bf8a_7ded_086ed4918c64["LocalTransportThreadModelTest2"]
  48439426_aca2_f365_76b8_0bb2924f04f9 -->|defined in| 466017c7_8ea0_bf8a_7ded_086ed4918c64
  5e40d4c3_4359_26df_1b74_60b2431b95f0["LocalHandler()"]
  48439426_aca2_f365_76b8_0bb2924f04f9 -->|calls| 5e40d4c3_4359_26df_1b74_60b2431b95f0
  babd54f5_2738_3d21_8934_12868f2e6b96["close()"]
  48439426_aca2_f365_76b8_0bb2924f04f9 -->|calls| babd54f5_2738_3d21_8934_12868f2e6b96
  style 48439426_aca2_f365_76b8_0bb2924f04f9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java lines 41–76

    @Test
    @Timeout(value = 15000, unit = TimeUnit.MILLISECONDS)
    public void testSocketReuse() throws InterruptedException {
        ServerBootstrap serverBootstrap = new ServerBootstrap();
        LocalHandler serverHandler = new LocalHandler("SERVER");
        serverBootstrap
                .group(new MultiThreadIoEventLoopGroup(LocalIoHandler.newFactory()))
                .channel(LocalServerChannel.class)
                .childHandler(serverHandler);

        Bootstrap clientBootstrap = new Bootstrap();
        LocalHandler clientHandler = new LocalHandler("CLIENT");
        clientBootstrap
                .group(new MultiThreadIoEventLoopGroup(LocalIoHandler.newFactory()))
                .channel(LocalChannel.class)
                .remoteAddress(new LocalAddress(LOCAL_CHANNEL)).handler(clientHandler);

        serverBootstrap.bind(new LocalAddress(LOCAL_CHANNEL)).sync();

        int count = 100;
        for (int i = 1; i < count + 1; i ++) {
            Channel ch = clientBootstrap.connect().sync().channel();

            // SPIN until we get what we are looking for.
            int target = i * messageCountPerRun;
            while (serverHandler.count.get() != target || clientHandler.count.get() != target) {
                Thread.sleep(50);
            }
            close(ch, clientHandler);
        }

        assertEquals(count * 2 * messageCountPerRun, serverHandler.count.get() +
                clientHandler.count.get());
        serverBootstrap.config().group().shutdownGracefully().sync();
        clientBootstrap.config().group().shutdownGracefully().sync();
    }

Domain

Subdomains

Frequently Asked Questions

What does testSocketReuse() do?
testSocketReuse() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java.
Where is testSocketReuse() defined?
testSocketReuse() is defined in transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest2.java at line 41.
What does testSocketReuse() call?
testSocketReuse() calls 2 function(s): LocalHandler, close.

Analyze Your Own Codebase

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

Try Supermodel Free