Same fix than in version 3.5 for Master branch (refer to issue #345)
Will be proposed once the one in 3.5 will be validated
This commit is contained in:
parent
714e3d682e
commit
3bd77e93f1
@ -15,13 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.handler.traffic;
|
package io.netty.handler.traffic;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
|
|
||||||
import io.netty.channel.ChannelHandler.Sharable;
|
import io.netty.channel.ChannelHandler.Sharable;
|
||||||
import io.netty.handler.execution.ExecutionHandler;
|
import io.netty.handler.execution.ExecutionHandler;
|
||||||
import io.netty.handler.execution.MemoryAwareThreadPoolExecutor;
|
import io.netty.handler.execution.MemoryAwareThreadPoolExecutor;
|
||||||
import io.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
|
import io.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
|
||||||
import io.netty.handler.execution.ObjectSizeEstimator;
|
import io.netty.handler.execution.ObjectSizeEstimator;
|
||||||
|
import io.netty.util.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation of the {@link AbstractTrafficShapingHandler} is for global
|
* This implementation of the {@link AbstractTrafficShapingHandler} is for global
|
||||||
@ -31,8 +30,8 @@ import io.netty.handler.execution.ObjectSizeEstimator;
|
|||||||
* The general use should be as follow:<br>
|
* The general use should be as follow:<br>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Create your unique GlobalTrafficShapingHandler like:<br><br>
|
* <li>Create your unique GlobalTrafficShapingHandler like:<br><br>
|
||||||
* <tt>GlobalTrafficShapingHandler myHandler = new GlobalTrafficShapingHandler(executor);</tt><br><br>
|
* <tt>GlobalTrafficShapingHandler myHandler = new GlobalTrafficShapingHandler(timer);</tt><br><br>
|
||||||
* executor could be created using <tt>Executors.newCachedThreadPool();</tt><br>
|
* timer could be created using <tt>HashedWheelTimer<tt><br>
|
||||||
* <tt>pipeline.addLast("GLOBAL_TRAFFIC_SHAPING", myHandler);</tt><br><br>
|
* <tt>pipeline.addLast("GLOBAL_TRAFFIC_SHAPING", myHandler);</tt><br><br>
|
||||||
*
|
*
|
||||||
* <b>Note that this handler has a Pipeline Coverage of "all" which means only one such handler must be created
|
* <b>Note that this handler has a Pipeline Coverage of "all" which means only one such handler must be created
|
||||||
@ -52,7 +51,7 @@ import io.netty.handler.execution.ObjectSizeEstimator;
|
|||||||
* {@link OrderedMemoryAwareThreadPoolExecutor} or {@link MemoryAwareThreadPoolExecutor}).<br>
|
* {@link OrderedMemoryAwareThreadPoolExecutor} or {@link MemoryAwareThreadPoolExecutor}).<br>
|
||||||
* <tt>pipeline.addLast("GLOBAL_TRAFFIC_SHAPING", myHandler);</tt><br><br>
|
* <tt>pipeline.addLast("GLOBAL_TRAFFIC_SHAPING", myHandler);</tt><br><br>
|
||||||
* </li>
|
* </li>
|
||||||
* <li>When you shutdown your application, release all the external resources like the executor
|
* <li>When you shutdown your application, release all the external resources (except the timer internal itself)
|
||||||
* by calling:<br>
|
* by calling:<br>
|
||||||
* <tt>myHandler.releaseExternalResources();</tt><br>
|
* <tt>myHandler.releaseExternalResources();</tt><br>
|
||||||
* </li>
|
* </li>
|
||||||
@ -64,96 +63,61 @@ public class GlobalTrafficShapingHandler extends AbstractTrafficShapingHandler {
|
|||||||
* Create the global TrafficCounter
|
* Create the global TrafficCounter
|
||||||
*/
|
*/
|
||||||
void createGlobalTrafficCounter() {
|
void createGlobalTrafficCounter() {
|
||||||
TrafficCounter tc = new TrafficCounter(this, executor, "GlobalTC",
|
TrafficCounter tc;
|
||||||
checkInterval);
|
if (timer != null) {
|
||||||
setTrafficCounter(tc);
|
tc = new TrafficCounter(this, timer, "GlobalTC",
|
||||||
tc.start();
|
checkInterval);
|
||||||
|
setTrafficCounter(tc);
|
||||||
|
tc.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public GlobalTrafficShapingHandler(Timer timer, long writeLimit,
|
||||||
* @param executor
|
|
||||||
* @param writeLimit
|
|
||||||
* @param readLimit
|
|
||||||
* @param checkInterval
|
|
||||||
*/
|
|
||||||
public GlobalTrafficShapingHandler(Executor executor, long writeLimit,
|
|
||||||
long readLimit, long checkInterval) {
|
long readLimit, long checkInterval) {
|
||||||
super(executor, writeLimit, readLimit, checkInterval);
|
super(timer, writeLimit, readLimit, checkInterval);
|
||||||
createGlobalTrafficCounter();
|
createGlobalTrafficCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public GlobalTrafficShapingHandler(Timer timer, long writeLimit,
|
||||||
* @param executor
|
|
||||||
* @param writeLimit
|
|
||||||
* @param readLimit
|
|
||||||
*/
|
|
||||||
public GlobalTrafficShapingHandler(Executor executor, long writeLimit,
|
|
||||||
long readLimit) {
|
long readLimit) {
|
||||||
super(executor, writeLimit, readLimit);
|
super(timer, writeLimit, readLimit);
|
||||||
createGlobalTrafficCounter();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param executor
|
|
||||||
* @param checkInterval
|
|
||||||
*/
|
|
||||||
public GlobalTrafficShapingHandler(Executor executor, long checkInterval) {
|
|
||||||
super(executor, checkInterval);
|
|
||||||
createGlobalTrafficCounter();
|
createGlobalTrafficCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public GlobalTrafficShapingHandler(Timer timer, long checkInterval) {
|
||||||
* @param executor
|
super(timer, checkInterval);
|
||||||
*/
|
createGlobalTrafficCounter();
|
||||||
public GlobalTrafficShapingHandler(Executor executor) {
|
}
|
||||||
super(executor);
|
|
||||||
|
public GlobalTrafficShapingHandler(Timer timer) {
|
||||||
|
super(timer);
|
||||||
createGlobalTrafficCounter();
|
createGlobalTrafficCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param objectSizeEstimator
|
|
||||||
* @param executor
|
|
||||||
* @param writeLimit
|
|
||||||
* @param readLimit
|
|
||||||
* @param checkInterval
|
|
||||||
*/
|
|
||||||
public GlobalTrafficShapingHandler(ObjectSizeEstimator objectSizeEstimator,
|
public GlobalTrafficShapingHandler(ObjectSizeEstimator objectSizeEstimator,
|
||||||
Executor executor, long writeLimit, long readLimit,
|
Timer timer, long writeLimit, long readLimit,
|
||||||
long checkInterval) {
|
long checkInterval) {
|
||||||
super(objectSizeEstimator, executor, writeLimit, readLimit,
|
super(objectSizeEstimator, timer, writeLimit, readLimit,
|
||||||
checkInterval);
|
checkInterval);
|
||||||
createGlobalTrafficCounter();
|
createGlobalTrafficCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param objectSizeEstimator
|
|
||||||
* @param executor
|
|
||||||
* @param writeLimit
|
|
||||||
* @param readLimit
|
|
||||||
*/
|
|
||||||
public GlobalTrafficShapingHandler(ObjectSizeEstimator objectSizeEstimator,
|
public GlobalTrafficShapingHandler(ObjectSizeEstimator objectSizeEstimator,
|
||||||
Executor executor, long writeLimit, long readLimit) {
|
Timer timer, long writeLimit, long readLimit) {
|
||||||
super(objectSizeEstimator, executor, writeLimit, readLimit);
|
super(objectSizeEstimator, timer, writeLimit, readLimit);
|
||||||
createGlobalTrafficCounter();
|
createGlobalTrafficCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param objectSizeEstimator
|
|
||||||
* @param executor
|
|
||||||
* @param checkInterval
|
|
||||||
*/
|
|
||||||
public GlobalTrafficShapingHandler(ObjectSizeEstimator objectSizeEstimator,
|
public GlobalTrafficShapingHandler(ObjectSizeEstimator objectSizeEstimator,
|
||||||
Executor executor, long checkInterval) {
|
Timer timer, long checkInterval) {
|
||||||
super(objectSizeEstimator, executor, checkInterval);
|
super(objectSizeEstimator, timer, checkInterval);
|
||||||
createGlobalTrafficCounter();
|
createGlobalTrafficCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param objectSizeEstimator
|
|
||||||
* @param executor
|
|
||||||
*/
|
|
||||||
public GlobalTrafficShapingHandler(ObjectSizeEstimator objectSizeEstimator,
|
public GlobalTrafficShapingHandler(ObjectSizeEstimator objectSizeEstimator,
|
||||||
Executor executor) {
|
Timer timer) {
|
||||||
super(objectSizeEstimator, executor);
|
super(objectSizeEstimator, timer);
|
||||||
createGlobalTrafficCounter();
|
createGlobalTrafficCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user