submitWrite() — netty Function Reference
Architecture documentation for the submitWrite() function in GlobalChannelTrafficShapingHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e0808444_5985_0d26_adac_0697fe4d503a["submitWrite()"] 70857fc2_a134_e299_7b48_1738d53c0016["GlobalChannelTrafficShapingHandler"] e0808444_5985_0d26_adac_0697fe4d503a -->|defined in| 70857fc2_a134_e299_7b48_1738d53c0016 95f889b3_eae3_1bd8_4f15_602c55f0e60f["write()"] 95f889b3_eae3_1bd8_4f15_602c55f0e60f -->|calls| e0808444_5985_0d26_adac_0697fe4d503a 95f889b3_eae3_1bd8_4f15_602c55f0e60f["write()"] e0808444_5985_0d26_adac_0697fe4d503a -->|calls| 95f889b3_eae3_1bd8_4f15_602c55f0e60f fcb44b6c_2b50_b0b5_033e_3d887cd78994["ToSend()"] e0808444_5985_0d26_adac_0697fe4d503a -->|calls| fcb44b6c_2b50_b0b5_033e_3d887cd78994 fdc8520e_a0b7_8af9_c2a9_1cedfe7a5952["sendAllValid()"] e0808444_5985_0d26_adac_0697fe4d503a -->|calls| fdc8520e_a0b7_8af9_c2a9_1cedfe7a5952 style e0808444_5985_0d26_adac_0697fe4d503a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java lines 693–740
@Override
protected void submitWrite(final ChannelHandlerContext ctx, final Object msg,
final long size, final long writedelay, final long now,
final ChannelPromise promise) {
Channel channel = ctx.channel();
Integer key = channel.hashCode();
PerChannel perChannel = channelQueues.get(key);
if (perChannel == null) {
// in case write occurs before handlerAdded is raised for this handler
// imply a synchronized only if needed
perChannel = getOrSetPerChannel(ctx);
}
final ToSend newToSend;
long delay = writedelay;
boolean globalSizeExceeded = false;
// write operations need synchronization
synchronized (perChannel) {
if (writedelay == 0 && perChannel.messagesQueue.isEmpty()) {
trafficCounter.bytesRealWriteFlowControl(size);
perChannel.channelTrafficCounter.bytesRealWriteFlowControl(size);
ctx.write(msg, promise);
perChannel.lastWriteTimestamp = now;
return;
}
if (delay > maxTime && now + delay - perChannel.lastWriteTimestamp > maxTime) {
delay = maxTime;
}
newToSend = new ToSend(delay + now, msg, size, promise);
perChannel.messagesQueue.addLast(newToSend);
perChannel.queueSize += size;
queuesSize.addAndGet(size);
checkWriteSuspend(ctx, delay, perChannel.queueSize);
if (queuesSize.get() > maxGlobalWriteSize) {
globalSizeExceeded = true;
}
}
if (globalSizeExceeded) {
setUserDefinedWritability(ctx, false);
}
final long futureNow = newToSend.relativeTimeAction;
final PerChannel forSchedule = perChannel;
ctx.executor().schedule(new Runnable() {
@Override
public void run() {
sendAllValid(ctx, forSchedule, futureNow);
}
}, delay, TimeUnit.MILLISECONDS);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does submitWrite() do?
submitWrite() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java.
Where is submitWrite() defined?
submitWrite() is defined in handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java at line 693.
What does submitWrite() call?
submitWrite() calls 3 function(s): ToSend, sendAllValid, write.
What calls submitWrite()?
submitWrite() is called by 1 function(s): write.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free