Home / Function/ basicEcho() — netty Function Reference

basicEcho() — netty Function Reference

Architecture documentation for the basicEcho() function in NioUdtByteRendezvousChannelTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  1e584831_6f37_c452_1b70_cfbe6142858c["basicEcho()"]
  85b4a24a_d101_22e8_4e36_f45640fd90df["NioUdtByteRendezvousChannelTest"]
  1e584831_6f37_c452_1b70_cfbe6142858c -->|defined in| 85b4a24a_d101_22e8_4e36_f45640fd90df
  style 1e584831_6f37_c452_1b70_cfbe6142858c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtByteRendezvousChannelTest.java lines 56–116

    @Test
    @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
    public void basicEcho() throws Exception {

        final int messageSize = 64 * 1024;
        final int transferLimit = messageSize * 16;

        final InetSocketAddress addr1 = UnitHelp.localSocketAddress();
        final InetSocketAddress addr2 = UnitHelp.localSocketAddress();

        final EchoByteHandler handler1 = new EchoByteHandler(messageSize);
        final EchoByteHandler handler2 = new EchoByteHandler(messageSize);

        final EventLoopGroup group1 = new MultiThreadIoEventLoopGroup(
                1, Executors.defaultThreadFactory(), NioIoHandler.newFactory(NioUdtProvider.BYTE_PROVIDER));
        final EventLoopGroup group2 = new MultiThreadIoEventLoopGroup(
                1, Executors.defaultThreadFactory(), NioIoHandler.newFactory(NioUdtProvider.BYTE_PROVIDER));

        final Bootstrap boot1 = new Bootstrap();
        boot1.group(group1)
             .channelFactory(NioUdtProvider.BYTE_RENDEZVOUS)
             .localAddress(addr1)
             .remoteAddress(addr2)
             .handler(handler1);

        final Bootstrap boot2 = new Bootstrap();
        boot2.group(group1)
             .channelFactory(NioUdtProvider.BYTE_RENDEZVOUS)
             .localAddress(addr2)
             .remoteAddress(addr1)
             .handler(handler2);

        final ChannelFuture connectFuture1 = boot1.connect();
        final ChannelFuture connectFuture2 = boot2.connect();

        while (handler1.counter() < transferLimit
                && handler2.counter() < transferLimit) {

            log.info("progress : {} {}", handler1.counter(), handler2
                    .counter());

            Thread.sleep(1000);
        }

        connectFuture1.channel().close().sync();
        connectFuture2.channel().close().sync();

        log.info("handler1 : {}", handler1.counter());
        log.info("handler2 : {}", handler2.counter());

        assertTrue(handler1.counter() >= transferLimit);
        assertTrue(handler2.counter() >= transferLimit);

        assertEquals(handler1.counter(), handler2.counter());

        group1.shutdownGracefully();
        group2.shutdownGracefully();

        group1.terminationFuture().sync();
        group2.terminationFuture().sync();
    }

Domain

Subdomains

Frequently Asked Questions

What does basicEcho() do?
basicEcho() is a function in the netty codebase, defined in transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtByteRendezvousChannelTest.java.
Where is basicEcho() defined?
basicEcho() is defined in transport-udt/src/test/java/io/netty/test/udt/nio/NioUdtByteRendezvousChannelTest.java at line 56.

Analyze Your Own Codebase

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

Try Supermodel Free