channelRead() — netty Function Reference
Architecture documentation for the channelRead() function in AbstractTrafficShapingHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD fb0bd446_d029_b153_b41c_ec3b265bd3ac["channelRead()"] 8335ea87_158a_c21f_4d30_8f254caf2ded["AbstractTrafficShapingHandler"] fb0bd446_d029_b153_b41c_ec3b265bd3ac -->|defined in| 8335ea87_158a_c21f_4d30_8f254caf2ded a91eab56_8f89_970f_38b0_86168fd566bd["calculateSize()"] fb0bd446_d029_b153_b41c_ec3b265bd3ac -->|calls| a91eab56_8f89_970f_38b0_86168fd566bd 26eff0b4_2947_71aa_7687_c056c00e9223["checkWaitReadTime()"] fb0bd446_d029_b153_b41c_ec3b265bd3ac -->|calls| 26eff0b4_2947_71aa_7687_c056c00e9223 5546df53_f7c6_1216_f0ef_637a40f2a3fa["isHandlerActive()"] fb0bd446_d029_b153_b41c_ec3b265bd3ac -->|calls| 5546df53_f7c6_1216_f0ef_637a40f2a3fa 5b58fa00_a407_e8db_8cd8_d733412bb1e9["ReopenReadTimerTask()"] fb0bd446_d029_b153_b41c_ec3b265bd3ac -->|calls| 5b58fa00_a407_e8db_8cd8_d733412bb1e9 2d957381_0308_38a2_c8fd_61f349a484d3["informReadOperation()"] fb0bd446_d029_b153_b41c_ec3b265bd3ac -->|calls| 2d957381_0308_38a2_c8fd_61f349a484d3 style fb0bd446_d029_b153_b41c_ec3b265bd3ac fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java lines 469–507
@Override
public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
long size = calculateSize(msg);
long now = TrafficCounter.milliSecondFromNano();
if (size > 0) {
// compute the number of ms to wait before reopening the channel
long wait = trafficCounter.readTimeToWait(size, readLimit, maxTime, now);
wait = checkWaitReadTime(ctx, wait, now);
if (wait >= MINIMAL_WAIT) { // At least 10ms seems a minimal
// time in order to try to limit the traffic
// Only AutoRead AND HandlerActive True means Context Active
Channel channel = ctx.channel();
ChannelConfig config = channel.config();
if (logger.isDebugEnabled()) {
logger.debug("Read suspend: " + wait + ':' + config.isAutoRead() + ':'
+ isHandlerActive(ctx));
}
if (config.isAutoRead() && isHandlerActive(ctx)) {
config.setAutoRead(false);
channel.attr(READ_SUSPENDED).set(true);
// Create a Runnable to reactive the read if needed. If one was create before it will just be
// reused to limit object creation
Attribute<Runnable> attr = channel.attr(REOPEN_TASK);
Runnable reopenTask = attr.get();
if (reopenTask == null) {
reopenTask = new ReopenReadTimerTask(ctx);
attr.set(reopenTask);
}
ctx.executor().schedule(reopenTask, wait, TimeUnit.MILLISECONDS);
if (logger.isDebugEnabled()) {
logger.debug("Suspend final status => " + config.isAutoRead() + ':'
+ isHandlerActive(ctx) + " will reopened at: " + wait);
}
}
}
}
informReadOperation(ctx, now);
ctx.fireChannelRead(msg);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does channelRead() do?
channelRead() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java.
Where is channelRead() defined?
channelRead() is defined in handler/src/main/java/io/netty/handler/traffic/AbstractTrafficShapingHandler.java at line 469.
What does channelRead() call?
channelRead() calls 5 function(s): ReopenReadTimerTask, calculateSize, checkWaitReadTime, informReadOperation, isHandlerActive.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free