org.cdlib.xtf.textEngine
Class IndexWarmer

Object
  extended by IndexWarmer

public class IndexWarmer
extends Object

Handles background warming of new (or changed) indexes, so that servlets can continue serving using their existing index, and switch quickly to the new one when it is ready.

Author:
Martin Haye

Nested Class Summary
private static class IndexWarmer.BgThread
          Thread that sits in the background and periodically checks if there are indexes in need of warming, and warms them.
private static class IndexWarmer.Entry
          An entry mapping indexPath to XtfSearcher
 
Field Summary
private  IndexWarmer.BgThread bgThread
           
private  HashMap<String,IndexWarmer.Entry> entries
           
private  int updateInterval
           
private  String xtfHome
           
 
Constructor Summary
IndexWarmer(String xtfHome, int updateInterval)
          Construct the warmer and start up the background warming thread.
 
Method Summary
 void close()
          Shuts down the background thread, if it's running.
 XtfSearcher getSearcher(String indexPath)
          Get a searcher for the given index path.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xtfHome

private String xtfHome

entries

private HashMap<String,IndexWarmer.Entry> entries

bgThread

private IndexWarmer.BgThread bgThread

updateInterval

private int updateInterval
Constructor Detail

IndexWarmer

public IndexWarmer(String xtfHome,
                   int updateInterval)
Construct the warmer and start up the background warming thread.

Parameters:
xtfHome - Filesystem path to the XTF home directory
updateInterval - Minimum number of seconds between warming one index and the next, or 0 to disable background warming.
Method Detail

close

public void close()
Shuts down the background thread, if it's running.


getSearcher

public XtfSearcher getSearcher(String indexPath)
                        throws IOException
Get a searcher for the given index path. If there isn't one already, we create one in the foreground (we don't return til it's ready).

Throws:
IOException