GlobalChannelTrafficCounter Class — netty Architecture
Architecture documentation for the GlobalChannelTrafficCounter class in GlobalChannelTrafficCounter.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 2a051faf_25b0_e46d_ad69_5f887649cee4["GlobalChannelTrafficCounter"] ebc539a8_6c99_bb78_32a4_7f74a286b263["GlobalChannelTrafficCounter.java"] 2a051faf_25b0_e46d_ad69_5f887649cee4 -->|defined in| ebc539a8_6c99_bb78_32a4_7f74a286b263 d1b515cd_4051_5ea0_fa27_2480e446a305["GlobalChannelTrafficCounter()"] 2a051faf_25b0_e46d_ad69_5f887649cee4 -->|method| d1b515cd_4051_5ea0_fa27_2480e446a305 616b7daf_1b94_5de0_6cde_f9cf0e81360d["start()"] 2a051faf_25b0_e46d_ad69_5f887649cee4 -->|method| 616b7daf_1b94_5de0_6cde_f9cf0e81360d a5856cba_651f_03dc_2e4a_4629f660f686["stop()"] 2a051faf_25b0_e46d_ad69_5f887649cee4 -->|method| a5856cba_651f_03dc_2e4a_4629f660f686 b72ae670_2fe0_4b6d_14dc_0be2278feb98["resetCumulativeTime()"] 2a051faf_25b0_e46d_ad69_5f887649cee4 -->|method| b72ae670_2fe0_4b6d_14dc_0be2278feb98
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficCounter.java lines 31–127
public class GlobalChannelTrafficCounter extends TrafficCounter {
/**
* @param trafficShapingHandler the associated {@link GlobalChannelTrafficShapingHandler}.
* @param executor the underlying executor service for scheduling checks (both Global and per Channel).
* @param name the name given to this monitor.
* @param checkInterval the checkInterval in millisecond between two computations.
*/
public GlobalChannelTrafficCounter(GlobalChannelTrafficShapingHandler trafficShapingHandler,
ScheduledExecutorService executor, String name, long checkInterval) {
super(trafficShapingHandler, executor, name, checkInterval);
checkNotNullWithIAE(executor, "executor");
}
/**
* Class to implement monitoring at fix delay.
* This version is Mixed in the way it mixes Global and Channel counters.
*/
private static class MixedTrafficMonitoringTask implements Runnable {
/**
* The associated TrafficShapingHandler
*/
private final GlobalChannelTrafficShapingHandler trafficShapingHandler1;
/**
* The associated TrafficCounter
*/
private final TrafficCounter counter;
/**
* @param trafficShapingHandler The parent handler to which this task needs to callback to for accounting.
* @param counter The parent TrafficCounter that we need to reset the statistics for.
*/
MixedTrafficMonitoringTask(
GlobalChannelTrafficShapingHandler trafficShapingHandler,
TrafficCounter counter) {
trafficShapingHandler1 = trafficShapingHandler;
this.counter = counter;
}
@Override
public void run() {
if (!counter.monitorActive) {
return;
}
long newLastTime = milliSecondFromNano();
counter.resetAccounting(newLastTime);
for (PerChannel perChannel : trafficShapingHandler1.channelQueues.values()) {
perChannel.channelTrafficCounter.resetAccounting(newLastTime);
}
trafficShapingHandler1.doAccounting(counter);
}
}
/**
* Start the monitoring process.
*/
@Override
public synchronized void start() {
if (monitorActive) {
return;
}
lastTime.set(milliSecondFromNano());
long localCheckInterval = checkInterval.get();
if (localCheckInterval > 0) {
monitorActive = true;
monitor = new MixedTrafficMonitoringTask((GlobalChannelTrafficShapingHandler) trafficShapingHandler, this);
scheduledFuture =
executor.scheduleAtFixedRate(monitor, 0, localCheckInterval, TimeUnit.MILLISECONDS);
}
}
/**
* Stop the monitoring process.
*/
@Override
public synchronized void stop() {
if (!monitorActive) {
return;
}
monitorActive = false;
resetAccounting(milliSecondFromNano());
Source
Frequently Asked Questions
What is the GlobalChannelTrafficCounter class?
GlobalChannelTrafficCounter is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficCounter.java.
Where is GlobalChannelTrafficCounter defined?
GlobalChannelTrafficCounter is defined in handler/src/main/java/io/netty/handler/traffic/GlobalChannelTrafficCounter.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free