public class TrafficCounter
extends java.lang.Object
TrafficCounter is associated with AbstractTrafficShapingHandler
.
AbstractTrafficShapingHandler
doAccounting method at every
specified interval. If this interval is set to 0, therefore no accounting will be done and only
statistics will be computed at each receive or write operations.构造器和说明 |
---|
TrafficCounter(AbstractTrafficShapingHandler trafficShapingHandler,
Timer timer,
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. |
限定符和类型 | 方法和说明 |
---|---|
void |
configure(long newcheckInterval)
Change checkInterval between
two computations in millisecond.
|
long |
getCheckInterval() |
long |
getCumulativeReadBytes() |
long |
getCumulativeWrittenBytes() |
long |
getCurrentReadBytes() |
long |
getCurrentWrittenBytes() |
long |
getLastCumulativeTime() |
long |
getLastReadBytes() |
long |
getLastReadThroughput() |
long |
getLastTime() |
long |
getLastWriteThroughput() |
long |
getLastWrittenBytes() |
java.lang.String |
getName() |
long |
getRealWriteThroughput() |
java.util.concurrent.atomic.AtomicLong |
getRealWrittenBytes() |
static long |
milliSecondFromNano() |
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()
String information
|
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(AbstractTrafficShapingHandler trafficShapingHandler, Timer timer, 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 AbstractTrafficShapingHandlertimer
- Could be a HashedWheelTimer, might be null when used
from GlobalChannelTrafficCounter
.name
- the name given to this monitorcheckInterval
- the checkInterval in millisecond between two computations.public static long milliSecondFromNano()
public void start()
public void stop()
public void configure(long newcheckInterval)
public long getCheckInterval()
public long getLastReadThroughput()
public long getLastWriteThroughput()
public long getLastReadBytes()
public long getLastWrittenBytes()
public long getCurrentReadBytes()
public long getCurrentWrittenBytes()
public long getLastTime()
public long getCumulativeWrittenBytes()
public long getCumulativeReadBytes()
public long getLastCumulativeTime()
public java.util.concurrent.atomic.AtomicLong getRealWrittenBytes()
public long getRealWriteThroughput()
public void resetCumulativeTime()
@Deprecated public long readTimeToWait(long size, long limitTraffic, long maxTime)
size
- the recv sizelimitTraffic
- the traffic limit in bytes per secondmaxTime
- 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 secondmaxTime
- 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 secondmaxTime
- the max time in ms to wait in case of excess of traffic.now
- the current timepublic java.lang.String getName()
public java.lang.String toString()
toString
在类中 java.lang.Object