Home / Class/ SpdyEchoTestClientHandler Class — netty Architecture

SpdyEchoTestClientHandler Class — netty Architecture

Architecture documentation for the SpdyEchoTestClientHandler class in SocketSpdyEchoTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  4c87ad0e_19af_537a_1acb_ce96aa7fd113["SpdyEchoTestClientHandler"]
  9d0e1508_0ea8_c1d9_8c6d_ac1e2e7350e6["SocketSpdyEchoTest.java"]
  4c87ad0e_19af_537a_1acb_ce96aa7fd113 -->|defined in| 9d0e1508_0ea8_c1d9_8c6d_ac1e2e7350e6
  22c1d0f9_08bf_fe5b_011f_08bf288bf404["SpdyEchoTestClientHandler()"]
  4c87ad0e_19af_537a_1acb_ce96aa7fd113 -->|method| 22c1d0f9_08bf_fe5b_011f_08bf288bf404
  cdb49aab_4cbb_6b53_793b_d7bd9c03b5b8["channelActive()"]
  4c87ad0e_19af_537a_1acb_ce96aa7fd113 -->|method| cdb49aab_4cbb_6b53_793b_d7bd9c03b5b8
  2c64a59e_d389_7146_6693_ee32f2b34e31["channelRead0()"]
  4c87ad0e_19af_537a_1acb_ce96aa7fd113 -->|method| 2c64a59e_d389_7146_6693_ee32f2b34e31
  fb9e7f63_4fed_0e1a_6ef1_49c981606aa8["exceptionCaught()"]
  4c87ad0e_19af_537a_1acb_ce96aa7fd113 -->|method| fb9e7f63_4fed_0e1a_6ef1_49c981606aa8
  202c8685_e3dc_9f00_7932_2db8bd3881f0["channelReadComplete()"]
  4c87ad0e_19af_537a_1acb_ce96aa7fd113 -->|method| 202c8685_e3dc_9f00_7932_2db8bd3881f0

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSpdyEchoTest.java lines 279–322

    private static class SpdyEchoTestClientHandler extends SimpleChannelInboundHandler<ByteBuf> {
        private final boolean autoRead;
        final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
        final ByteBuf frames;
        volatile int counter;

        SpdyEchoTestClientHandler(ByteBuf frames, boolean autoRead) {
            this.frames = frames;
            this.autoRead = autoRead;
        }
        @Override
        public void channelActive(ChannelHandlerContext ctx) throws Exception {
            if (!autoRead) {
                ctx.read();
            }
        }

        @Override
        public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
            byte[] actual = new byte[in.readableBytes()];
            in.readBytes(actual);

            int lastIdx = counter;
            for (int i = 0; i < actual.length; i ++) {
                assertEquals(frames.getByte(ignoredBytes + i + lastIdx), actual[i]);
            }

            counter += actual.length;
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
            if (exception.compareAndSet(null, cause)) {
                ctx.close();
            }
        }

        @Override
        public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
            if (!autoRead) {
                ctx.read();
            }
        }
    }

Frequently Asked Questions

What is the SpdyEchoTestClientHandler class?
SpdyEchoTestClientHandler is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSpdyEchoTest.java.
Where is SpdyEchoTestClientHandler defined?
SpdyEchoTestClientHandler is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSpdyEchoTest.java at line 279.

Analyze Your Own Codebase

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

Try Supermodel Free