java.lang.Object
org.apache.lucene.index.DocumentsWriterFlushControl
- All Implemented Interfaces:
Closeable,AutoCloseable,Accountable
This class controls
DocumentsWriterPerThread flushing during indexing. It tracks the
memory consumption per DocumentsWriterPerThread and uses a configured FlushPolicy
to decide if a DocumentsWriterPerThread must flush.
In addition to the FlushPolicy the flush control might set certain DocumentsWriterPerThread as flush pending iff a DocumentsWriterPerThread exceeds the
IndexWriterConfig.getRAMPerThreadHardLimitMB() to prevent address space exhaustion.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate final Queue<DocumentsWriterPerThread> private booleanprivate final LiveIndexWriterConfigprivate final DocumentsWriterprivate booleanprivate longprivate final AtomicBooleanprivate final List<DocumentsWriterPerThread> private final FlushPolicyprivate final Queue<DocumentsWriterPerThread> private booleanprivate booleanprivate final longprivate final InfoStreamprivate doubleprivate intprivate intprivate longprivate longprivate longprivate longprivate final DocumentsWriterPerThreadPool(package private) final DocumentsWriterStallControlprivate longFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
ConstructorsConstructorDescriptionDocumentsWriterFlushControl(DocumentsWriter documentsWriter, LiveIndexWriterConfig config) -
Method Summary
Modifier and TypeMethodDescription(package private) void(package private) voidlongprivate voidaddFlushingDWPT(DocumentsWriterPerThread perThread) Returns an iterator that provides access to all currently activeDocumentsWriterPerThreads(package private) booleanReturnstrueiff stalledprivate boolean(package private) booleanassertBlockedFlushes(DocumentsWriterDeleteQueue flushingQueue) private booleanprivate booleanassertNumDocsSinceStalled(boolean stalled) private DocumentsWriterPerThreadcheckout(DocumentsWriterPerThread perThread, boolean markPending) private voidcheckoutAndBlock(DocumentsWriterPerThread perThread) To be called only by the owner of this object's monitor lockprivate DocumentsWriterPerThreadcheckOutForFlush(DocumentsWriterPerThread perThread) (package private) final DocumentsWriterPerThreadReturns the largest non-pending flushable DWPT ornullif there is none.voidclose()(package private) DocumentsWriterPerThreaddoAfterDocument(DocumentsWriterPerThread perThread) (package private) void(package private) voiddoOnAbort(DocumentsWriterPerThread perThread) (package private) void(package private) DocumentsWriterPerThread(package private) voidbooleanbooleanCheck whether deletes need to be applied.longReturns heap bytes currently consumed by buffered deletes/updates that would be freed if we pushed all deletes.(package private) longReturns theIndexWriterInfoStream(package private) long(package private) long(package private) booleanReturnstrueif a full flush is currently running(package private) long(package private) longnetBytes()(package private) DocumentsWriterPerThread(package private) intReturns the number of flushes that are checked out but not yet available for flushing.(package private) int(package private) intReturns the number of flushes that are already checked out but not yet actively flushing(package private) DocumentsWriterPerThreadprivate voidpruneBlockedQueue(DocumentsWriterDeleteQueue flushingQueue) Prunes the blockedQueue by removing all DWPTs that are associated with the given flush queue.private longReturn the smallest number of bytes that we would like to make sure to not miss from the global RAM accounting.longReturn the memory usage of this object in bytes.voidvoidsetFlushPending(DocumentsWriterPerThread perThread) Sets flush pending state on the givenDocumentsWriterPerThread.private longtoString()private booleanupdatePeaks(long delta) private booleanvoid(package private) voidThis method will block if too many DWPT are currently flushing and no checked out DWPT are availableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Field Details
-
hardMaxBytesPerDWPT
private final long hardMaxBytesPerDWPT -
activeBytes
private long activeBytes -
flushBytes
private volatile long flushBytes -
numPending
private volatile int numPending -
numDocsSinceStalled
private int numDocsSinceStalled -
flushDeletes
-
fullFlush
private boolean fullFlush -
fullFlushMarkDone
private boolean fullFlushMarkDone -
flushQueue
-
blockedFlushes
-
flushingWriters
-
maxConfiguredRamBuffer
private double maxConfiguredRamBuffer -
peakActiveBytes
private long peakActiveBytes -
peakFlushBytes
private long peakFlushBytes -
peakNetBytes
private long peakNetBytes -
peakDelta
private long peakDelta -
flushByRAMWasDisabled
private boolean flushByRAMWasDisabled -
stallControl
-
perThreadPool
-
flushPolicy
-
closed
private boolean closed -
documentsWriter
-
config
-
infoStream
-
stallStartNS
private long stallStartNS
-
-
Constructor Details
-
DocumentsWriterFlushControl
DocumentsWriterFlushControl(DocumentsWriter documentsWriter, LiveIndexWriterConfig config)
-
-
Method Details
-
activeBytes
public long activeBytes() -
getFlushingBytes
long getFlushingBytes() -
netBytes
long netBytes() -
stallLimitBytes
private long stallLimitBytes() -
assertMemory
private boolean assertMemory() -
updatePeaks
private boolean updatePeaks(long delta) -
ramBufferGranularity
private long ramBufferGranularity()Return the smallest number of bytes that we would like to make sure to not miss from the global RAM accounting. -
doAfterDocument
-
checkout
-
assertNumDocsSinceStalled
private boolean assertNumDocsSinceStalled(boolean stalled) -
doAfterFlush
-
updateStallState
private boolean updateStallState() -
waitForFlush
public void waitForFlush() -
setFlushPending
Sets flush pending state on the givenDocumentsWriterPerThread. TheDocumentsWriterPerThreadmust have indexed at least on Document and must not be already pending. -
doOnAbort
-
checkoutAndBlock
To be called only by the owner of this object's monitor lock -
checkOutForFlush
-
addFlushingDWPT
-
toString
-
nextPendingFlush
DocumentsWriterPerThread nextPendingFlush() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
allActiveWriters
Returns an iterator that provides access to all currently activeDocumentsWriterPerThreads -
doOnDelete
void doOnDelete() -
getDeleteBytesUsed
public long getDeleteBytesUsed()Returns heap bytes currently consumed by buffered deletes/updates that would be freed if we pushed all deletes. This does not include bytes consumed by already pushed delete/update packets. -
ramBytesUsed
public long ramBytesUsed()Description copied from interface:AccountableReturn the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsedin interfaceAccountable
-
numFlushingDWPT
int numFlushingDWPT() -
getAndResetApplyAllDeletes
public boolean getAndResetApplyAllDeletes() -
getApplyAllDeletes
public boolean getApplyAllDeletes()Check whether deletes need to be applied. This can be used as a pre-flight check before callinggetAndResetApplyAllDeletes()to make sure that a single thread applies deletes. -
setApplyAllDeletes
public void setApplyAllDeletes() -
obtainAndLock
DocumentsWriterPerThread obtainAndLock() -
markForFullFlush
long markForFullFlush() -
assertActiveDeleteQueue
-
pruneBlockedQueue
Prunes the blockedQueue by removing all DWPTs that are associated with the given flush queue. -
finishFullFlush
void finishFullFlush() -
assertBlockedFlushes
-
abortFullFlushes
void abortFullFlushes() -
abortPendingFlushes
void abortPendingFlushes() -
isFullFlush
boolean isFullFlush()Returnstrueif a full flush is currently running -
numQueuedFlushes
int numQueuedFlushes()Returns the number of flushes that are already checked out but not yet actively flushing -
numBlockedFlushes
int numBlockedFlushes()Returns the number of flushes that are checked out but not yet available for flushing. This only applies during a full flush if a DWPT needs flushing but must not be flushed until the full flush has finished. -
waitIfStalled
void waitIfStalled()This method will block if too many DWPT are currently flushing and no checked out DWPT are available -
anyStalledThreads
boolean anyStalledThreads()Returnstrueiff stalled -
getInfoStream
Returns theIndexWriterInfoStream -
findLargestNonPendingWriter
DocumentsWriterPerThread findLargestNonPendingWriter() -
checkoutLargestNonPendingWriter
Returns the largest non-pending flushable DWPT ornullif there is none. -
getPeakActiveBytes
long getPeakActiveBytes() -
getPeakNetBytes
long getPeakNetBytes()
-