public class HitRateMetric extends AbstractMetric implements LongMetric
rateTimeInterval
milliseconds.
Algorithm is based on circular array of size
hit counters, each is responsible for last corresponding time
interval of rateTimeInterval
/size
milliseconds. Resulting number of hits is sum of all counters.
Implementation is nonblocking and protected from hits loss.
Maximum relative error is 1/size
.
2^55 - 1 hits per interval can be accumulated without numeric overflow.
Modifier and Type | Field and Description |
---|---|
static int |
DFLT_SIZE
Default counters array size.
|
Constructor and Description |
---|
HitRateMetric(String name,
@Nullable String desc,
long rateTimeInterval,
int size) |
Modifier and Type | Method and Description |
---|---|
void |
add(long x)
Adds x to the metric.
|
void |
increment()
Adds 1 to the metric.
|
long |
rateTimeInterval() |
void |
reset()
Resets metric state.
|
void |
reset(long rateTimeInterval)
Resets metric with the new parametes.
|
void |
reset(long rateTimeInterval,
int size)
Resets metric with the new parameters.
|
long |
value() |
description, equals, hashCode, name
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getAsString
description, name
public static final int DFLT_SIZE
public void reset(long rateTimeInterval)
rateTimeInterval
- New rate time interval.public void reset(long rateTimeInterval, int size)
rateTimeInterval
- New rate time interval.size
- New counters array size.public void add(long x)
x
- Value to be added.public void increment()
public long value()
value
in interface LongMetric
public long rateTimeInterval()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021