GlobalTrafficShapingHandler Class — netty Architecture
Architecture documentation for the GlobalTrafficShapingHandler class in GlobalTrafficShapingHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 25ae99c4_4bb1_9893_ce25_fa54995d6af1["GlobalTrafficShapingHandler"] 56b066c8_9f5e_b8d6_7611_973e59bdf8b9["GlobalTrafficShapingHandler.java"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|defined in| 56b066c8_9f5e_b8d6_7611_973e59bdf8b9 ee98b8da_8bb6_4b96_c4ab_4354c557f348["createGlobalTrafficCounter()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| ee98b8da_8bb6_4b96_c4ab_4354c557f348 7cce8575_95f0_eb4d_7331_0f17d07648c3["userDefinedWritabilityIndex()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| 7cce8575_95f0_eb4d_7331_0f17d07648c3 b966d22f_28b2_a5b4_f505_47979b0f1159["GlobalTrafficShapingHandler()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| b966d22f_28b2_a5b4_f505_47979b0f1159 3916ec70_0c21_107a_891f_d9d214adb2e1["getMaxGlobalWriteSize()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| 3916ec70_0c21_107a_891f_d9d214adb2e1 d42612d9_3ad5_bc87_3b95_d934432eac45["setMaxGlobalWriteSize()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| d42612d9_3ad5_bc87_3b95_d934432eac45 6ca19109_0ef9_9f92_1be8_daee9ecf09e1["queuesSize()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| 6ca19109_0ef9_9f92_1be8_daee9ecf09e1 3e8f5c2d_c798_2f7e_047c_8a550e9567de["release()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| 3e8f5c2d_c798_2f7e_047c_8a550e9567de b524ce42_3f71_22cb_1190_0a97828ae14d["PerChannel()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| b524ce42_3f71_22cb_1190_0a97828ae14d 4743f579_248e_f764_d8ae_ae9675dd57ad["handlerAdded()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| 4743f579_248e_f764_d8ae_ae9675dd57ad a5d9dd40_8a6e_6f8f_d2d0_0fbf517aed51["handlerRemoved()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| a5d9dd40_8a6e_6f8f_d2d0_0fbf517aed51 cf61ed13_75a4_605d_739d_8ab42e03ee38["checkWaitReadTime()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| cf61ed13_75a4_605d_739d_8ab42e03ee38 76726d03_426c_39e9_2809_0b7b309d2e35["informReadOperation()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| 76726d03_426c_39e9_2809_0b7b309d2e35 54f6e54e_8782_c399_da86_551bdcf1fafe["submitWrite()"] 25ae99c4_4bb1_9893_ce25_fa54995d6af1 -->|method| 54f6e54e_8782_c399_da86_551bdcf1fafe
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java lines 78–401
@Sharable
public class GlobalTrafficShapingHandler extends AbstractTrafficShapingHandler {
/**
* All queues per channel
*/
private final ConcurrentMap<Integer, PerChannel> channelQueues = new ConcurrentHashMap<>();
/**
* Global queues size
*/
private final AtomicLong queuesSize = new AtomicLong();
/**
* Max size in the list before proposing to stop writing new objects from next handlers
* for all channel (global)
*/
long maxGlobalWriteSize = DEFAULT_MAX_SIZE * 100; // default 400MB
private static final class PerChannel {
ArrayDeque<ToSend> messagesQueue;
long queueSize;
long lastWriteTimestamp;
long lastReadTimestamp;
}
/**
* Create the global TrafficCounter.
*/
void createGlobalTrafficCounter(ScheduledExecutorService executor) {
TrafficCounter tc = new TrafficCounter(this,
ObjectUtil.checkNotNull(executor, "executor"),
"GlobalTC",
checkInterval);
setTrafficCounter(tc);
tc.start();
}
@Override
protected int userDefinedWritabilityIndex() {
return AbstractTrafficShapingHandler.GLOBAL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX;
}
/**
* Create a new instance.
*
* @param executor
* the {@link ScheduledExecutorService} to use for the {@link TrafficCounter}.
* @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 GlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeLimit, long readLimit,
long checkInterval, long maxTime) {
super(writeLimit, readLimit, checkInterval, maxTime);
createGlobalTrafficCounter(executor);
}
/**
* Create a new instance using
* default max time as delay allowed value of 15000 ms.
*
* @param executor
* the {@link ScheduledExecutorService} to use for the {@link TrafficCounter}.
* @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 GlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeLimit,
long readLimit, long checkInterval) {
super(writeLimit, readLimit, checkInterval);
Source
Frequently Asked Questions
What is the GlobalTrafficShapingHandler class?
GlobalTrafficShapingHandler is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java.
Where is GlobalTrafficShapingHandler defined?
GlobalTrafficShapingHandler is defined in handler/src/main/java/io/netty/handler/traffic/GlobalTrafficShapingHandler.java at line 78.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free