Top Description Fields Constructors Methods
org.eclipse.jetty.util.statistic

public Class RateStatistic

extends Object
Class Inheritance
Imports
java.util.ArrayDeque, .Deque, java.util.concurrent.TimeUnit, java.util.stream.Collectors, org.eclipse.jetty.util.NanoTime, org.eclipse.jetty.util.thread.AutoLock

Statistics on a time sequence rate.

Calculates the rate at which the record() method is called over the configured period, retaining also the total count and maximum rate achieved.

The implementation keeps a Deque of timestamps for all records for the last time period, so this method is not suitable for large rates unless a small time period is used.

Field Summary

Modifier and TypeField and Description
private long
private final AutoLock
private long
private final long
private final Deque<Long>
private final TimeUnit

Constructor Summary

AccessConstructor and Description
public
RateStatistic(long period, TimeUnit units)

Method Summary

Modifier and TypeMethod and Description
protected void
age(long period, TimeUnit units)

public String
dump()

public String
dump(TimeUnit units)

public long

Returns:

the number of samples recorded
getCount
()

Get the number of samples recorded.

public long

Returns:

the max number of samples per period.
getMax
()

Get the max number of samples per period..

public long

Returns:

the age of the oldest sample in the requested units
getOldest
(TimeUnit
the units of the return
units
)

public long
public int

Returns:

the number of records in the current period
getRate
()

Get the number of records in the current period.

public TimeUnit
public int

Returns:

the number of records in the current period.
record
()

Records a sample value.

public void
reset()

Resets the statistics.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private String
toString(long nanoTime)

private void
private void
update(long now)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_countback to summary
private long _count
_lockback to summary
private final AutoLock _lock
_maxback to summary
private long _max
_nanoPeriodback to summary
private final long _nanoPeriod
_samplesback to summary
private final Deque<Long> _samples
_unitsback to summary
private final TimeUnit _units

Constructor Detail

RateStatisticback to summary
public RateStatistic(long period, TimeUnit units)

Method Detail

ageback to summary
protected void age(long period, TimeUnit units)
dumpback to summary
public String dump()
dumpback to summary
public String dump(TimeUnit units)
getCountback to summary
public long getCount()

Get the number of samples recorded.

Returns:long

the number of samples recorded

getMaxback to summary
public long getMax()

Get the max number of samples per period..

Returns:long

the max number of samples per period.

getOldestback to summary
public long getOldest(TimeUnit units)
Parameters
units:TimeUnit

the units of the return

Returns:long

the age of the oldest sample in the requested units

getPeriodback to summary
public long getPeriod()
getRateback to summary
public int getRate()

Get the number of records in the current period.

Returns:int

the number of records in the current period

getUnitsback to summary
public TimeUnit getUnits()
recordback to summary
public int record()

Records a sample value.

Returns:int

the number of records in the current period.

resetback to summary
public void reset()

Resets the statistics.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
toStringback to summary
private String toString(long nanoTime)
updateback to summary
private void update()
updateback to summary
private void update(long now)