Package org.apache.lucene.index
Class DocumentsWriterStallControl
- java.lang.Object
-
- org.apache.lucene.index.DocumentsWriterStallControl
-
final class DocumentsWriterStallControl extends java.lang.Object
Controls the health status of aDocumentsWriter
sessions. This class used to block incoming indexing threads if flushing significantly slower than indexing to ensure theDocumentsWriter
s healthiness. If flushing is significantly slower than indexing the net memory used within anIndexWriter
session can increase very quickly and easily exceed the JVM's available memory.To prevent OOM Errors and ensure IndexWriter's stability this class blocks incoming threads from indexing once 2 x number of available
DocumentsWriterPerThreadPool.ThreadState
s inDocumentsWriterPerThreadPool
is exceeded. Once flushing catches up and the number of flushing DWPT is equal or lower than the number of activeDocumentsWriterPerThreadPool.ThreadState
s threads are released and can continue indexing.
-
-
Field Summary
Fields Modifier and Type Field Description private int
numWaiting
private boolean
stalled
private java.util.Map<java.lang.Thread,java.lang.Boolean>
waiting
private boolean
wasStalled
-
Constructor Summary
Constructors Constructor Description DocumentsWriterStallControl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
anyStalledThreads()
private void
decrWaiters()
(package private) boolean
hasBlocked()
private void
incWaiters()
(package private) boolean
isHealthy()
(package private) boolean
isThreadQueued(java.lang.Thread t)
(package private) void
updateStalled(boolean stalled)
Update the stalled flag status.(package private) void
waitIfStalled()
Blocks if documents writing is currently in a stalled state.(package private) boolean
wasStalled()
-
-
-
Method Detail
-
updateStalled
void updateStalled(boolean stalled)
Update the stalled flag status. This method will set the stalled flag totrue
iff the number of flushingDocumentsWriterPerThread
is greater than the number of activeDocumentsWriterPerThread
. Otherwise it will reset theDocumentsWriterStallControl
to healthy and release all threads waiting onwaitIfStalled()
-
waitIfStalled
void waitIfStalled()
Blocks if documents writing is currently in a stalled state.
-
anyStalledThreads
boolean anyStalledThreads()
-
incWaiters
private void incWaiters()
-
decrWaiters
private void decrWaiters()
-
hasBlocked
boolean hasBlocked()
-
isHealthy
boolean isHealthy()
-
isThreadQueued
boolean isThreadQueued(java.lang.Thread t)
-
wasStalled
boolean wasStalled()
-
-