GlobalChannelTrafficShapingHandler Class — netty Architecture
Architecture documentation for the GlobalChannelTrafficShapingHandler class in GlobalChannelTrafficShapingHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 70857fc2_a134_e299_7b48_1738d53c0016["GlobalChannelTrafficShapingHandler"] 2a6f3579_5e2c_f3dd_d952_233cf1266660["GlobalChannelTrafficShapingHandler.java"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|defined in| 2a6f3579_5e2c_f3dd_d952_233cf1266660 87612d77_4348_8664_2730_9c2305a55ccb["createGlobalTrafficCounter()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| 87612d77_4348_8664_2730_9c2305a55ccb a765fd60_05d3_e2a0_4d5e_a168a2661d11["userDefinedWritabilityIndex()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| a765fd60_05d3_e2a0_4d5e_a168a2661d11 32866b34_af8c_68a2_c3dc_0d80794a41b8["GlobalChannelTrafficShapingHandler()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| 32866b34_af8c_68a2_c3dc_0d80794a41b8 197fd8c0_d3a7_4da9_4743_9a0c478debad["maxDeviation()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| 197fd8c0_d3a7_4da9_4743_9a0c478debad 81f09c18_d1e3_e366_338e_a2b7dc9e2f10["accelerationFactor()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| 81f09c18_d1e3_e366_338e_a2b7dc9e2f10 27affa1d_5c3a_9e1c_9b96_58934f02aabb["slowDownFactor()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| 27affa1d_5c3a_9e1c_9b96_58934f02aabb cf8addf9_b3f8_ca59_a053_79f7174422d0["setMaxDeviation()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| cf8addf9_b3f8_ca59_a053_79f7174422d0 dc4f3c28_7980_8d8c_dff3_c5128677de24["computeDeviationCumulativeBytes()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| dc4f3c28_7980_8d8c_dff3_c5128677de24 eea939a3_df3c_a437_65bb_184607e3a12d["doAccounting()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| eea939a3_df3c_a437_65bb_184607e3a12d 69a96252_28cc_c201_a07c_016f54efb94c["computeBalancedWait()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| 69a96252_28cc_c201_a07c_016f54efb94c b82302b0_5452_debb_0873_8cdfbf4f2bd6["getMaxGlobalWriteSize()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| b82302b0_5452_debb_0873_8cdfbf4f2bd6 b3d343e0_dafb_cdb0_a3b1_3cb72f98cc11["setMaxGlobalWriteSize()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| b3d343e0_dafb_cdb0_a3b1_3cb72f98cc11 4040e5e4_ecb1_d9f3_c54e_f5aa7690c4dc["queuesSize()"] 70857fc2_a134_e299_7b48_1738d53c0016 -->|method| 4040e5e4_ecb1_d9f3_c54e_f5aa7690c4dc
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java lines 90–773
@Sharable
public class GlobalChannelTrafficShapingHandler extends AbstractTrafficShapingHandler {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(GlobalChannelTrafficShapingHandler.class);
/**
* All queues per channel
*/
final ConcurrentMap<Integer, PerChannel> channelQueues = new ConcurrentHashMap<>();
/**
* Global queues size
*/
private final AtomicLong queuesSize = new AtomicLong();
/**
* Maximum cumulative writing bytes for one channel among all (as long as channels stay the same)
*/
private final AtomicLong cumulativeWrittenBytes = new AtomicLong();
/**
* Maximum cumulative read bytes for one channel among all (as long as channels stay the same)
*/
private final AtomicLong cumulativeReadBytes = new AtomicLong();
/**
* Max size in the list before proposing to stop writing new objects from next handlers
* for all channel (global)
*/
volatile long maxGlobalWriteSize = DEFAULT_MAX_SIZE * 100; // default 400MB
/**
* Limit in B/s to apply to write
*/
private volatile long writeChannelLimit;
/**
* Limit in B/s to apply to read
*/
private volatile long readChannelLimit;
private static final float DEFAULT_DEVIATION = 0.1F;
private static final float MAX_DEVIATION = 0.4F;
private static final float DEFAULT_SLOWDOWN = 0.4F;
private static final float DEFAULT_ACCELERATION = -0.1F;
private volatile float maxDeviation;
private volatile float accelerationFactor;
private volatile float slowDownFactor;
private volatile boolean readDeviationActive;
private volatile boolean writeDeviationActive;
static final class PerChannel {
ArrayDeque<ToSend> messagesQueue;
TrafficCounter channelTrafficCounter;
long queueSize;
long lastWriteTimestamp;
long lastReadTimestamp;
}
/**
* Create the global TrafficCounter
*/
void createGlobalTrafficCounter(ScheduledExecutorService executor) {
// Default
setMaxDeviation(DEFAULT_DEVIATION, DEFAULT_SLOWDOWN, DEFAULT_ACCELERATION);
checkNotNullWithIAE(executor, "executor");
TrafficCounter tc = new GlobalChannelTrafficCounter(this, executor, "GlobalChannelTC", checkInterval);
setTrafficCounter(tc);
tc.start();
}
@Override
protected int userDefinedWritabilityIndex() {
return AbstractTrafficShapingHandler.GLOBALCHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX;
}
/**
* Create a new instance.
*
* @param executor
* the {@link ScheduledExecutorService} to use for the {@link TrafficCounter}.
* @param writeGlobalLimit
Source
Frequently Asked Questions
What is the GlobalChannelTrafficShapingHandler class?
GlobalChannelTrafficShapingHandler is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java.
Where is GlobalChannelTrafficShapingHandler defined?
GlobalChannelTrafficShapingHandler is defined in handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficShapingHandler.java at line 90.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free