Home / Function/ childQueueIsDrainedAndNewDataIsDispatchedInParentReadLoopNoAutoRead() — netty Function Reference

childQueueIsDrainedAndNewDataIsDispatchedInParentReadLoopNoAutoRead() — netty Function Reference

Architecture documentation for the childQueueIsDrainedAndNewDataIsDispatchedInParentReadLoopNoAutoRead() function in Http2MultiplexTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  bd1cdfef_7aca_ef78_4c9e_7c3c77559a41["childQueueIsDrainedAndNewDataIsDispatchedInParentReadLoopNoAutoRead()"]
  4745ff96_ed57_3bd8_9861_4b786d0b6e09["Http2MultiplexTest"]
  bd1cdfef_7aca_ef78_4c9e_7c3c77559a41 -->|defined in| 4745ff96_ed57_3bd8_9861_4b786d0b6e09
  style bd1cdfef_7aca_ef78_4c9e_7c3c77559a41 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexTest.java lines 1406–1476

    @Test
    public void childQueueIsDrainedAndNewDataIsDispatchedInParentReadLoopNoAutoRead() {
        final AtomicInteger numReads = new AtomicInteger(1);
        final AtomicInteger channelReadCompleteCount = new AtomicInteger(0);
        final AtomicBoolean shouldDisableAutoRead = new AtomicBoolean();
        Consumer<ChannelHandlerContext> ctxConsumer = new Consumer<ChannelHandlerContext>() {
            @Override
            public void accept(ChannelHandlerContext obj) {
                channelReadCompleteCount.incrementAndGet();
                if (shouldDisableAutoRead.get()) {
                    obj.channel().config().setAutoRead(false);
                }
            }
        };
        final LastInboundHandler inboundHandler = new LastInboundHandler(ctxConsumer);
        Http2StreamChannel childChannel = newInboundStream(3, false, numReads, inboundHandler);
        childChannel.config().setAutoRead(false);

        Http2DataFrame dataFrame1 = new DefaultHttp2DataFrame(bb("1")).stream(childChannel.stream());
        Http2DataFrame dataFrame2 = new DefaultHttp2DataFrame(bb("2")).stream(childChannel.stream());
        Http2DataFrame dataFrame3 = new DefaultHttp2DataFrame(bb("3")).stream(childChannel.stream());
        Http2DataFrame dataFrame4 = new DefaultHttp2DataFrame(bb("4")).stream(childChannel.stream());

        assertEquals(new DefaultHttp2HeadersFrame(request).stream(childChannel.stream()), inboundHandler.readInbound());

        ChannelHandler readCompleteSupressHandler = new ChannelInboundHandlerAdapter() {
            @Override
            public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
                // We want to simulate the parent channel calling channelRead and delay calling channelReadComplete.
            }
        };
        parentChannel.pipeline().addFirst(readCompleteSupressHandler);

        frameInboundWriter.writeInboundData(childChannel.stream().id(), bb("1"), 0, false);

        assertEqualsAndRelease(dataFrame1, inboundHandler.<Http2Frame>readInbound());

        // We want one item to be in the queue, and allow the numReads to be larger than 1. This will ensure that
        // when beginRead() is called the child channel is added to the readPending queue of the parent channel.
        frameInboundWriter.writeInboundData(childChannel.stream().id(), bb("2"), 0, false);

        numReads.set(2);
        childChannel.read();

        assertEqualsAndRelease(dataFrame2, inboundHandler.<Http2Frame>readInbound());

        assertNull(inboundHandler.readInbound());

        // This is the second item that was read, this should be the last until we call read() again. This should also
        // notify of readComplete().
        frameInboundWriter.writeInboundData(childChannel.stream().id(), bb("3"), 0, false);

        assertEqualsAndRelease(dataFrame3, inboundHandler.<Http2Frame>readInbound());

        frameInboundWriter.writeInboundData(childChannel.stream().id(), bb("4"), 0, false);
        assertNull(inboundHandler.readInbound());

        childChannel.read();

        assertEqualsAndRelease(dataFrame4, inboundHandler.<Http2Frame>readInbound());

        assertNull(inboundHandler.readInbound());

        // Now we want to call channelReadComplete and simulate the end of the read loop.
        parentChannel.pipeline().remove(readCompleteSupressHandler);
        parentChannel.flushInbound();

        // 3 = 1 for initialization + 1 for first read of 2 items + 1 for second read of 2 items +
        // 1 for parent channel readComplete
        assertEquals(4, channelReadCompleteCount.get());
    }

Domain

Subdomains

Frequently Asked Questions

What does childQueueIsDrainedAndNewDataIsDispatchedInParentReadLoopNoAutoRead() do?
childQueueIsDrainedAndNewDataIsDispatchedInParentReadLoopNoAutoRead() is a function in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexTest.java.
Where is childQueueIsDrainedAndNewDataIsDispatchedInParentReadLoopNoAutoRead() defined?
childQueueIsDrainedAndNewDataIsDispatchedInParentReadLoopNoAutoRead() is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MultiplexTest.java at line 1406.

Analyze Your Own Codebase

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

Try Supermodel Free