Package org.apache.lucene.store
Class RateLimiter.SimpleRateLimiter
java.lang.Object
org.apache.lucene.store.RateLimiter
org.apache.lucene.store.RateLimiter.SimpleRateLimiter
- Enclosing class:
- RateLimiter
Simple class to rate limit IO.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.store.RateLimiter
RateLimiter.SimpleRateLimiter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
The current mb per second rate limit.long
How many bytes caller should add up itself before invokingRateLimiter.pause(long)
.long
pause
(long bytes) Pauses, if necessary, to keep the instantaneous IO rate at or below the target.void
setMBPerSec
(double mbPerSec) Sets an updated mb per second rate limit.
-
Constructor Details
-
SimpleRateLimiter
public SimpleRateLimiter(double mbPerSec) mbPerSec is the MB/sec max IO rate
-
-
Method Details
-
setMBPerSec
public void setMBPerSec(double mbPerSec) Sets an updated mb per second rate limit.- Specified by:
setMBPerSec
in classRateLimiter
-
getMinPauseCheckBytes
public long getMinPauseCheckBytes()Description copied from class:RateLimiter
How many bytes caller should add up itself before invokingRateLimiter.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.- Specified by:
getMinPauseCheckBytes
in classRateLimiter
-
getMBPerSec
public double getMBPerSec()The current mb per second rate limit.- Specified by:
getMBPerSec
in classRateLimiter
-
pause
public long pause(long bytes) Pauses, if necessary, to keep the instantaneous IO rate at or below the target. Be sure to only call this method when bytes >getMinPauseCheckBytes()
, otherwise it will pause way too long!- Specified by:
pause
in classRateLimiter
- Returns:
- the pause time in nano seconds
-