Package org.apache.lucene.index
Class MergeRateLimiter
- java.lang.Object
-
- org.apache.lucene.store.RateLimiter
-
- org.apache.lucene.index.MergeRateLimiter
-
public class MergeRateLimiter extends RateLimiter
This is theRateLimiterthatIndexWriterassigns to each running merge, to giveMergeSchedulers ionice like control.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.store.RateLimiter
RateLimiter.SimpleRateLimiter
-
-
Field Summary
Fields Modifier and Type Field Description private longlastNSprivate static longMAX_PAUSE_NSprivate doublembPerSecprivate MergePolicy.OneMergeProgressmergeProgressprivate static intMIN_PAUSE_CHECK_MSECprivate static longMIN_PAUSE_NSprivate longminPauseCheckBytesprivate java.util.concurrent.atomic.AtomicLongtotalBytesWritten
-
Constructor Summary
Constructors Constructor Description MergeRateLimiter(MergePolicy.OneMergeProgress mergeProgress)Sole constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetMBPerSec()The current MB per second rate limit.longgetMinPauseCheckBytes()How many bytes caller should add up itself before invokingRateLimiter.pause(long).longgetTotalBytesWritten()Returns total bytes written by this merge.longgetTotalPausedNS()Total NS merge was paused to rate limit IO.longgetTotalStoppedNS()Total NS merge was stopped.private longmaybePause(long bytes, long curNS)Returns the number of nanoseconds spent in a paused state or-1if no pause was applied.longpause(long bytes)Pauses, if necessary, to keep the instantaneous IO rate at or below the target.voidsetMBPerSec(double mbPerSec)Sets an updated MB per second rate limit.
-
-
-
Field Detail
-
MIN_PAUSE_CHECK_MSEC
private static final int MIN_PAUSE_CHECK_MSEC
- See Also:
- Constant Field Values
-
MIN_PAUSE_NS
private static final long MIN_PAUSE_NS
-
MAX_PAUSE_NS
private static final long MAX_PAUSE_NS
-
mbPerSec
private volatile double mbPerSec
-
minPauseCheckBytes
private volatile long minPauseCheckBytes
-
lastNS
private long lastNS
-
totalBytesWritten
private java.util.concurrent.atomic.AtomicLong totalBytesWritten
-
mergeProgress
private final MergePolicy.OneMergeProgress mergeProgress
-
-
Constructor Detail
-
MergeRateLimiter
public MergeRateLimiter(MergePolicy.OneMergeProgress mergeProgress)
Sole constructor.
-
-
Method Detail
-
setMBPerSec
public void setMBPerSec(double mbPerSec)
Description copied from class:RateLimiterSets an updated MB per second rate limit. A subclass is allowed to perform dynamic updates of the rate limit during use.- Specified by:
setMBPerSecin classRateLimiter
-
getMBPerSec
public double getMBPerSec()
Description copied from class:RateLimiterThe current MB per second rate limit.- Specified by:
getMBPerSecin classRateLimiter
-
getTotalBytesWritten
public long getTotalBytesWritten()
Returns total bytes written by this merge.
-
pause
public long pause(long bytes) throws MergePolicy.MergeAbortedExceptionDescription copied from class:RateLimiterPauses, if necessary, to keep the instantaneous IO rate at or below the target.Note: the implementation is thread-safe
- Specified by:
pausein classRateLimiter- Returns:
- the pause time in nano seconds
- Throws:
MergePolicy.MergeAbortedException
-
getTotalStoppedNS
public long getTotalStoppedNS()
Total NS merge was stopped.
-
getTotalPausedNS
public long getTotalPausedNS()
Total NS merge was paused to rate limit IO.
-
maybePause
private long maybePause(long bytes, long curNS) throws MergePolicy.MergeAbortedExceptionReturns the number of nanoseconds spent in a paused state or-1if no pause was applied. If the thread needs pausing, this method delegates to the linkedMergePolicy.OneMergeProgress.
-
getMinPauseCheckBytes
public long getMinPauseCheckBytes()
Description copied from class:RateLimiterHow 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:
getMinPauseCheckBytesin classRateLimiter
-
-