Package org.apache.lucene.store
Class RateLimiter
java.lang.Object
org.apache.lucene.store.RateLimiter
- Direct Known Subclasses:
MergeRateLimiter
,RateLimiter.SimpleRateLimiter
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 call
pause(long)
whenever the have read or written more than getMinPauseCheckBytes()
bytes.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Simple class to rate limit IO. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract double
The current MB per second rate limit.abstract long
How many bytes caller should add up itself before invokingpause(long)
.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.
-
Constructor Details
-
RateLimiter
public RateLimiter()
-
-
Method Details
-
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
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
- Throws:
IOException
-
getMinPauseCheckBytes
public abstract long getMinPauseCheckBytes()How many bytes caller should add up itself before invokingpause(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.
-