public abstract class AbstractTrafficShapingHandler
extends io.netty.channel.ChannelDuplexHandler
GlobalTrafficShapingHandler) or per session
bandwidth (see ChannelTrafficShapingHandler), as traffic shaping.
It allows you to implement an almost real time monitoring of the bandwidth using
the monitors from TrafficCounter that will call back every checkInterval
the method doAccounting of this handler.| Modifier and Type | Field and Description |
|---|---|
protected long |
checkInterval
Delay between two performance snapshots
|
static long |
DEFAULT_CHECK_INTERVAL
Default delay between two checks: 1s
|
protected TrafficCounter |
trafficCounter
Traffic Counter
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractTrafficShapingHandler()
Constructor using NO LIMIT and default Check Interval
|
protected |
AbstractTrafficShapingHandler(long checkInterval)
Constructor using NO LIMIT
|
protected |
AbstractTrafficShapingHandler(long writeLimit,
long readLimit)
Constructor using default Check Interval
|
protected |
AbstractTrafficShapingHandler(long writeLimit,
long readLimit,
long checkInterval) |
| Modifier and Type | Method and Description |
|---|---|
protected long |
calculateSize(Object msg)
Calculate the size of the given
Object. |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
configure(long newCheckInterval)
Change the check interval.
|
void |
configure(long newWriteLimit,
long newReadLimit)
Change the underlying limitations.
|
void |
configure(long newWriteLimit,
long newReadLimit,
long newCheckInterval)
Change the underlying limitations and check interval.
|
protected void |
doAccounting(TrafficCounter counter)
Called each time the accounting is computed from the TrafficCounters.
|
void |
read(io.netty.channel.ChannelHandlerContext ctx) |
String |
toString() |
TrafficCounter |
trafficCounter() |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise) |
bind, close, connect, deregister, disconnect, flushchannelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredhandlerAdded, handlerRemoved, isSharablepublic static final long DEFAULT_CHECK_INTERVAL
protected TrafficCounter trafficCounter
protected long checkInterval
protected AbstractTrafficShapingHandler(long writeLimit,
long readLimit,
long checkInterval)
writeLimit - 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 computedprotected AbstractTrafficShapingHandler(long writeLimit,
long readLimit)
writeLimit - 0 or a limit in bytes/sreadLimit - 0 or a limit in bytes/sprotected AbstractTrafficShapingHandler()
protected AbstractTrafficShapingHandler(long checkInterval)
checkInterval - The delay between two computations of performances for
channels or 0 if no stats are to be computedpublic void configure(long newWriteLimit,
long newReadLimit,
long newCheckInterval)
newWriteLimit - The new write limit (in bytes)newReadLimit - The new read limit (in bytes)newCheckInterval - The new check interval (in milliseconds)public void configure(long newWriteLimit,
long newReadLimit)
newWriteLimit - The new write limit (in bytes)newReadLimit - The new read limit (in bytes)public void configure(long newCheckInterval)
newCheckInterval - The new check interval (in milliseconds)protected void doAccounting(TrafficCounter counter)
counter - the TrafficCounter that computes its performancepublic void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
throws Exception
channelRead in interface io.netty.channel.ChannelInboundHandlerchannelRead in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void read(io.netty.channel.ChannelHandlerContext ctx)
read in interface io.netty.channel.ChannelOutboundHandlerread in class io.netty.channel.ChannelDuplexHandlerpublic void write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
throws Exception
write in interface io.netty.channel.ChannelOutboundHandlerwrite in class io.netty.channel.ChannelDuplexHandlerExceptionpublic TrafficCounter trafficCounter()
Copyright © 2008–2014 The Netty Project. All rights reserved.