org.elasticsearch.common
Class RateLimiter
java.lang.Object
org.elasticsearch.common.RateLimiter
public class RateLimiter
- extends Object
Constructor Summary |
RateLimiter(double mbPerSec)
mbPerSec is the MB/sec max IO rate |
Method Summary |
long |
pause(long bytes)
Pauses, if necessary, to keep the instantaneous IO
rate at or below the target. |
void |
setMaxRate(double mbPerSec)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RateLimiter
public RateLimiter(double mbPerSec)
- mbPerSec is the MB/sec max IO rate
setMaxRate
public void setMaxRate(double mbPerSec)
pause
public long pause(long bytes)
- Pauses, if necessary, to keep the instantaneous IO
rate at or below the target. NOTE: multiple threads
may safely use this, however the implementation is
not perfectly thread safe but likely in practice this
is harmless (just means in some rare cases the rate
might exceed the target). It's best to call this
with a biggish count, not one byte at a time.
Copyright © 2009-2012. All Rights Reserved.