Class EventThrottler

  extended by voldemort.utils.EventThrottler
Direct Known Subclasses:

public class EventThrottler
extends java.lang.Object

A class to throttle Events to a certain rate This class takes a maximum rate in events/sec and a minimum interval in ms at which to check the rate. The rate is checked every time the interval ellapses, and if the events rate exceeds the maximum, the call will block long enough to equalize it. This is generalized IoThrottler as it existed before, you can use it to throttle on Bytes read/write,number of entries scanned etc.

Constructor Summary
EventThrottler(long ratesPerSecond)
EventThrottler(Time time, long ratePerSecond, long intervalMs)
Method Summary
 long getRate()
 void maybeThrottle(int eventsSeen)
          Sleeps if necessary to slow down the caller.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public EventThrottler(long ratesPerSecond)


public EventThrottler(Time time,
                      long ratePerSecond,
                      long intervalMs)
Method Detail


public long getRate()


public void maybeThrottle(int eventsSeen)
Sleeps if necessary to slow down the caller.

eventsSeen - Number of events seen since last invocation. Basis for determining whether its necessary to sleep.

Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu