Package org.apache.lucene.index
Class DocumentsWriterFlushControl
- java.lang.Object
-
- org.apache.lucene.index.DocumentsWriterFlushControl
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Accountable
final class DocumentsWriterFlushControl extends java.lang.Object implements Accountable, java.io.Closeable
This class controlsDocumentsWriterPerThreadflushing during indexing. It tracks the memory consumption perDocumentsWriterPerThreadand uses a configuredFlushPolicyto decide if aDocumentsWriterPerThreadmust flush.In addition to the
FlushPolicythe flush control might set certainDocumentsWriterPerThreadas flush pending iff aDocumentsWriterPerThreadexceeds theIndexWriterConfig.getRAMPerThreadHardLimitMB()to prevent address space exhaustion.
-
-
Field Summary
Fields Modifier and Type Field Description private longactiveBytesprivate java.util.Queue<DocumentsWriterPerThread>blockedFlushesprivate booleanclosedprivate LiveIndexWriterConfigconfigprivate DocumentsWriterdocumentsWriterprivate booleanflushByRAMWasDisabledprivate longflushBytesprivate java.util.concurrent.atomic.AtomicBooleanflushDeletesprivate java.util.List<DocumentsWriterPerThread>flushingWritersprivate FlushPolicyflushPolicyprivate java.util.Queue<DocumentsWriterPerThread>flushQueueprivate booleanfullFlushprivate booleanfullFlushMarkDoneprivate longhardMaxBytesPerDWPTprivate InfoStreaminfoStreamprivate doublemaxConfiguredRamBufferprivate intnumDocsSinceStalledprivate intnumPendingprivate longpeakActiveBytesprivate longpeakDeltaprivate longpeakFlushBytesprivate longpeakNetBytesprivate DocumentsWriterPerThreadPoolperThreadPool(package private) DocumentsWriterStallControlstallControlprivate longstallStartNS-
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
-
Constructor Summary
Constructors Constructor Description DocumentsWriterFlushControl(DocumentsWriter documentsWriter, LiveIndexWriterConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidabortFullFlushes()(package private) voidabortPendingFlushes()longactiveBytes()private voidaddFlushingDWPT(DocumentsWriterPerThread perThread)java.util.Iterator<DocumentsWriterPerThread>allActiveWriters()Returns an iterator that provides access to all currently activeDocumentsWriterPerThreads(package private) booleananyStalledThreads()Returnstrueiff stalledprivate booleanassertActiveDeleteQueue(DocumentsWriterDeleteQueue queue)(package private) booleanassertBlockedFlushes(DocumentsWriterDeleteQueue flushingQueue)private booleanassertMemory()private booleanassertNumDocsSinceStalled(boolean stalled)private DocumentsWriterPerThreadcheckout(DocumentsWriterPerThread perThread, boolean markPending)private voidcheckoutAndBlock(DocumentsWriterPerThread perThread)private DocumentsWriterPerThreadcheckOutForFlush(DocumentsWriterPerThread perThread)(package private) DocumentsWriterPerThreadcheckoutLargestNonPendingWriter()Returns the largest non-pending flushable DWPT ornullif there is none.voidclose()private voidcommitPerThreadBytes(DocumentsWriterPerThread perThread)(package private) DocumentsWriterPerThreaddoAfterDocument(DocumentsWriterPerThread perThread, boolean isUpdate)(package private) voiddoAfterFlush(DocumentsWriterPerThread dwpt)(package private) voiddoOnAbort(DocumentsWriterPerThread perThread)(package private) voiddoOnDelete()(package private) DocumentsWriterPerThreadfindLargestNonPendingWriter()(package private) voidfinishFullFlush()booleangetAndResetApplyAllDeletes()longgetDeleteBytesUsed()Returns heap bytes currently consumed by buffered deletes/updates that would be freed if we pushed all deletes.(package private) longgetFlushingBytes()InfoStreamgetInfoStream()Returns theIndexWriterInfoStream(package private) longgetPeakActiveBytes()(package private) longgetPeakNetBytes()(package private) booleanisFullFlush()Returnstrueif a full flush is currently running(package private) longmarkForFullFlush()(package private) longnetBytes()(package private) DocumentsWriterPerThreadnextPendingFlush()(package private) intnumBlockedFlushes()Returns the number of flushes that are checked out but not yet available for flushing.(package private) intnumFlushingDWPT()(package private) intnumQueuedFlushes()Returns the number of flushes that are already checked out but not yet actively flushing(package private) DocumentsWriterPerThreadobtainAndLock()private voidpruneBlockedQueue(DocumentsWriterDeleteQueue flushingQueue)Prunes the blockedQueue by removing all DWPTs that are associated with the given flush queue.longramBytesUsed()Return the memory usage of this object in bytes.voidsetApplyAllDeletes()voidsetFlushPending(DocumentsWriterPerThread perThread)Sets flush pending state on the givenDocumentsWriterPerThread.private longstallLimitBytes()java.lang.StringtoString()private booleanupdatePeaks(long delta)private booleanupdateStallState()voidwaitForFlush()(package private) voidwaitIfStalled()This method will block if too many DWPT are currently flushing and no checked out DWPT are available-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
-
-
-
Field Detail
-
hardMaxBytesPerDWPT
private final long hardMaxBytesPerDWPT
-
activeBytes
private long activeBytes
-
flushBytes
private volatile long flushBytes
-
numPending
private volatile int numPending
-
numDocsSinceStalled
private int numDocsSinceStalled
-
flushDeletes
private final java.util.concurrent.atomic.AtomicBoolean flushDeletes
-
fullFlush
private boolean fullFlush
-
fullFlushMarkDone
private boolean fullFlushMarkDone
-
flushQueue
private final java.util.Queue<DocumentsWriterPerThread> flushQueue
-
blockedFlushes
private final java.util.Queue<DocumentsWriterPerThread> blockedFlushes
-
flushingWriters
private final java.util.List<DocumentsWriterPerThread> 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
final DocumentsWriterStallControl stallControl
-
perThreadPool
private final DocumentsWriterPerThreadPool perThreadPool
-
flushPolicy
private final FlushPolicy flushPolicy
-
closed
private boolean closed
-
documentsWriter
private final DocumentsWriter documentsWriter
-
config
private final LiveIndexWriterConfig config
-
infoStream
private final InfoStream infoStream
-
stallStartNS
private long stallStartNS
-
-
Constructor Detail
-
DocumentsWriterFlushControl
DocumentsWriterFlushControl(DocumentsWriter documentsWriter, LiveIndexWriterConfig config)
-
-
Method Detail
-
activeBytes
public long activeBytes()
-
getFlushingBytes
long getFlushingBytes()
-
netBytes
long netBytes()
-
stallLimitBytes
private long stallLimitBytes()
-
assertMemory
private boolean assertMemory()
-
commitPerThreadBytes
private void commitPerThreadBytes(DocumentsWriterPerThread perThread)
-
updatePeaks
private boolean updatePeaks(long delta)
-
doAfterDocument
DocumentsWriterPerThread doAfterDocument(DocumentsWriterPerThread perThread, boolean isUpdate)
-
checkout
private DocumentsWriterPerThread checkout(DocumentsWriterPerThread perThread, boolean markPending)
-
assertNumDocsSinceStalled
private boolean assertNumDocsSinceStalled(boolean stalled)
-
doAfterFlush
void doAfterFlush(DocumentsWriterPerThread dwpt)
-
updateStallState
private boolean updateStallState()
-
waitForFlush
public void waitForFlush()
-
setFlushPending
public void setFlushPending(DocumentsWriterPerThread perThread)
Sets flush pending state on the givenDocumentsWriterPerThread. TheDocumentsWriterPerThreadmust have indexed at least on Document and must not be already pending.
-
doOnAbort
void doOnAbort(DocumentsWriterPerThread perThread)
-
checkoutAndBlock
private void checkoutAndBlock(DocumentsWriterPerThread perThread)
-
checkOutForFlush
private DocumentsWriterPerThread checkOutForFlush(DocumentsWriterPerThread perThread)
-
addFlushingDWPT
private void addFlushingDWPT(DocumentsWriterPerThread perThread)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
nextPendingFlush
DocumentsWriterPerThread nextPendingFlush()
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
allActiveWriters
public java.util.Iterator<DocumentsWriterPerThread> 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()
-
setApplyAllDeletes
public void setApplyAllDeletes()
-
obtainAndLock
DocumentsWriterPerThread obtainAndLock()
-
markForFullFlush
long markForFullFlush()
-
assertActiveDeleteQueue
private boolean assertActiveDeleteQueue(DocumentsWriterDeleteQueue queue)
-
pruneBlockedQueue
private void pruneBlockedQueue(DocumentsWriterDeleteQueue flushingQueue)
Prunes the blockedQueue by removing all DWPTs that are associated with the given flush queue.
-
finishFullFlush
void finishFullFlush()
-
assertBlockedFlushes
boolean assertBlockedFlushes(DocumentsWriterDeleteQueue flushingQueue)
-
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
public InfoStream getInfoStream()
Returns theIndexWriterInfoStream
-
findLargestNonPendingWriter
DocumentsWriterPerThread findLargestNonPendingWriter()
-
checkoutLargestNonPendingWriter
final DocumentsWriterPerThread checkoutLargestNonPendingWriter()
Returns the largest non-pending flushable DWPT ornullif there is none.
-
getPeakActiveBytes
long getPeakActiveBytes()
-
getPeakNetBytes
long getPeakNetBytes()
-
-