Package org.apache.lucene.store
Class RateLimiter
- java.lang.Object
-
- org.apache.lucene.store.RateLimiter
-
- Direct Known Subclasses:
RateLimiter.SimpleRateLimiter
public abstract class RateLimiter extends java.lang.Object
Abstract base class to rate limit IO. Typically implementations are shared across multiple IndexInputs or IndexOutputs (for example those involved all merging). Those IndexInputs and IndexOutputs would callpause(long)
whenever they want to read bytes or write bytes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RateLimiter.SimpleRateLimiter
Simple class to rate limit IO.
-
Constructor Summary
Constructors Constructor Description RateLimiter()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract double
getMbPerSec()
The current mb per second rate limit.abstract long
pause(long bytes)
Pauses, if necessary, to keep the instantaneous IO rate at or below the target.abstract void
setMbPerSec(double mbPerSec)
Sets an updated mb per second rate limit.
-
-
-
Method Detail
-
setMbPerSec
public abstract void setMbPerSec(double mbPerSec)
Sets an updated mb per second rate limit.
-
getMbPerSec
public abstract double getMbPerSec()
The current mb per second rate limit.
-
pause
public abstract long pause(long bytes)
Pauses, if necessary, to keep the instantaneous IO rate at or below the target.Note: the implementation is thread-safe
- Returns:
- the pause time in nano seconds
-
-