final class DocumentsWriterPerThreadPool
extends java.lang.Object
DocumentsWriterPerThreadPool
controls DocumentsWriterPerThreadPool.ThreadState
instances
and their thread assignments during indexing. Each DocumentsWriterPerThreadPool.ThreadState
holds
a reference to a DocumentsWriterPerThread
that is once a
DocumentsWriterPerThreadPool.ThreadState
is obtained from the pool exclusively used for indexing a
single document by the obtaining thread. Each indexing thread must obtain
such a DocumentsWriterPerThreadPool.ThreadState
to make progress. Depending on the
DocumentsWriterPerThreadPool
implementation DocumentsWriterPerThreadPool.ThreadState
assignments might differ from document to document.
Once a DocumentsWriterPerThread
is selected for flush the thread pool
is reusing the flushing DocumentsWriterPerThread
s ThreadState with a
new DocumentsWriterPerThread
instance.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
DocumentsWriterPerThreadPool.ThreadState
DocumentsWriterPerThreadPool.ThreadState references and guards a
DocumentsWriterPerThread instance that is used during indexing to
build a in-memory index segment. |
Modifier and Type | Field and Description |
---|---|
private java.util.List<DocumentsWriterPerThreadPool.ThreadState> |
freeList |
private int |
takenThreadStatePermits |
private java.util.List<DocumentsWriterPerThreadPool.ThreadState> |
threadStates |
Constructor and Description |
---|
DocumentsWriterPerThreadPool() |
Modifier and Type | Method and Description |
---|---|
(package private) int |
getActiveThreadStateCount()
Returns the active number of
DocumentsWriterPerThreadPool.ThreadState instances. |
(package private) DocumentsWriterPerThreadPool.ThreadState |
getAndLock()
This method is used by DocumentsWriter/FlushControl to obtain a ThreadState to do an indexing operation (add/updateDocument).
|
(package private) int |
getMaxThreadStates() |
(package private) DocumentsWriterPerThreadPool.ThreadState |
getThreadState(int ord)
Returns the ith active
DocumentsWriterPerThreadPool.ThreadState where i is the
given ord. |
(package private) void |
lockNewThreadStates() |
private DocumentsWriterPerThreadPool.ThreadState |
newThreadState()
Returns a new
DocumentsWriterPerThreadPool.ThreadState iff any new state is available otherwise
null . |
(package private) void |
recycle(DocumentsWriterPerThread dwpt) |
(package private) void |
release(DocumentsWriterPerThreadPool.ThreadState state) |
(package private) DocumentsWriterPerThread |
reset(DocumentsWriterPerThreadPool.ThreadState threadState) |
(package private) void |
unlockNewThreadStates() |
private final java.util.List<DocumentsWriterPerThreadPool.ThreadState> threadStates
private final java.util.List<DocumentsWriterPerThreadPool.ThreadState> freeList
private int takenThreadStatePermits
int getActiveThreadStateCount()
DocumentsWriterPerThreadPool.ThreadState
instances.void lockNewThreadStates()
void unlockNewThreadStates()
private DocumentsWriterPerThreadPool.ThreadState newThreadState()
DocumentsWriterPerThreadPool.ThreadState
iff any new state is available otherwise
null
.
NOTE: the returned DocumentsWriterPerThreadPool.ThreadState
is already locked iff non-
null
.
DocumentsWriterPerThreadPool.ThreadState
iff any new state is available otherwise
null
DocumentsWriterPerThread reset(DocumentsWriterPerThreadPool.ThreadState threadState)
void recycle(DocumentsWriterPerThread dwpt)
DocumentsWriterPerThreadPool.ThreadState getAndLock()
void release(DocumentsWriterPerThreadPool.ThreadState state)
DocumentsWriterPerThreadPool.ThreadState getThreadState(int ord)
DocumentsWriterPerThreadPool.ThreadState
where i is the
given ord.ord
- the ordinal of the DocumentsWriterPerThreadPool.ThreadState
DocumentsWriterPerThreadPool.ThreadState
where i is the
given ord.int getMaxThreadStates()