public class TrafficCounter extends Object
AbstractTrafficShapingHandler
.
A TrafficCounter counts the read and written bytes such that the
AbstractTrafficShapingHandler
can limit the traffic, globally or per channel.
It computes the statistics for both read and written every checkInterval
, and calls
back to its parent AbstractTrafficShapingHandler.doAccounting(io.netty.handler.traffic.TrafficCounter)
method. If the checkInterval
is set to 0, no accounting will be done and statistics will only be computed at each receive or
write operation.
Constructor and Description |
---|
TrafficCounter(AbstractTrafficShapingHandler trafficShapingHandler,
ScheduledExecutorService executor,
String name,
long checkInterval)
Constructor with the
AbstractTrafficShapingHandler that hosts it, the Timer to use, its
name, the checkInterval between two computations in millisecond |
Modifier and Type | Method and Description |
---|---|
long |
checkInterval() |
void |
configure(long newcheckInterval)
Change checkInterval between two computations in millisecond
|
long |
cumulativeReadBytes() |
long |
cumulativeWrittenBytes() |
long |
currentReadBytes() |
long |
currentWrittenBytes() |
long |
lastCumulativeTime() |
long |
lastReadBytes() |
long |
lastReadThroughput() |
long |
lastTime() |
long |
lastWriteThroughput() |
long |
lastWrittenBytes() |
String |
name() |
void |
resetCumulativeTime()
Reset both read and written cumulative bytes counters and the associated time.
|
void |
start()
Start the monitoring process
|
void |
stop()
Stop the monitoring process
|
String |
toString()
String information
|
public TrafficCounter(AbstractTrafficShapingHandler trafficShapingHandler, ScheduledExecutorService executor, String name, long checkInterval)
AbstractTrafficShapingHandler
that hosts it, the Timer to use, its
name, the checkInterval between two computations in millisecondtrafficShapingHandler
- the associated AbstractTrafficShapingHandlerexecutor
- the underlying executor service for scheduling checksname
- the name given to this monitorcheckInterval
- the checkInterval in millisecond between two computationspublic void start()
public void stop()
public void configure(long newcheckInterval)
newcheckInterval
- The new check interval (in milliseconds)public long checkInterval()
public long lastReadThroughput()
public long lastWriteThroughput()
public long lastReadBytes()
public long lastWrittenBytes()
public long currentReadBytes()
public long currentWrittenBytes()
public long lastTime()
public long cumulativeWrittenBytes()
public long cumulativeReadBytes()
public long lastCumulativeTime()
public void resetCumulativeTime()
public String name()
Copyright © 2008–2014 The Netty Project. All rights reserved.