Interface RateLimiter

All Superinterfaces:
Startable
All Known Implementing Classes:
HybridRateLimiter

public interface RateLimiter
extends Startable
  • Method Summary

    Modifier and Type Method Description
    void applyRateSpec​(RateSpec spec)
    Modify the rate of a running rate limiter.
    RateSpec getRateSpec()
    Get the rate spec that this rate limiter was created from.
    long getStartTime()
    Return the system nanoseconds at the time when the last rate change was made active by a starting or restarting rate spec.
    long getTotalWaitTime()
    Return the total number of nanoseconds behind schedule that this rate limiter is, including the full history across all rates.
    long getWaitTime()
    Return the total number of nanoseconds behind schedule that this rate limiter is, but only since the last time the rate spec has changed.
    long maybeWaitForOp()
    Block until it is time for the next operation, according to the nanoseconds per op as set by applyRateSpec(RateSpec)

    Methods inherited from interface io.nosqlbench.engine.api.activityapi.core.Startable

    start
  • Method Details

    • maybeWaitForOp

      long maybeWaitForOp()
      Block until it is time for the next operation, according to the nanoseconds per op as set by applyRateSpec(RateSpec)
      Returns:
      the waittime as nanos behind schedule when this op returns. The returned value is required to be greater than or equal to zero. Note that accuracy of the returned value is limited by timing precision and calling overhead of the real time clock. It will not generally be better than microseconds. Also, some rate limiting algorithms are unable to efficiently track per-op waittime at speed due to bulk allocation mechanisms necessary to support higher rates.
    • getTotalWaitTime

      long getTotalWaitTime()
      Return the total number of nanoseconds behind schedule that this rate limiter is, including the full history across all rates. When the rate is changed, this value is check-pointed to an accumulator and also included in any subsequent measurement.
      Returns:
      nanoseconds behind schedule since the rate limiter was started
    • getWaitTime

      long getWaitTime()
      Return the total number of nanoseconds behind schedule that this rate limiter is, but only since the last time the rate spec has changed. When the rate is changed, this value is check-pointed to an accumulator and also included in any subsequent measurement.
      Returns:
      nanoseconds behind schedule since the rate limiter was started
    • applyRateSpec

      void applyRateSpec​(RateSpec spec)
      Modify the rate of a running rate limiter.
      Parameters:
      spec - The rate and burstRatio specification
    • getStartTime

      long getStartTime()
      Return the system nanoseconds at the time when the last rate change was made active by a starting or restarting rate spec.
      Returns:
      long nanoseconds
    • getRateSpec

      RateSpec getRateSpec()
      Get the rate spec that this rate limiter was created from.
      Returns:
      a RateSpec that describes this rate limiter