Class ExponentialLeakyBucket<T>

    • Constructor Detail

      • ExponentialLeakyBucket

        public ExponentialLeakyBucket()
        Creates a new ExponentialLeakyBucket 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.
      • ExponentialLeakyBucket

        public ExponentialLeakyBucket​(int size,
                                      double alpha)
        Creates a new ExponentialLeakyBucket.
        Parameters:
        size - the number of samples to keep in the sampling reservoir
        alpha - the exponential decay factor; the higher this is, the more biased the reservoir will be towards newer values
      • ExponentialLeakyBucket

        public ExponentialLeakyBucket​(int size,
                                      double alpha,
                                      com.codahale.metrics.Clock clock)
        Creates a new ExponentialLeakyBucket.
        Parameters:
        size - the number of samples to keep in the sampling reservoir
        alpha - the exponential decay factor; the higher this is, the more biased the reservoir will be towards newer values
        clock - the clock to use
    • Method Detail

      • size

        public int size()
      • add

        public void add​(T value)
      • add

        public void add​(T value,
                        long timestamp)
        Adds an old value with a fixed timestamp to the reservoir.
        Parameters:
        value - the value to be added
        timestamp - the epoch timestamp of value in seconds
      • values

        public List<T> values()