Home / Class/ EchoByteHandler Class — netty Architecture

EchoByteHandler Class — netty Architecture

Architecture documentation for the EchoByteHandler class in EchoByteHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  b95f388d_0316_b8b5_6d49_5ac9354700db["EchoByteHandler"]
  73e60742_e304_1d8f_c1a5_1ddc21e159ed["EchoByteHandler.java"]
  b95f388d_0316_b8b5_6d49_5ac9354700db -->|defined in| 73e60742_e304_1d8f_c1a5_1ddc21e159ed
  e4cb8b02_5eea_5081_57a6_5ad99dd9572e["counter()"]
  b95f388d_0316_b8b5_6d49_5ac9354700db -->|method| e4cb8b02_5eea_5081_57a6_5ad99dd9572e
  3734bcae_de5b_4336_213a_33b9fa533071["EchoByteHandler()"]
  b95f388d_0316_b8b5_6d49_5ac9354700db -->|method| 3734bcae_de5b_4336_213a_33b9fa533071
  30553b39_cf2e_0adf_fd1c_2bcce0289528["channelActive()"]
  b95f388d_0316_b8b5_6d49_5ac9354700db -->|method| 30553b39_cf2e_0adf_fd1c_2bcce0289528
  239bee91_7322_8a16_5f38_768215d6169e["channelRead()"]
  b95f388d_0316_b8b5_6d49_5ac9354700db -->|method| 239bee91_7322_8a16_5f38_768215d6169e
  a738c246_95c4_f54d_1a02_15cc131debb0["exceptionCaught()"]
  b95f388d_0316_b8b5_6d49_5ac9354700db -->|method| a738c246_95c4_f54d_1a02_15cc131debb0

Relationship Graph

Source Code

transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java lines 32–76

public class EchoByteHandler extends ChannelInboundHandlerAdapter {

    private static final InternalLogger log = InternalLoggerFactory.getInstance(EchoByteHandler.class);

    private final ByteBuf message;

    private volatile int counter;

    public int counter() {
        return counter;
    }

    public EchoByteHandler(final int messageSize) {

        message = Unpooled.buffer(messageSize);

        for (int i = 0; i < message.capacity(); i++) {
            message.writeByte((byte) i);
        }
    }

    @Override
    public void channelActive(final ChannelHandlerContext ctx) throws Exception {

        log.info("ECHO active {}", NioUdtProvider.socketUDT(ctx.channel()).toStringOptions());

        ctx.writeAndFlush(message);
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf buf = (ByteBuf) msg;
        counter += buf.readableBytes();
        ctx.writeAndFlush(msg);
    }

    @Override
    public void exceptionCaught(final ChannelHandlerContext ctx,
            final Throwable e) {

        log.error("exception : {}", e.getMessage());

        ctx.close();
    }
}

Frequently Asked Questions

What is the EchoByteHandler class?
EchoByteHandler is a class in the netty codebase, defined in transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java.
Where is EchoByteHandler defined?
EchoByteHandler is defined in transport-udt/src/test/java/io/netty/test/udt/util/EchoByteHandler.java at line 32.

Analyze Your Own Codebase

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

Try Supermodel Free