java.lang.Object
org.apache.lucene.index.MergePolicy.OneMergeProgress
- Enclosing class:
MergePolicy
Progress and state for an executing merge. This class encapsulates the logic to pause and
resume the merge thread or to abort the merge entirely.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumReason for pausing the merge thread. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate ThreadThis field is for sanity-check purposes only.private final ReentrantLockprivate final EnumMap<MergePolicy.OneMergeProgress.PauseReason, AtomicLong> Pause times (in nanoseconds) for eachMergePolicy.OneMergeProgress.PauseReason.private final Condition -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Abort the merge this progress tracks at the next possible moment.Returns pause reasons and associated times in nanoseconds.booleanReturn the aborted state of this merge.voidpauseNanos(long pauseNanos, MergePolicy.OneMergeProgress.PauseReason reason, BooleanSupplier condition) Pauses the calling thread for at leastpauseNanosnanoseconds unless the merge is aborted or the external condition returnsfalse, in which case control returns immediately.(package private) final voidsetMergeThread(Thread owner) voidwakeup()Request a wakeup for any threads stalled inpauseNanos(long, org.apache.lucene.index.MergePolicy.OneMergeProgress.PauseReason, java.util.function.BooleanSupplier).
-
Field Details
-
pauseLock
-
pausing
-
pauseTimesNS
Pause times (in nanoseconds) for eachMergePolicy.OneMergeProgress.PauseReason. -
aborted
private volatile boolean aborted -
owner
This field is for sanity-check purposes only. Only the same thread that invokedMergePolicy.OneMerge.mergeInit()is permitted to be callingpauseNanos(long, org.apache.lucene.index.MergePolicy.OneMergeProgress.PauseReason, java.util.function.BooleanSupplier). This is always verified at runtime.
-
-
Constructor Details
-
OneMergeProgress
public OneMergeProgress()Creates a new merge progress info.
-
-
Method Details
-
abort
public void abort()Abort the merge this progress tracks at the next possible moment. -
isAborted
public boolean isAborted()Return the aborted state of this merge. -
pauseNanos
public void pauseNanos(long pauseNanos, MergePolicy.OneMergeProgress.PauseReason reason, BooleanSupplier condition) throws InterruptedException Pauses the calling thread for at leastpauseNanosnanoseconds unless the merge is aborted or the external condition returnsfalse, in which case control returns immediately.The external condition is required so that other threads can terminate the pausing immediately, before
pauseNanosexpires. We can't rely on justCondition.awaitNanos(long)alone because it can return due to spurious wakeups too.- Parameters:
condition- The pause condition that should return false if immediate return from this method is needed. Other threads can wake up any sleeping thread by callingwakeup(), but it'd fall to sleep for the remainder of the requested time if this condition- Throws:
InterruptedException
-
wakeup
public void wakeup()Request a wakeup for any threads stalled inpauseNanos(long, org.apache.lucene.index.MergePolicy.OneMergeProgress.PauseReason, java.util.function.BooleanSupplier). -
getPauseTimes
Returns pause reasons and associated times in nanoseconds. -
setMergeThread
-