Home / Function/ handlerRemoved() — netty Function Reference

handlerRemoved() — netty Function Reference

Architecture documentation for the handlerRemoved() function in GlobalChannelTrafficShapingHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  706081ef_7d7c_bb2e_f6ca_38466de329e4["handlerRemoved()"]
  70857fc2_a134_e299_7b48_1738d53c0016["GlobalChannelTrafficShapingHandler"]
  706081ef_7d7c_bb2e_f6ca_38466de329e4 -->|defined in| 70857fc2_a134_e299_7b48_1738d53c0016
  95f889b3_eae3_1bd8_4f15_602c55f0e60f["write()"]
  706081ef_7d7c_bb2e_f6ca_38466de329e4 -->|calls| 95f889b3_eae3_1bd8_4f15_602c55f0e60f
  f1c28e56_3e92_84c6_fbbe_578734762ca7["release()"]
  706081ef_7d7c_bb2e_f6ca_38466de329e4 -->|calls| f1c28e56_3e92_84c6_fbbe_578734762ca7
  style 706081ef_7d7c_bb2e_f6ca_38466de329e4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java lines 480–512

    @Override
    public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
        trafficCounter.resetCumulativeTime();
        Channel channel = ctx.channel();
        Integer key = channel.hashCode();
        PerChannel perChannel = channelQueues.remove(key);
        if (perChannel != null) {
            // write operations need synchronization
            synchronized (perChannel) {
                if (channel.isActive()) {
                    for (ToSend toSend : perChannel.messagesQueue) {
                        long size = calculateSize(toSend.toSend);
                        trafficCounter.bytesRealWriteFlowControl(size);
                        perChannel.channelTrafficCounter.bytesRealWriteFlowControl(size);
                        perChannel.queueSize -= size;
                        queuesSize.addAndGet(-size);
                        ctx.write(toSend.toSend, toSend.promise);
                    }
                } else {
                    queuesSize.addAndGet(-perChannel.queueSize);
                    for (ToSend toSend : perChannel.messagesQueue) {
                        if (toSend.toSend instanceof ByteBuf) {
                            ((ByteBuf) toSend.toSend).release();
                        }
                    }
                }
                perChannel.messagesQueue.clear();
            }
        }
        releaseWriteSuspended(ctx);
        releaseReadSuspended(ctx);
        super.handlerRemoved(ctx);
    }

Domain

Subdomains

Frequently Asked Questions

What does handlerRemoved() do?
handlerRemoved() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java.
Where is handlerRemoved() defined?
handlerRemoved() is defined in handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java at line 480.
What does handlerRemoved() call?
handlerRemoved() calls 2 function(s): release, write.

Analyze Your Own Codebase

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

Try Supermodel Free