public class ControlledRealTimeReopenThread<T> extends Thread implements Closeable
ReferenceManager
, with methods to wait for a specific
index changes to become visible. To use this class you
must first wrap your IndexWriter
with a TrackingIndexWriter
and always use it to make changes
to the index, saving the returned generation. Then,
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.Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
ControlledRealTimeReopenThread(TrackingIndexWriter writer,
ReferenceManager<T> manager,
double targetMaxStaleSec,
double targetMinStaleSec)
Create ControlledRealTimeReopenThread, to periodically
reopen the a
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.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public ControlledRealTimeReopenThread(TrackingIndexWriter 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()
close
in interface Closeable
close
in interface AutoCloseable
public void waitForGeneration(long targetGen) throws InterruptedException
ReferenceManager.maybeRefresh()
or until the ReferenceManager
is closed.targetGen
- the generation to wait forInterruptedException
public boolean waitForGeneration(long targetGen, int maxMS) throws InterruptedException
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 indefinitelyInterruptedException
public long getSearchingGen()
generation
the current searcher is guaranteed to include.Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.