Home / Class/ IoUringDomainSocketFdTest Class — netty Architecture

IoUringDomainSocketFdTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  22551703_3532_b531_98ad_64e017f8468d["IoUringDomainSocketFdTest"]
  a2d76b6f_3689_27d6_6af8_6f03cb54edc8["IoUringDomainSocketFdTest.java"]
  22551703_3532_b531_98ad_64e017f8468d -->|defined in| a2d76b6f_3689_27d6_6af8_6f03cb54edc8
  cbc26896_e1d7_e7a1_247d_a46950cd109d["SocketAddress()"]
  22551703_3532_b531_98ad_64e017f8468d -->|method| cbc26896_e1d7_e7a1_247d_a46950cd109d
  30863ad1_29b2_561b_6dc5_34d76077ac7f["newFactories()"]
  22551703_3532_b531_98ad_64e017f8468d -->|method| 30863ad1_29b2_561b_6dc5_34d76077ac7f
  4e14e3d3_e376_e70e_df58_3239773769a7["testSendRecvFd()"]
  22551703_3532_b531_98ad_64e017f8468d -->|method| 4e14e3d3_e376_e70e_df58_3239773769a7

Relationship Graph

Source Code

transport-native-io_uring/src/test/java/io/netty/channel/uring/IoUringDomainSocketFdTest.java lines 45–156

public class IoUringDomainSocketFdTest extends AbstractSocketTest {
    @Override
    protected SocketAddress newSocketAddress() {
        return IoUringSocketTestPermutation.newDomainSocketAddress();
    }

    @Override
    protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
        return IoUringSocketTestPermutation.INSTANCE.domainSocket();
    }

    @Test
    @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
    public void testSendRecvFd(TestInfo testInfo) throws Throwable {
        run(testInfo, new Runner<ServerBootstrap, Bootstrap>() {
            @Override
            public void run(ServerBootstrap serverBootstrap, Bootstrap bootstrap) throws Throwable {
                testSendRecvFd(serverBootstrap, bootstrap);
            }
        });
    }

    public void testSendRecvFd(ServerBootstrap sb, Bootstrap cb) throws Throwable {

        String expected = "Hello World";
        CompletableFuture<FileDescriptor> recvFdFuture = new CompletableFuture<>();
        CompletableFuture<ByteBuf> recvByteBufFuture = new CompletableFuture<>();

        sb.childHandler(new ChannelInboundHandlerAdapter() {
            @Override
            public void channelActive(ChannelHandlerContext ctx) throws Exception {
                // Create new channel and obtain a file descriptor from it.
                final IoUringDomainSocketChannel ch = new IoUringDomainSocketChannel();

                ctx.writeAndFlush(ch.fd()).addListener(future -> {
                    if (!future.isSuccess()) {
                        Throwable cause = future.cause();
                        recvFdFuture.completeExceptionally(cause);
                    } else {
                        ByteBuf sendBuffer = ctx.alloc().directBuffer(expected.length());
                        sendBuffer.writeBytes(expected.getBytes());
                        ctx.writeAndFlush(sendBuffer).addListener(f -> {
                            if (!f.isSuccess()) {
                                Throwable cause = f.cause();
                                recvByteBufFuture.completeExceptionally(cause);
                            }
                        });
                    }
                });
            }
        });

        cb.handler(new ChannelInboundHandlerAdapter() {

            private CompositeByteBuf byteBufs;

            @Override
            public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
                if (msg instanceof FileDescriptor) {
                    FileDescriptor fd = (FileDescriptor) msg;
                    recvFdFuture.complete(fd);
                    ctx.channel().config()
                            .setOption(IoUringChannelOption.DOMAIN_SOCKET_READ_MODE, DomainSocketReadMode.BYTES);
                } else {
                    byteBufs.addComponent(true, (ByteBuf) msg);
                }
            }

            @Override
            public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
                DomainSocketReadMode readMode = ctx.channel().config()
                        .getOption(IoUringChannelOption.DOMAIN_SOCKET_READ_MODE);
                if (readMode == DomainSocketReadMode.FILE_DESCRIPTORS) {
                    recvFdFuture.completeExceptionally(cause);
                } else {
                    recvByteBufFuture.completeExceptionally(cause);
                }
                ctx.close();
            }

            @Override

Frequently Asked Questions

What is the IoUringDomainSocketFdTest class?
IoUringDomainSocketFdTest is a class in the netty codebase, defined in transport-native-io_uring/src/test/java/io/netty/channel/uring/IoUringDomainSocketFdTest.java.
Where is IoUringDomainSocketFdTest defined?
IoUringDomainSocketFdTest is defined in transport-native-io_uring/src/test/java/io/netty/channel/uring/IoUringDomainSocketFdTest.java at line 45.

Analyze Your Own Codebase

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

Try Supermodel Free