Class TokenBucketSampler
- java.lang.Object
-
- com.apple.foundationdb.relational.util.TokenBucketSampler
-
- All Implemented Interfaces:
Sampler
@API(EXPERIMENTAL) public class TokenBucketSampler extends java.lang.Object implements Sampler
A sampling engine which will pass a sample test according to a TokenBucket algorithm.A Token-bucket algorithm allows a constant average throughput, but allows some burstiness by building up tokens over periods of idleness. For more information, see Wikipedia. You can control the burstiness by configuring the maximum number of tokens to allow in the sampler, and the average rate by adjusting the refresh interval. Note, however, that the refresh interval is typically sensitive to the clock used in computing the interval--the refresh interval typically cannot be smaller than the resolution of the system clock used.
-
-
Constructor Summary
Constructors Constructor Description TokenBucketSampler(int maxTokens, long refreshIntervalNanos, Clock clock)
TokenBucketSampler(int maxTokens, long refreshInterval, java.util.concurrent.TimeUnit refreshTime, Clock clock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canSample()
Determine if a sample should be taken.
-