Home / Function/ testFlushStrategy() — netty Function Reference

testFlushStrategy() — netty Function Reference

Architecture documentation for the testFlushStrategy() function in QuicheQuicCodecTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  99e2019c_6094_36fb_5440_75f8048c88d7["testFlushStrategy()"]
  7e52543b_4bd8_490c_5ff3_60e2d328d393["QuicheQuicCodecTest"]
  99e2019c_6094_36fb_5440_75f8048c88d7 -->|defined in| 7e52543b_4bd8_490c_5ff3_60e2d328d393
  74bd8818_996e_540f_8b45_2dc5e15a6e6b["testFlushStrategyUsedWithBytes()"]
  74bd8818_996e_540f_8b45_2dc5e15a6e6b -->|calls| 99e2019c_6094_36fb_5440_75f8048c88d7
  b7584172_a699_6b6b_fbf4_494f1bc1f243["testFlushStrategyUsedWithPackets()"]
  b7584172_a699_6b6b_fbf4_494f1bc1f243 -->|calls| 99e2019c_6094_36fb_5440_75f8048c88d7
  style 99e2019c_6094_36fb_5440_75f8048c88d7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicheQuicCodecTest.java lines 54–110

    private void testFlushStrategy(boolean useBytes) {
        final int bytes = 8;
        final AtomicInteger numBytesTracker = new AtomicInteger();
        final AtomicInteger numPacketsTracker = new AtomicInteger();
        final AtomicInteger flushCount = new AtomicInteger();
        B builder = newCodecBuilder();
        builder.flushStrategy((numPackets, numBytes) -> {
            numPacketsTracker.set(numPackets);
            numBytesTracker.set(numBytes);
            if (useBytes) {
                return numBytes > 8;
            }
            if (numPackets == 2) {
                return true;
            }
            return false;
        });

        EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() {
            @Override
            public void flush(ChannelHandlerContext ctx) throws Exception {
                flushCount.incrementAndGet();
                super.flush(ctx);
            }
        }, builder.build());
        assertEquals(0, numPacketsTracker.get());
        assertEquals(0, numBytesTracker.get());
        assertEquals(0, flushCount.get());

        channel.write(new DatagramPacket(Unpooled.buffer().writeZero(bytes), new InetSocketAddress(0)));
        assertEquals(1, numPacketsTracker.get());
        assertEquals(8, numBytesTracker.get());
        assertEquals(0, flushCount.get());

        channel.write(new DatagramPacket(Unpooled.buffer().writeZero(bytes), new InetSocketAddress(0)));
        assertEquals(2, numPacketsTracker.get());
        assertEquals(16, numBytesTracker.get());
        assertEquals(1, flushCount.get());

        // As a flush did happen we should see two packets in the outbound queue.
        for (int i = 0; i < 2; i++) {
            DatagramPacket packet = channel.readOutbound();
            assertNotNull(packet);
            packet.release();
        }

        ChannelFuture future = channel.write(new DatagramPacket(Unpooled.buffer().writeZero(bytes),
                new InetSocketAddress(0)));
        assertEquals(1, numPacketsTracker.get());
        assertEquals(8, numBytesTracker.get());
        assertEquals(1, flushCount.get());

        // We never flushed the last datagram packet so it should be failed.
        assertFalse(channel.finish());
        assertTrue(future.isDone());
        assertFalse(future.isSuccess());
    }

Domain

Subdomains

Frequently Asked Questions

What does testFlushStrategy() do?
testFlushStrategy() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicheQuicCodecTest.java.
Where is testFlushStrategy() defined?
testFlushStrategy() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicheQuicCodecTest.java at line 54.
What calls testFlushStrategy()?
testFlushStrategy() is called by 2 function(s): testFlushStrategyUsedWithBytes, testFlushStrategyUsedWithPackets.

Analyze Your Own Codebase

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

Try Supermodel Free