Home / Function/ testMultipleBindDatagramChannel() — netty Function Reference

testMultipleBindDatagramChannel() — netty Function Reference

Architecture documentation for the testMultipleBindDatagramChannel() function in EpollReuseAddrTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  f3e2e7fd_7460_739d_9cb6_36351cbde902["testMultipleBindDatagramChannel()"]
  872e58d8_72a4_04f4_f4a3_a86fb110f538["EpollReuseAddrTest"]
  f3e2e7fd_7460_739d_9cb6_36351cbde902 -->|defined in| 872e58d8_72a4_04f4_f4a3_a86fb110f538
  2cb5d0a8_8e51_b815_9f07_7fbf35f11bf5["versionEqOrGt()"]
  f3e2e7fd_7460_739d_9cb6_36351cbde902 -->|calls| 2cb5d0a8_8e51_b815_9f07_7fbf35f11bf5
  bd874a09_d726_cce9_537d_08d0fa7b770b["DatagramSocketTestHandler()"]
  f3e2e7fd_7460_739d_9cb6_36351cbde902 -->|calls| bd874a09_d726_cce9_537d_08d0fa7b770b
  style f3e2e7fd_7460_739d_9cb6_36351cbde902 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java lines 142–194

    @Test
    @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
    @Disabled // TODO: Unignore after making it pass on centos6-1 and debian7-1
    public void testMultipleBindDatagramChannel() throws Exception {
        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
        assumeTrue(versionEqOrGt(3, 9, 0));
        Bootstrap bootstrap = createBootstrap();
        bootstrap.option(EpollChannelOption.SO_REUSEPORT, true);
        final AtomicBoolean received1 = new AtomicBoolean();
        bootstrap.handler(new DatagramSocketTestHandler(received1));
        ChannelFuture future = bootstrap.bind().syncUninterruptibly();
        final InetSocketAddress address1 = (InetSocketAddress) future.channel().localAddress();

        final AtomicBoolean received2 = new AtomicBoolean();
        bootstrap.handler(new DatagramSocketTestHandler(received2));
        ChannelFuture future2 = bootstrap.bind(address1).syncUninterruptibly();
        final InetSocketAddress address2 = (InetSocketAddress) future2.channel().localAddress();

        assertEquals(address1, address2);
        final byte[] bytes = "data".getBytes();

        // fire up 16 Threads and send DatagramPackets to make sure we stress it enough to see DatagramPackets received
        // on both sockets.
        int count = 16;
        final CountDownLatch latch = new CountDownLatch(count);
        Runnable r = new Runnable() {
            @Override
            public void run() {
                try {
                    DatagramSocket socket = new DatagramSocket();
                    while (!received1.get() || !received2.get()) {
                        socket.send(new DatagramPacket(
                                bytes, 0, bytes.length, address1.getAddress(), address1.getPort()));
                    }
                    socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                latch.countDown();
            }
        };

        ExecutorService executor = Executors.newFixedThreadPool(count);
        for (int i = 0 ; i < count; i++) {
            executor.execute(r);
        }
        latch.await();
        executor.shutdown();
        future.channel().close().syncUninterruptibly();
        future2.channel().close().syncUninterruptibly();
        assertTrue(received1.get());
        assertTrue(received2.get());
    }

Domain

Subdomains

Frequently Asked Questions

What does testMultipleBindDatagramChannel() do?
testMultipleBindDatagramChannel() is a function in the netty codebase, defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java.
Where is testMultipleBindDatagramChannel() defined?
testMultipleBindDatagramChannel() is defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java at line 142.
What does testMultipleBindDatagramChannel() call?
testMultipleBindDatagramChannel() calls 2 function(s): DatagramSocketTestHandler, versionEqOrGt.

Analyze Your Own Codebase

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

Try Supermodel Free