@ChannelHandler.Sharable public class GlobalTrafficShapingHandler extends AbstractTrafficShapingHandler
AbstractTrafficShapingHandler is for global
traffic shaping, that is to say a global limitation of the bandwidth, whatever
the number of opened channels.release() once this handler is not needed anymore to release all internal resources.
This will not shutdown the EventExecutor as it may be shared, so you need to do this by your own.ChannelHandler.SharablecheckInterval, DEFAULT_CHECK_INTERVAL, DEFAULT_MAX_TIME, maxTime, trafficCounter| Constructor and Description |
|---|
GlobalTrafficShapingHandler(EventExecutor executor)
Create a new instance
|
GlobalTrafficShapingHandler(ScheduledExecutorService executor,
long checkInterval)
Create a new instance
|
GlobalTrafficShapingHandler(ScheduledExecutorService executor,
long writeLimit,
long readLimit)
Create a new instance
|
GlobalTrafficShapingHandler(ScheduledExecutorService executor,
long writeLimit,
long readLimit,
long checkInterval)
Create a new instance
|
GlobalTrafficShapingHandler(ScheduledExecutorService executor,
long writeLimit,
long readLimit,
long checkInterval,
long maxTime)
Create a new instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
void |
handlerRemoved(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
void |
release()
Release all internal resources of this instance
|
protected void |
submitWrite(ChannelHandlerContext ctx,
Object msg,
long delay,
ChannelPromise promise) |
calculateSize, channelRead, configure, configure, configure, doAccounting, getCheckInterval, getMaxTimeWait, getReadLimit, getWriteLimit, isHandlerActive, read, setCheckInterval, setMaxTimeWait, setReadLimit, setWriteLimit, toString, trafficCounter, writebind, close, connect, deregister, disconnect, flushchannelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredisSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitexceptionCaughtpublic GlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeLimit, long readLimit, long checkInterval, long maxTime)
executor - the ScheduledExecutorService to use for the TrafficCounterwriteLimit - 0 or a limit in bytes/sreadLimit - 0 or a limit in bytes/scheckInterval - The delay between two computations of performances for
channels or 0 if no stats are to be computedmaxTime - The maximum delay to wait in case of traffic excesspublic GlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeLimit, long readLimit, long checkInterval)
executor - the ScheduledExecutorService to use for the TrafficCounterwriteLimit - 0 or a limit in bytes/sreadLimit - 0 or a limit in bytes/scheckInterval - The delay between two computations of performances for
channels or 0 if no stats are to be computedpublic GlobalTrafficShapingHandler(ScheduledExecutorService executor, long writeLimit, long readLimit)
executor - the ScheduledExecutorService to use for the TrafficCounterwriteLimit - 0 or a limit in bytes/sreadLimit - 0 or a limit in bytes/spublic GlobalTrafficShapingHandler(ScheduledExecutorService executor, long checkInterval)
executor - the ScheduledExecutorService to use for the TrafficCountercheckInterval - The delay between two computations of performances for
channels or 0 if no stats are to be computedpublic GlobalTrafficShapingHandler(EventExecutor executor)
executor - the ScheduledExecutorService to use for the TrafficCounterpublic final void release()
public void handlerAdded(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterhandlerAdded in interface ChannelHandlerhandlerAdded in class ChannelHandlerAdapterExceptionpublic void handlerRemoved(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterhandlerRemoved in interface ChannelHandlerhandlerRemoved in class ChannelHandlerAdapterExceptionprotected void submitWrite(ChannelHandlerContext ctx, Object msg, long delay, ChannelPromise promise)
submitWrite in class AbstractTrafficShapingHandlerCopyright © 2008–2014 The Netty Project. All rights reserved.