Home / Function/ testPathStatsAreCollected() — netty Function Reference

testPathStatsAreCollected() — netty Function Reference

Architecture documentation for the testPathStatsAreCollected() function in QuicConnectionPathStatsTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a4a299ec_a061_af5d_59ca_5474aa848da9["testPathStatsAreCollected()"]
  1e708fe0_ed9b_fc0a_0a94_fcd4ecfaa0c8["QuicConnectionPathStatsTest"]
  a4a299ec_a061_af5d_59ca_5474aa848da9 -->|defined in| 1e708fe0_ed9b_fc0a_0a94_fcd4ecfaa0c8
  c2419d52_6c49_dd66_ef2b_3dfddef1f35f["assertStats()"]
  a4a299ec_a061_af5d_59ca_5474aa848da9 -->|calls| c2419d52_6c49_dd66_ef2b_3dfddef1f35f
  style a4a299ec_a061_af5d_59ca_5474aa848da9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicConnectionPathStatsTest.java lines 38–122

    @ParameterizedTest
    @MethodSource("newSslTaskExecutors")
    public void testPathStatsAreCollected(Executor executor) throws Throwable {
        Channel server = null;
        Channel channel = null;
        AtomicInteger counter = new AtomicInteger();

        Promise<QuicConnectionPathStats> serverActiveStats = ImmediateEventExecutor.INSTANCE.newPromise();
        QuicChannelValidationHandler serverHandler = new QuicChannelValidationHandler() {
            @Override
            public void channelActive(ChannelHandlerContext ctx) {
                super.channelActive(ctx);
                collectPathStats(ctx, serverActiveStats);
            }

            private void collectPathStats(ChannelHandlerContext ctx, Promise<QuicConnectionPathStats> promise) {
                QuicheQuicChannel channel = (QuicheQuicChannel) ctx.channel();
                channel.collectPathStats(0, promise);
            }
        };
        QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();
        try {
            server = QuicTestUtils.newServer(executor, serverHandler, new ChannelInboundHandlerAdapter() {

                @Override
                public void channelActive(ChannelHandlerContext ctx) {
                    counter.incrementAndGet();
                }

                @Override
                public void channelRead(ChannelHandlerContext ctx, Object msg) {
                    // Let's just echo back the message.
                    ctx.writeAndFlush(msg);
                }

                @Override
                public boolean isSharable() {
                    return true;
                }
            });
            channel = QuicTestUtils.newClient(executor);

            QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
                    .handler(clientHandler)
                    .streamHandler(new ChannelInboundHandlerAdapter())
                    .remoteAddress(server.localAddress())
                    .connect().get();
            assertNotNull(quicChannel.collectStats().sync().getNow());
            quicChannel.createStream(QuicStreamType.BIDIRECTIONAL, new ChannelInboundHandlerAdapter() {
                private final int bufferSize = 8;
                private int received;

                @Override
                public void channelActive(ChannelHandlerContext ctx) {
                    ctx.writeAndFlush(Unpooled.buffer().writeZero(bufferSize));
                }

                @Override
                public void channelRead(ChannelHandlerContext ctx, Object msg) {
                    ByteBuf buffer = (ByteBuf) msg;
                    received += buffer.readableBytes();
                    buffer.release();
                    if (received == bufferSize) {
                        ctx.close().addListener((ChannelFuture future) -> {
                            // Close the underlying QuicChannel as well.
                            future.channel().parent().close();
                        });
                    }
                }
            }).sync();

            // Wait until closure
            quicChannel.closeFuture().sync();
            assertStats(serverActiveStats.sync().getNow());
            assertEquals(1, counter.get());

            serverHandler.assertState();
            clientHandler.assertState();
        } finally {
            QuicTestUtils.closeIfNotNull(channel);
            QuicTestUtils.closeIfNotNull(server);

Domain

Subdomains

Frequently Asked Questions

What does testPathStatsAreCollected() do?
testPathStatsAreCollected() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicConnectionPathStatsTest.java.
Where is testPathStatsAreCollected() defined?
testPathStatsAreCollected() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicConnectionPathStatsTest.java at line 38.
What does testPathStatsAreCollected() call?
testPathStatsAreCollected() calls 1 function(s): assertStats.

Analyze Your Own Codebase

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

Try Supermodel Free