Home / Function/ observeOutputIdle() — netty Function Reference

observeOutputIdle() — netty Function Reference

Architecture documentation for the observeOutputIdle() function in IdleStateHandlerTest.java from the netty codebase.

Function java Buffer Allocators calls 2 called by 2

Entity Profile

Dependency Diagram

graph TD
  4603684a_0605_686e_f307_23319cb70e14["observeOutputIdle()"]
  f1a156c3_6366_afc7_6b64_9543e5f91ba9["IdleStateHandlerTest"]
  4603684a_0605_686e_f307_23319cb70e14 -->|defined in| f1a156c3_6366_afc7_6b64_9543e5f91ba9
  986ff7c4_fdc7_a35d_fc1d_1ae708241887["testObserveWriterIdle()"]
  986ff7c4_fdc7_a35d_fc1d_1ae708241887 -->|calls| 4603684a_0605_686e_f307_23319cb70e14
  d04c6cb1_49ec_a2aa_cb19_67da01cf216b["testObserveAllIdle()"]
  d04c6cb1_49ec_a2aa_cb19_67da01cf216b -->|calls| 4603684a_0605_686e_f307_23319cb70e14
  debc1f58_1548_0245_2304_17ee9f9d6b51["ObservableChannel()"]
  4603684a_0605_686e_f307_23319cb70e14 -->|calls| debc1f58_1548_0245_2304_17ee9f9d6b51
  bb158678_d17d_a690_f4aa_bca8aceb61e5["assertNotNullAndRelease()"]
  4603684a_0605_686e_f307_23319cb70e14 -->|calls| bb158678_d17d_a690_f4aa_bca8aceb61e5
  style 4603684a_0605_686e_f307_23319cb70e14 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java lines 238–364

    private static void observeOutputIdle(boolean writer) throws Exception {

        long writerIdleTime = 0L;
        long allIdleTime = 0L;
        IdleStateEvent expected;

        if (writer) {
            writerIdleTime = 5L;
            expected = IdleStateEvent.FIRST_WRITER_IDLE_STATE_EVENT;
        } else {
            allIdleTime = 5L;
            expected = IdleStateEvent.FIRST_ALL_IDLE_STATE_EVENT;
        }

        IdleStateHandler idleStateHandler = new IdleStateHandler(
                true, 0L, writerIdleTime, allIdleTime, TimeUnit.SECONDS);

        final List<Object> events = new ArrayList<Object>();
        ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() {
            @Override
            public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
                events.add(evt);
            }
        };

        ObservableChannel channel = new ObservableChannel(idleStateHandler, handler);
        channel.freezeTime();
        try {
            // We're writing 3 messages that will be consumed at different rates!
            channel.writeAndFlush(Unpooled.wrappedBuffer(new byte[] { 1 }));
            channel.writeAndFlush(Unpooled.wrappedBuffer(new byte[] { 2 }));
            channel.writeAndFlush(Unpooled.wrappedBuffer(new byte[] { 3 }));
            channel.writeAndFlush(Unpooled.wrappedBuffer(new byte[5 * 1024]));

            // Establish a baseline. We're not consuming anything and let it idle once.
            channel.advanceTimeBy(5, TimeUnit.SECONDS);
            channel.runPendingTasks();
            assertEquals(1, events.size());
            assertSame(expected, events.get(0));
            events.clear();

            // Consume one message in 4 seconds, then be idle for 2 seconds,
            // then run the task and we shouldn't get an IdleStateEvent because
            // we haven't been idle for long enough!
            channel.advanceTimeBy(4, TimeUnit.SECONDS);
            channel.runPendingTasks();
            assertNotNullAndRelease(channel.consume());

            channel.advanceTimeBy(2, TimeUnit.SECONDS);
            channel.runPendingTasks();
            assertEquals(0, events.size());

            // Consume one message in 3 seconds, then be idle for 4 seconds,
            // then run the task and we shouldn't get an IdleStateEvent because
            // we haven't been idle for long enough!
            channel.advanceTimeBy(2, TimeUnit.SECONDS);
            channel.runPendingTasks();
            assertNotNullAndRelease(channel.consume());

            channel.advanceTimeBy(4, TimeUnit.SECONDS);
            channel.runPendingTasks();
            assertEquals(0, events.size());

            // Don't consume a message and be idle for 5 seconds.
            // We should get an IdleStateEvent!
            channel.advanceTimeBy(5, TimeUnit.SECONDS);
            channel.runPendingTasks();
            assertEquals(1, events.size());
            events.clear();

            // Consume one message in 2 seconds, then be idle for 1 seconds,
            // then run the task and we shouldn't get an IdleStateEvent because
            // we haven't been idle for long enough!
            channel.advanceTimeBy(2, TimeUnit.SECONDS);
            channel.runPendingTasks();
            assertNotNullAndRelease(channel.consume());

            channel.advanceTimeBy(1, TimeUnit.SECONDS);
            channel.runPendingTasks();
            assertEquals(0, events.size());

Domain

Subdomains

Frequently Asked Questions

What does observeOutputIdle() do?
observeOutputIdle() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java.
Where is observeOutputIdle() defined?
observeOutputIdle() is defined in handler/src/test/java/io/netty/handler/timeout/IdleStateHandlerTest.java at line 238.
What does observeOutputIdle() call?
observeOutputIdle() calls 2 function(s): ObservableChannel, assertNotNullAndRelease.
What calls observeOutputIdle()?
observeOutputIdle() is called by 2 function(s): testObserveAllIdle, testObserveWriterIdle.

Analyze Your Own Codebase

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

Try Supermodel Free