Package org.apache.lucene.index
Class MergePolicy.OneMergeProgress
- java.lang.Object
-
- org.apache.lucene.index.MergePolicy.OneMergeProgress
-
- Enclosing class:
- MergePolicy
public static class MergePolicy.OneMergeProgress extends java.lang.Object
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 Classes Modifier and Type Class Description static class
MergePolicy.OneMergeProgress.PauseReason
Reason for pausing the merge thread.
-
Field Summary
Fields Modifier and Type Field Description private boolean
aborted
private java.lang.Thread
owner
This field is for sanity-check purposes only.private java.util.concurrent.locks.ReentrantLock
pauseLock
private java.util.EnumMap<MergePolicy.OneMergeProgress.PauseReason,java.util.concurrent.atomic.AtomicLong>
pauseTimesNS
Pause times (in nanoseconds) for eachMergePolicy.OneMergeProgress.PauseReason
.private java.util.concurrent.locks.Condition
pausing
-
Constructor Summary
Constructors Constructor Description OneMergeProgress()
Creates a new merge progress info.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Abort the merge this progress tracks at the next possible moment.java.util.Map<MergePolicy.OneMergeProgress.PauseReason,java.lang.Long>
getPauseTimes()
Returns pause reasons and associated times in nanoseconds.boolean
isAborted()
Return the aborted state of this merge.void
pauseNanos(long pauseNanos, MergePolicy.OneMergeProgress.PauseReason reason, java.util.function.BooleanSupplier condition)
Pauses the calling thread for at leastpauseNanos
nanoseconds unless the merge is aborted or the external condition returnsfalse
, in which case control returns immediately.(package private) void
setMergeThread(java.lang.Thread owner)
void
wakeup()
Request a wakeup for any threads stalled inpauseNanos(long, org.apache.lucene.index.MergePolicy.OneMergeProgress.PauseReason, java.util.function.BooleanSupplier)
.
-
-
-
Field Detail
-
pauseLock
private final java.util.concurrent.locks.ReentrantLock pauseLock
-
pausing
private final java.util.concurrent.locks.Condition pausing
-
pauseTimesNS
private final java.util.EnumMap<MergePolicy.OneMergeProgress.PauseReason,java.util.concurrent.atomic.AtomicLong> pauseTimesNS
Pause times (in nanoseconds) for eachMergePolicy.OneMergeProgress.PauseReason
.
-
aborted
private volatile boolean aborted
-
owner
private java.lang.Thread 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.
-
-
Method Detail
-
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, java.util.function.BooleanSupplier condition) throws java.lang.InterruptedException
Pauses the calling thread for at leastpauseNanos
nanoseconds 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
pauseNanos
expires. 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:
java.lang.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
public java.util.Map<MergePolicy.OneMergeProgress.PauseReason,java.lang.Long> getPauseTimes()
Returns pause reasons and associated times in nanoseconds.
-
setMergeThread
final void setMergeThread(java.lang.Thread owner)
-
-