org.compass.core.lucene.engine.manager
Class ScheduledLuceneSearchEngineIndexManager

java.lang.Object
  extended by org.compass.core.lucene.engine.manager.ScheduledLuceneSearchEngineIndexManager
All Implemented Interfaces:
SearchEngineIndexManager, LuceneSearchEngineIndexManager

public class ScheduledLuceneSearchEngineIndexManager
extends Object
implements LuceneSearchEngineIndexManager

Author:
kimchy

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.compass.core.lucene.engine.manager.LuceneSearchEngineIndexManager
LuceneSearchEngineIndexManager.LuceneIndexHolder
 
Nested classes/interfaces inherited from interface org.compass.core.engine.SearchEngineIndexManager
SearchEngineIndexManager.IndexOperationCallback, SearchEngineIndexManager.ReplaceIndexCallback
 
Constructor Summary
ScheduledLuceneSearchEngineIndexManager(LuceneSearchEngineIndexManager indexManager)
           
 
Method Summary
 void checkAndClearIfNotifiedAllToClearCache()
          Manual check if the notified to clear the cache globally.
 void clearCache()
          Clears any internal caching done by the index.
 void clearCache(String subIndex)
          Clears any internal caching done by the index for the specified sub-index.
 void close()
          Closes the index manager.
 void closeIndexWriter(String subIndex, IndexWriter indexWriter, Directory dir)
           
 void compoundIndex()
          Compounds the index.
 void createIndex()
          Creates an index data.
 void deleteIndex()
          Deletes the index data.
 LuceneSettings getSettings()
           
 LuceneSearchEngineStore getStore()
           
 boolean indexExists()
          Returns true if the index exists.
 boolean isCached()
          Returns true if one of the sub indexes is cached.
 boolean isCached(String subIndex)
          Returns true if the sub index is cached.
 boolean isIndexCompound()
          Returns true if the index is in a compound form.
 boolean isIndexUnCompound()
          Returns true if the index is in a none compound form.
 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).
 boolean isRunning()
          Returns true if the index manage is running
 void notifyAllToClearCache()
          Notifies all the compass instances that are working with the same index to clear cache.
 LuceneSearchEngineIndexManager.LuceneIndexHolder openIndexHolderBySubIndex(String subIndex)
           
 IndexWriter openIndexWriter(Directory dir, boolean create)
           
 void operate(SearchEngineIndexManager.IndexOperationCallback callback)
          A general api for index operations.
 void performScheduledTasks()
           
 void releaseLock(String subIndex)
          Releases the lock for the given sub index.
 void releaseLocks()
          Releases all the locks on all the sub indexes.
 void replaceIndex(SearchEngineIndexManager innerIndexManager, SearchEngineIndexManager.ReplaceIndexCallback callback)
          Replaces the index data that is used by the current instance, with the one that is pointed by the given indexManager.
 void setWaitForCacheInvalidationBeforeSecondStep(long timeToWaitInMillis)
          Since there might be several instances of Compass running against the same index, they need to be globally notified to invalidate the cache after the commit lock has been obtained for the second step on the SearchEngineIndexManager.operate(org.compass.core.engine.SearchEngineIndexManager.IndexOperationCallback) or SearchEngineIndexManager.replaceIndex(org.compass.core.engine.SearchEngineIndexManager, org.compass.core.engine.SearchEngineIndexManager.ReplaceIndexCallback).
 void start()
          Starts the index manager
 void stop()
          Stops / closes the index manager
 void unCompoundIndex()
          Uncompounds the index.
 boolean verifyIndex()
          Verify the index data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScheduledLuceneSearchEngineIndexManager

public ScheduledLuceneSearchEngineIndexManager(LuceneSearchEngineIndexManager indexManager)
Method Detail

start

public void start()
Description copied from interface: SearchEngineIndexManager
Starts the index manager

Specified by:
start in interface SearchEngineIndexManager

stop

public void stop()
Description copied from interface: SearchEngineIndexManager
Stops / closes the index manager

Specified by:
stop in interface SearchEngineIndexManager

isRunning

public boolean isRunning()
Description copied from interface: SearchEngineIndexManager
Returns true if the index manage is running

Specified by:
isRunning in interface SearchEngineIndexManager

close

public void close()
Description copied from interface: SearchEngineIndexManager
Closes the index manager. Used by compass, probably not a good idea to call it.

Specified by:
close in interface SearchEngineIndexManager

createIndex

public void createIndex()
                 throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Creates an index data. If exists, deletes it and creates a new one.

Specified by:
createIndex in interface SearchEngineIndexManager
Throws:
SearchEngineException

verifyIndex

public boolean verifyIndex()
                    throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Verify the index data. If exists, does nothing. If it doesn't exists, creates it. Returns true if the index was created. If the index exists, and it's LuceneEnvironment.SearchEngineIndex.USE_COMPOUND_FILE changed it's settings, will compound / un-compound the index accordingly.

Specified by:
verifyIndex in interface SearchEngineIndexManager
Throws:
SearchEngineException

deleteIndex

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

Specified by:
deleteIndex in interface SearchEngineIndexManager
Throws:
SearchEngineException

indexExists

public boolean indexExists()
                    throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Returns true if the index exists.

Specified by:
indexExists in interface SearchEngineIndexManager
Throws:
SearchEngineException

operate

public void operate(SearchEngineIndexManager.IndexOperationCallback callback)
             throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
A general api for index operations. Provides the ability to perform safe operations using the SearchEngineIndexManager.IndexOperationCallback.

Specified by:
operate in interface SearchEngineIndexManager
Throws:
SearchEngineException

replaceIndex

public void replaceIndex(SearchEngineIndexManager innerIndexManager,
                         SearchEngineIndexManager.ReplaceIndexCallback callback)
                  throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Replaces the index data that is used by the current instance, with the one that is pointed by the given indexManager. A callback interface can be registered if the index is dynamically created.

The replace process is safe, in terms that it will aquire dirty locks and read locks, so the index can be safely replaced while it is being used.

Specified by:
replaceIndex in interface SearchEngineIndexManager
Throws:
SearchEngineException

isCached

public boolean isCached(String subIndex)
                 throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Returns true if the sub index is cached.

Specified by:
isCached in interface SearchEngineIndexManager
Throws:
SearchEngineException

isCached

public boolean isCached()
                 throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Returns true if one of the sub indexes is cached.

Specified by:
isCached in interface SearchEngineIndexManager
Throws:
SearchEngineException

clearCache

public void clearCache(String subIndex)
                throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Clears any internal caching done by the index for the specified sub-index.

Specified by:
clearCache in interface SearchEngineIndexManager
Throws:
SearchEngineException

clearCache

public void clearCache()
                throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Clears any internal caching done by the index.

Specified by:
clearCache in interface SearchEngineIndexManager
Throws:
SearchEngineException

notifyAllToClearCache

public void notifyAllToClearCache()
                           throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Notifies all the compass instances that are working with the same index to clear cache.

Specified by:
notifyAllToClearCache in interface SearchEngineIndexManager
Throws:
SearchEngineException

checkAndClearIfNotifiedAllToClearCache

public void checkAndClearIfNotifiedAllToClearCache()
                                            throws SearchEngineException
Description copied from interface: SearchEngineIndexManager
Manual check if the notified to clear the cache globally. If it does, will clear the cache.

Specified by:
checkAndClearIfNotifiedAllToClearCache in interface SearchEngineIndexManager
Throws:
SearchEngineException

isIndexCompound

public boolean isIndexCompound()
                        throws SearchEngineException
Description copied from interface: LuceneSearchEngineIndexManager
Returns true if the index is in a compound form. Will return true if the index is empty or it does not exists.

Specified by:
isIndexCompound in interface LuceneSearchEngineIndexManager
Throws:
SearchEngineException

isIndexUnCompound

public boolean isIndexUnCompound()
                          throws SearchEngineException
Description copied from interface: LuceneSearchEngineIndexManager
Returns true if the index is in a none compound form. Will return true if the index is empty or it does not exists.

Specified by:
isIndexUnCompound in interface LuceneSearchEngineIndexManager
Throws:
SearchEngineException

compoundIndex

public void compoundIndex()
                   throws SearchEngineException
Description copied from interface: LuceneSearchEngineIndexManager
Compounds the index.

Specified by:
compoundIndex in interface LuceneSearchEngineIndexManager
Throws:
SearchEngineException

unCompoundIndex

public void unCompoundIndex()
                     throws SearchEngineException
Description copied from interface: LuceneSearchEngineIndexManager
Uncompounds the index.

Specified by:
unCompoundIndex in interface LuceneSearchEngineIndexManager
Throws:
SearchEngineException

isLocked

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

Specified by:
isLocked in interface SearchEngineIndexManager
Throws:
SearchEngineException

isLocked

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

Specified by:
isLocked in interface SearchEngineIndexManager
Throws:
SearchEngineException

releaseLock

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

Specified by:
releaseLock in interface SearchEngineIndexManager
Throws:
SearchEngineException

releaseLocks

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

Specified by:
releaseLocks in interface SearchEngineIndexManager
Throws:
SearchEngineException

getSettings

public LuceneSettings getSettings()
Specified by:
getSettings in interface LuceneSearchEngineIndexManager

getStore

public LuceneSearchEngineStore getStore()
Specified by:
getStore in interface LuceneSearchEngineIndexManager

openIndexWriter

public IndexWriter openIndexWriter(Directory dir,
                                   boolean create)
                            throws IOException
Specified by:
openIndexWriter in interface LuceneSearchEngineIndexManager
Throws:
IOException

closeIndexWriter

public void closeIndexWriter(String subIndex,
                             IndexWriter indexWriter,
                             Directory dir)
                      throws SearchEngineException
Specified by:
closeIndexWriter in interface LuceneSearchEngineIndexManager
Throws:
SearchEngineException

openIndexHolderBySubIndex

public LuceneSearchEngineIndexManager.LuceneIndexHolder openIndexHolderBySubIndex(String subIndex)
                                                                           throws SearchEngineException
Specified by:
openIndexHolderBySubIndex in interface LuceneSearchEngineIndexManager
Throws:
SearchEngineException

setWaitForCacheInvalidationBeforeSecondStep

public void setWaitForCacheInvalidationBeforeSecondStep(long timeToWaitInMillis)
Description copied from interface: LuceneSearchEngineIndexManager
Since there might be several instances of Compass running against the same index, they need to be globally notified to invalidate the cache after the commit lock has been obtained for the second step on the SearchEngineIndexManager.operate(org.compass.core.engine.SearchEngineIndexManager.IndexOperationCallback) or SearchEngineIndexManager.replaceIndex(org.compass.core.engine.SearchEngineIndexManager, org.compass.core.engine.SearchEngineIndexManager.ReplaceIndexCallback).

If directly set to 0, will not wait.

This one will default to the ScheduledLuceneSearchEngineIndexManager interval.

Specified by:
setWaitForCacheInvalidationBeforeSecondStep in interface LuceneSearchEngineIndexManager

performScheduledTasks

public void performScheduledTasks()
                           throws SearchEngineException
Specified by:
performScheduledTasks in interface LuceneSearchEngineIndexManager
Throws:
SearchEngineException


Copyright (c) 2004-2006 The Compass Project.