org.compass.core.lucene.engine.store
Class AbstractLuceneSearchEngineStore

java.lang.Object
  extended by org.compass.core.lucene.engine.store.AbstractLuceneSearchEngineStore
All Implemented Interfaces:
LuceneSearchEngineStore
Direct Known Subclasses:
FSLuceneSearchEngineStore, JdbcLuceneSearchEngineStore, RAMLuceneSearchEngineStore

public abstract class AbstractLuceneSearchEngineStore
extends Object
implements LuceneSearchEngineStore

Author:
kimchy

Nested Class Summary
protected  class AbstractLuceneSearchEngineStore.CopyFromHolder
           
 
Nested classes/interfaces inherited from interface org.compass.core.lucene.engine.store.LuceneSearchEngineStore
LuceneSearchEngineStore.LuceneStoreCallback
 
Field Summary
protected  String connectionString
           
protected  org.apache.commons.logging.Log log
           
protected  String subContext
           
protected  LuceneStoreTemplate template
           
 
Constructor Summary
AbstractLuceneSearchEngineStore(String connectionString, String subContext)
           
 
Method Summary
 String[] calcSubIndexes(String[] subIndexes, String[] aliases)
          Returns the sub indexes that intersect with the given sub indexes and aliases provided.
 void close()
          Closes the store.
protected  void closeDirectories()
           
 void closeDirectory(String subIndex, Directory dir)
          Closes the given directory.
 void configure(LuceneSearchEngineFactory searchEngineFactory, CompassSettings settings, CompassMapping mapping)
          Configures the store.
 void copyFrom(LuceneSearchEngineStore searchEngineStore)
          Copies the index from the given store into the current store.
 void createIndex()
          Creates the index (if it is already exists, delets it first).
 void deleteIndex()
          Deletes the index.
protected  void doAfterFailedCopyFrom(AbstractLuceneSearchEngineStore.CopyFromHolder holder)
           
protected  void doAfterSuccessfulCopyFrom(AbstractLuceneSearchEngineStore.CopyFromHolder holder)
           
protected  AbstractLuceneSearchEngineStore.CopyFromHolder doBeforeCopyFrom()
           
protected  void doClose()
           
protected abstract  void doDeleteIndex()
           
protected abstract  Directory doOpenDirectoryBySubIndex(String subIndex, boolean create)
           
 Directory getDirectoryBySubIndex(String subIndex, boolean create)
          Returns the directory that match the given sub index.
 LuceneSettings getLuceneSettings()
          Returns the lucene settings.
 int getNumberOfAliasesBySubIndex(String subIndex)
          Returns the number of aliases that map to the given sub index.
 String[] getSubIndexes()
          Returns all the sub indexes defined within the store.
 boolean indexExists()
          Returns true if one of the sub indexes index does not exists.
protected  Boolean indexExists(Directory dir)
           
protected  boolean indexExists(String subIndex)
           
 boolean isLocked()
          Returns true if any sub index is locked.
 boolean isLocked(String subIndex)
          Returns true if the sub index is locked (both Lucene write and commit locks).
 void performScheduledTasks()
          Performs any scheduled tasks, managed by the index manager.
 void registerEventListeners(SearchEngine searchEngine, SearchEngineEventManager eventManager)
          A callback to register event listeners when a SearchEngine is created.
 void releaseLock(String subIndex)
          Releases the lock for the given sub index.
 void releaseLocks()
          Releases all the locks on all the sub indexes.
 String toString()
           
 boolean verifyIndex()
          Verify that the index exists.
protected  boolean verifyIndex(String subIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log

template

protected LuceneStoreTemplate template

connectionString

protected String connectionString

subContext

protected String subContext
Constructor Detail

AbstractLuceneSearchEngineStore

public AbstractLuceneSearchEngineStore(String connectionString,
                                       String subContext)
Method Detail

configure

public void configure(LuceneSearchEngineFactory searchEngineFactory,
                      CompassSettings settings,
                      CompassMapping mapping)
Description copied from interface: LuceneSearchEngineStore
Configures the store.

Specified by:
configure in interface LuceneSearchEngineStore

close

public void close()
Description copied from interface: LuceneSearchEngineStore
Closes the store.

Specified by:
close in interface LuceneSearchEngineStore

closeDirectories

protected void closeDirectories()

doClose

protected void doClose()

performScheduledTasks

public void performScheduledTasks()
Description copied from interface: LuceneSearchEngineStore
Performs any scheduled tasks, managed by the index manager.

Specified by:
performScheduledTasks in interface LuceneSearchEngineStore

closeDirectory

public void closeDirectory(String subIndex,
                           Directory dir)
                    throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Closes the given directory.

Specified by:
closeDirectory in interface LuceneSearchEngineStore
Throws:
SearchEngineException

getNumberOfAliasesBySubIndex

public int getNumberOfAliasesBySubIndex(String subIndex)
Description copied from interface: LuceneSearchEngineStore
Returns the number of aliases that map to the given sub index.

Specified by:
getNumberOfAliasesBySubIndex in interface LuceneSearchEngineStore

getDirectoryBySubIndex

public Directory getDirectoryBySubIndex(String subIndex,
                                        boolean create)
                                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns the directory that match the given sub index.

Specified by:
getDirectoryBySubIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

doOpenDirectoryBySubIndex

protected abstract Directory doOpenDirectoryBySubIndex(String subIndex,
                                                       boolean create)
                                                throws SearchEngineException
Throws:
SearchEngineException

indexExists

protected boolean indexExists(String subIndex)
                       throws SearchEngineException
Throws:
SearchEngineException

indexExists

protected Boolean indexExists(Directory dir)
                       throws IOException
Throws:
IOException

verifyIndex

protected boolean verifyIndex(String subIndex)
                       throws SearchEngineException
Throws:
SearchEngineException

createIndex

public void createIndex()
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Creates the index (if it is already exists, delets it first).

Specified by:
createIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

verifyIndex

public boolean verifyIndex()
                    throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Verify that the index exists. If the index exists, nothing happens, if it does not, the index is created.

Specified by:
verifyIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

indexExists

public boolean indexExists()
                    throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns true if one of the sub indexes index does not exists.

Specified by:
indexExists in interface LuceneSearchEngineStore
Throws:
SearchEngineException

deleteIndex

public void deleteIndex()
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Deletes the index.

Specified by:
deleteIndex in interface LuceneSearchEngineStore
Throws:
SearchEngineException

doDeleteIndex

protected abstract void doDeleteIndex()
                               throws SearchEngineException
Throws:
SearchEngineException

getSubIndexes

public String[] getSubIndexes()
Description copied from interface: LuceneSearchEngineStore
Returns all the sub indexes defined within the store.

Specified by:
getSubIndexes in interface LuceneSearchEngineStore

calcSubIndexes

public String[] calcSubIndexes(String[] subIndexes,
                               String[] aliases)
Description copied from interface: LuceneSearchEngineStore
Returns the sub indexes that intersect with the given sub indexes and aliases provided. If the sub indexes and aliases are null, return all the sub indexes.

Specified by:
calcSubIndexes in interface LuceneSearchEngineStore

isLocked

public boolean isLocked()
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns true if any sub index is locked.

Specified by:
isLocked in interface LuceneSearchEngineStore
Throws:
SearchEngineException

isLocked

public boolean isLocked(String subIndex)
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Returns true if the sub index is locked (both Lucene write and commit locks).

Specified by:
isLocked in interface LuceneSearchEngineStore
Throws:
SearchEngineException

releaseLocks

public void releaseLocks()
                  throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Releases all the locks on all the sub indexes.

Specified by:
releaseLocks in interface LuceneSearchEngineStore
Throws:
SearchEngineException

releaseLock

public void releaseLock(String subIndex)
                 throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Releases the lock for the given sub index.

Specified by:
releaseLock in interface LuceneSearchEngineStore
Throws:
SearchEngineException

registerEventListeners

public void registerEventListeners(SearchEngine searchEngine,
                                   SearchEngineEventManager eventManager)
Description copied from interface: LuceneSearchEngineStore
A callback to register event listeners when a SearchEngine is created.

Specified by:
registerEventListeners in interface LuceneSearchEngineStore
Parameters:
searchEngine - The search engine created
eventManager - The event manager to register events with

copyFrom

public void copyFrom(LuceneSearchEngineStore searchEngineStore)
              throws SearchEngineException
Description copied from interface: LuceneSearchEngineStore
Copies the index from the given store into the current store.

Specified by:
copyFrom in interface LuceneSearchEngineStore
Parameters:
searchEngineStore - The store to copy from
Throws:
SearchEngineException

doBeforeCopyFrom

protected AbstractLuceneSearchEngineStore.CopyFromHolder doBeforeCopyFrom()
                                                                   throws SearchEngineException
Throws:
SearchEngineException

doAfterSuccessfulCopyFrom

protected void doAfterSuccessfulCopyFrom(AbstractLuceneSearchEngineStore.CopyFromHolder holder)
                                  throws SearchEngineException
Throws:
SearchEngineException

doAfterFailedCopyFrom

protected void doAfterFailedCopyFrom(AbstractLuceneSearchEngineStore.CopyFromHolder holder)
                              throws SearchEngineException
Throws:
SearchEngineException

getLuceneSettings

public LuceneSettings getLuceneSettings()
Description copied from interface: LuceneSearchEngineStore
Returns the lucene settings.

Specified by:
getLuceneSettings in interface LuceneSearchEngineStore

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2004-2006 The Compass Project.