final class DocumentsWriterStallControl
extends java.lang.Object
DocumentsWriter
sessions. This class
used to block incoming indexing threads if flushing significantly slower than
indexing to ensure the DocumentsWriter
s healthiness. If flushing is
significantly slower than indexing the net memory used within an
IndexWriter
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 in DocumentsWriterPerThreadPool
is exceeded.
Once flushing catches up and the number of flushing DWPT is equal or lower
than the number of active DocumentsWriterPerThreadPool.ThreadState
s threads are released and can
continue indexing.
Modifier and Type | Field and Description |
---|---|
private int |
numWaiting |
private boolean |
stalled |
private java.util.Map<java.lang.Thread,java.lang.Boolean> |
waiting |
private boolean |
wasStalled |
Constructor and Description |
---|
DocumentsWriterStallControl() |
Modifier and Type | Method and 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() |
private volatile boolean stalled
private int numWaiting
private boolean wasStalled
private final java.util.Map<java.lang.Thread,java.lang.Boolean> waiting
void updateStalled(boolean stalled)
true
iff the number of flushing
DocumentsWriterPerThread
is greater than the number of active
DocumentsWriterPerThread
. Otherwise it will reset the
DocumentsWriterStallControl
to healthy and release all threads
waiting on waitIfStalled()
void waitIfStalled()
boolean anyStalledThreads()
private void incWaiters()
private void decrWaiters()
boolean hasBlocked()
boolean isHealthy()
boolean isThreadQueued(java.lang.Thread t)
boolean wasStalled()