Class RateLimiter

    • Constructor Detail

      • RateLimiter

        public RateLimiter()
    • Method Detail

      • setMBPerSec

        public abstract void setMBPerSec​(double mbPerSec)
        Sets an updated MB per second rate limit. A subclass is allowed to perform dynamic updates of the rate limit during use.
      • getMBPerSec

        public abstract double getMBPerSec()
        The current MB per second rate limit.
      • pause

        public abstract long pause​(long bytes)
                            throws IOException
        Pauses, if necessary, to keep the instantaneous IO rate at or below the target.

        Note: the implementation is thread-safe

        the pause time in nano seconds
      • getMinPauseCheckBytes

        public abstract long getMinPauseCheckBytes()
        How many bytes caller should add up itself before invoking pause(long). NOTE: The value returned by this method may change over time and is not guaranteed to be constant throughout the lifetime of the RateLimiter. Users are advised to refresh their local values with calls to this method to ensure consistency.