public class TrafficCounter
extends java.lang.Object
It computes the statistics for both inbound and outbound traffic periodically at the given
checkInterval
, and calls the AbstractTrafficShapingHandler.doAccounting(TrafficCounter)
method back.
If the checkInterval
is 0
, no accounting will be done and statistics will only be computed at each
receive or write operation.
构造器和说明 |
---|
TrafficCounter(AbstractTrafficShapingHandler trafficShapingHandler,
java.util.concurrent.ScheduledExecutorService executor,
java.lang.String name,
long checkInterval)
Constructor with the
AbstractTrafficShapingHandler that hosts it, the Timer to use, its
name, the checkInterval between two computations in millisecond. |
TrafficCounter(java.util.concurrent.ScheduledExecutorService executor,
java.lang.String name,
long checkInterval)
Constructor with the
AbstractTrafficShapingHandler that hosts it, the ScheduledExecutorService
to use, its name, the checkInterval between two computations in milliseconds. |
限定符和类型 | 方法和说明 |
---|---|
long |
checkInterval() |
void |
configure(long newCheckInterval)
Change checkInterval between two computations in millisecond.
|
long |
cumulativeReadBytes() |
long |
cumulativeWrittenBytes() |
long |
currentReadBytes() |
long |
currentWrittenBytes() |
long |
getRealWriteThroughput() |
java.util.concurrent.atomic.AtomicLong |
getRealWrittenBytes() |
long |
lastCumulativeTime() |
long |
lastReadBytes() |
long |
lastReadThroughput() |
long |
lastTime() |
long |
lastWriteThroughput() |
long |
lastWrittenBytes() |
static long |
milliSecondFromNano() |
java.lang.String |
name() |
long |
readTimeToWait(long size,
long limitTraffic,
long maxTime)
已过时。
|
long |
readTimeToWait(long size,
long limitTraffic,
long maxTime,
long now)
Returns the time to wait (if any) for the given length message, using the given limitTraffic and the max wait
time.
|
void |
resetCumulativeTime()
Reset both read and written cumulative bytes counters and the associated absolute time
from System.currentTimeMillis().
|
void |
start()
Start the monitoring process.
|
void |
stop()
Stop the monitoring process.
|
java.lang.String |
toString() |
long |
writeTimeToWait(long size,
long limitTraffic,
long maxTime)
已过时。
|
long |
writeTimeToWait(long size,
long limitTraffic,
long maxTime,
long now)
Returns the time to wait (if any) for the given length message, using the given limitTraffic and
the max wait time.
|
public TrafficCounter(java.util.concurrent.ScheduledExecutorService executor, java.lang.String name, long checkInterval)
AbstractTrafficShapingHandler
that hosts it, the ScheduledExecutorService
to use, its name, the checkInterval between two computations in milliseconds.executor
- the underlying executor service for scheduling checks, might be null when used
from GlobalChannelTrafficCounter
.name
- the name given to this monitor.checkInterval
- the checkInterval in millisecond between two computations.public TrafficCounter(AbstractTrafficShapingHandler trafficShapingHandler, java.util.concurrent.ScheduledExecutorService executor, java.lang.String name, long checkInterval)
AbstractTrafficShapingHandler
that hosts it, the Timer to use, its
name, the checkInterval between two computations in millisecond.trafficShapingHandler
- the associated AbstractTrafficShapingHandler.executor
- the underlying executor service for scheduling checks, might be null when used
from GlobalChannelTrafficCounter
.name
- the name given to this monitor.checkInterval
- the checkInterval in millisecond between two computations.public static long milliSecondFromNano()
public 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 java.util.concurrent.atomic.AtomicLong getRealWrittenBytes()
public long getRealWriteThroughput()
public void resetCumulativeTime()
public java.lang.String name()
@Deprecated public long readTimeToWait(long size, long limitTraffic, long maxTime)
size
- the recv sizelimitTraffic
- the traffic limit in bytes per second.maxTime
- the max time in ms to wait in case of excess of traffic.public long readTimeToWait(long size, long limitTraffic, long maxTime, long now)
size
- the recv sizelimitTraffic
- the traffic limit in bytes per secondmaxTime
- the max time in ms to wait in case of excess of traffic.now
- the current time@Deprecated public long writeTimeToWait(long size, long limitTraffic, long maxTime)
size
- the write sizelimitTraffic
- the traffic limit in bytes per second.maxTime
- the max time in ms to wait in case of excess of traffic.public long writeTimeToWait(long size, long limitTraffic, long maxTime, long now)
size
- the write sizelimitTraffic
- the traffic limit in bytes per second.maxTime
- the max time in ms to wait in case of excess of traffic.now
- the current timepublic java.lang.String toString()
toString
在类中 java.lang.Object