Class LockFreeExponentiallyDecayingReservoir
- java.lang.Object
-
- com.palantir.tritium.metrics.registry.LockFreeExponentiallyDecayingReservoir
-
- All Implemented Interfaces:
com.codahale.metrics.Reservoir
@Beta public final class LockFreeExponentiallyDecayingReservoir extends java.lang.Object implements com.codahale.metrics.ReservoirLockFreeExponentiallyDecayingReservoiris based closely on the codahale ExponentiallyDecayingReservoir.java, however it provides looser guarantees while completely avoiding locks. This implementation is being contributed upstream: metrics#1656 Looser guarantees:- Updates which occur concurrently with rescaling may be discarded if the orphaned state node is updated after
rescale has replaced it. This condition has a greater probability as the rescale interval is reduced due to the
increased frequency of rescaling.
rescaleThresholdNanosvalues below 30 seconds are not recommended. - Given a small rescale threshold, updates may attempt to rescale into a new bucket, but lose the CAS race and update into a newer bucket than expected. In these cases the measurement weight is reduced accordingly.
- In the worst case, all concurrent threads updating the reservoir may attempt to rescale rather than a single thread holding an exclusive write lock. It's expected that the configuration is set such that rescaling is substantially less common than updating at peak load. Even so, when size is reasonably small it can be more efficient to rescale than to park and context switch.
ExponentiallyDecayingReservoirCopyright 2010-2012 Coda Hale and Yammer, Inc. Licensed under the Apache License, Version 2.0. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLockFreeExponentiallyDecayingReservoir.BuilderBy default this uses a size of 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution, and an alpha factor of 0.015, which heavily biases the reservoir to the past 5 minutes of measurements.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LockFreeExponentiallyDecayingReservoir.Builderbuilder()com.codahale.metrics.SnapshotgetSnapshot()intsize()voidupdate(long value)
-
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfacecom.codahale.metrics.Reservoir
-
update
public void update(long value)
- Specified by:
updatein interfacecom.codahale.metrics.Reservoir
-
getSnapshot
public com.codahale.metrics.Snapshot getSnapshot()
- Specified by:
getSnapshotin interfacecom.codahale.metrics.Reservoir
-
builder
public static LockFreeExponentiallyDecayingReservoir.Builder builder()
-
-