Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.search
Class ControlledRealTimeReopenThread<T>

    java.lang.Object
      java.lang.Thread
          org.apache.lucene.search.ControlledRealTimeReopenThread<T>

All Implemented Interfaces:
  Closeable, Runnable

    public class ControlledRealTimeReopenThread<T>

extends Thread
implements Closeable

Utility class that runs a thread to manage periodicc reopens of a `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.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Nested Class Summary

Nested classes/interfaces inherited from class java.lang.Thread
`Thread.State, Thread.UncaughtExceptionHandler`

Field Summary

Fields inherited from class java.lang.Thread
`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

Constructor Summary
`ControlledRealTimeReopenThread(TrackingIndexWriter writer, ReferenceManager<T> manager, double targetMaxStaleSec, double targetMinStaleSec)` Create ControlledRealTimeReopenThread, to periodically reopen the a `ReferenceManager`.

Method Summary
`void` | `close()`
`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.

Methods inherited from class java.lang.Thread
`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`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ControlledRealTimeReopenThread

    public ControlledRealTimeReopenThread(TrackingIndexWriter writer,
                                          ReferenceManager<T> manager,
                                          double targetMaxStaleSec,
                                          double targetMinStaleSec)

  Create ControlledRealTimeReopenThread, to periodically reopen the a `ReferenceManager`.

  Parameters:
    `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.

Method Detail

### close

    public void close()

  Specified by:
    `close` in interface `Closeable`

### waitForGeneration

    public void waitForGeneration(long targetGen)
                           throws InterruptedException

  Waits for the target generation to become visible in the searcher. If the current searcher is older than the target generation, this method will block until the searcher is reopened, by another via `ReferenceManager.maybeRefresh()` or until the `ReferenceManager` is closed.

  Parameters:
    `targetGen` - the generation to wait for
  Throws:
    `InterruptedException`

### waitForGeneration

    public boolean waitForGeneration(long targetGen,
                                     int maxMS)
                              throws InterruptedException

  Waits for the target generation to become visible in the searcher, up to a maximum specified milli-seconds. If the current searcher is older than the target generation, this method will block until the searcher has been reopened by another thread via `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.

  Parameters:
    `targetGen` - the generation to wait for
    `maxMS` - maximum milliseconds to wait, or -1 to wait indefinitely
  Returns:
    true if the targetGeneration is now available, or false if maxMS wait time was exceeded
  Throws:
    `InterruptedException`

### run

    public void run()

  Specified by:
    `run` in interface `Runnable`
  Overrides:
    `run` in class `Thread`

Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.