public class ControlledRealTimeReopenThread<T>
extends
implements
ReferenceManager
, with methods to wait for a specific
index changes to become visible. When a given search request needs to see a specific
index change, call the {#waitForGeneration} to wait for
that change to be visible. Note that this will only
scale well if most searches do not need to wait for a
specific index generation.Constructor and Description |
---|
ControlledRealTimeReopenThread(IndexWriter writer,
ReferenceManager<T> manager,
double targetMaxStaleSec,
double targetMinStaleSec)
Create ControlledRealTimeReopenThread, to periodically
reopen the
ReferenceManager . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
long |
getSearchingGen()
Returns which
generation the current searcher is guaranteed to include. |
void |
run() |
void |
waitForGeneration(long targetGen)
Waits for the target generation to become visible in
the searcher.
|
boolean |
waitForGeneration(long targetGen,
int maxMS)
Waits for the target generation to become visible in
the searcher, up to a maximum specified milli-seconds.
|
public ControlledRealTimeReopenThread(IndexWriter writer, ReferenceManager<T> manager, double targetMaxStaleSec, double targetMinStaleSec)
ReferenceManager
.targetMaxStaleSec
- Maximum time until a new
reader must be opened; this sets the upper bound
on how slowly reopens may occur, when no
caller is waiting for a specific generation to
become visible.targetMinStaleSec
- Mininum time until a new
reader can be opened; this sets the lower bound
on how quickly reopens may occur, when a caller
is waiting for a specific generation to
become visible.public void close()
in interface
in interface
public void waitForGeneration(long targetGen) throws
ReferenceManager.maybeRefresh()
or until the ReferenceManager
is closed.targetGen
- the generation to wait for
public boolean waitForGeneration(long targetGen, int maxMS) throws
ReferenceManager.maybeRefresh()
, the given waiting time has elapsed, or until
the ReferenceManager
is closed.
NOTE: if the waiting time elapses before the requested target generation is
available the current SearcherManager
is returned instead.
targetGen
- the generation to wait formaxMS
- maximum milliseconds to wait, or -1 to wait indefinitely
public void run()
in interface
in class
public long getSearchingGen()
generation
the current searcher is guaranteed to include.Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.