Home / Class/ ChannelTrafficShapingHandler Class — netty Architecture

ChannelTrafficShapingHandler Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  3ab3cf0d_ce70_e3dd_bab1_dbf87d133f02["ChannelTrafficShapingHandler"]
  86afef77_edd9_241a_e476_e4354e528092["ChannelTrafficShapingHandler.java"]
  3ab3cf0d_ce70_e3dd_bab1_dbf87d133f02 -->|defined in| 86afef77_edd9_241a_e476_e4354e528092
  471beea2_19fd_dc03_4ee6_1da9043f7f91["ChannelTrafficShapingHandler()"]
  3ab3cf0d_ce70_e3dd_bab1_dbf87d133f02 -->|method| 471beea2_19fd_dc03_4ee6_1da9043f7f91
  cbf55388_0ff5_b7fa_6f3b_b876514b04f7["handlerAdded()"]
  3ab3cf0d_ce70_e3dd_bab1_dbf87d133f02 -->|method| cbf55388_0ff5_b7fa_6f3b_b876514b04f7
  9e0f814d_7a6a_c08a_b1f5_4c590da72ce7["handlerRemoved()"]
  3ab3cf0d_ce70_e3dd_bab1_dbf87d133f02 -->|method| 9e0f814d_7a6a_c08a_b1f5_4c590da72ce7
  1b713933_a184_93c1_9ea9_dd7bde595461["submitWrite()"]
  3ab3cf0d_ce70_e3dd_bab1_dbf87d133f02 -->|method| 1b713933_a184_93c1_9ea9_dd7bde595461
  e4f33061_39c5_e7d9_db16_146de71ad694["sendAllValid()"]
  3ab3cf0d_ce70_e3dd_bab1_dbf87d133f02 -->|method| e4f33061_39c5_e7d9_db16_146de71ad694
  bf66436a_3747_0908_5423_fd442291a916["queueSize()"]
  3ab3cf0d_ce70_e3dd_bab1_dbf87d133f02 -->|method| bf66436a_3747_0908_5423_fd442291a916

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java lines 65–231

public class ChannelTrafficShapingHandler extends AbstractTrafficShapingHandler {
    private final ArrayDeque<ToSend> messagesQueue = new ArrayDeque<ToSend>();
    private long queueSize;

    /**
     * Create a new instance.
     *
     * @param writeLimit
     *            0 or a limit in bytes/s
     * @param readLimit
     *            0 or a limit in bytes/s
     * @param checkInterval
     *            The delay between two computations of performances for
     *            channels or 0 if no stats are to be computed.
     * @param maxTime
     *            The maximum delay to wait in case of traffic excess.
     */
    public ChannelTrafficShapingHandler(long writeLimit, long readLimit,
            long checkInterval, long maxTime) {
        super(writeLimit, readLimit, checkInterval, maxTime);
    }

    /**
     * Create a new instance using default
     * max time as delay allowed value of 15000 ms.
     *
     * @param writeLimit
     *          0 or a limit in bytes/s
     * @param readLimit
     *          0 or a limit in bytes/s
     * @param checkInterval
     *          The delay between two computations of performances for
     *            channels or 0 if no stats are to be computed.
     */
    public ChannelTrafficShapingHandler(long writeLimit,
            long readLimit, long checkInterval) {
        super(writeLimit, readLimit, checkInterval);
    }

    /**
     * Create a new instance using default Check Interval value of 1000 ms and
     * max time as delay allowed value of 15000 ms.
     *
     * @param writeLimit
     *          0 or a limit in bytes/s
     * @param readLimit
     *          0 or a limit in bytes/s
     */
    public ChannelTrafficShapingHandler(long writeLimit,
            long readLimit) {
        super(writeLimit, readLimit);
    }

    /**
     * Create a new instance using
     * default max time as delay allowed value of 15000 ms and no limit.
     *
     * @param checkInterval
     *          The delay between two computations of performances for
     *            channels or 0 if no stats are to be computed.
     */
    public ChannelTrafficShapingHandler(long checkInterval) {
        super(checkInterval);
    }

    @Override
    public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
        TrafficCounter trafficCounter = new TrafficCounter(this, ctx.executor(), "ChannelTC" +
                ctx.channel().hashCode(), checkInterval);
        setTrafficCounter(trafficCounter);
        trafficCounter.start();
        super.handlerAdded(ctx);
    }

    @Override
    public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
        trafficCounter.stop();
        // write order control
        synchronized (this) {
            if (ctx.channel().isActive()) {
                for (ToSend toSend : messagesQueue) {

Frequently Asked Questions

What is the ChannelTrafficShapingHandler class?
ChannelTrafficShapingHandler is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java.
Where is ChannelTrafficShapingHandler defined?
ChannelTrafficShapingHandler is defined in handler/src/main/java/io/netty/handler/traffic/ChannelTrafficShapingHandler.java at line 65.

Analyze Your Own Codebase

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

Try Supermodel Free