org.compass.core.lucene.engine.optimizer
Class AbstractOptimizer

java.lang.Object
  extended by org.compass.core.lucene.engine.optimizer.AbstractOptimizer
All Implemented Interfaces:
SearchEngineOptimizer, LuceneSearchEngineOptimizer
Direct Known Subclasses:
AbstractIndexInfoOptimizer, AdaptiveOptimizer, NullOptimizer

public abstract class AbstractOptimizer
extends Object
implements LuceneSearchEngineOptimizer

A base class that all custom optimizers should extend from. Derived classes should implement doOptimize(String) and doForceOptimize(String).

Author:
kimchy

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
AbstractOptimizer()
           
 
Method Summary
protected abstract  void doForceOptimize(String subIndex)
           
protected abstract  void doOptimize(String subIndex)
           
protected  void doStart()
           
protected  void doStop()
           
 void forceOptimize()
          Optimzies the search engine regardless if it required optimization or not.
 void forceOptimize(String subIndex)
          Optimzies the sub index regardless if it required optimization or not.
protected  LuceneSearchEngineFactory getSearchEngineFactory()
           
 boolean isRunning()
          Returns true if the optimizer is running.
 void optimize()
          Optimizes the search engine index if it requires optimization.
 void optimize(String subIndex)
          Optimizes the sub index if it requires optimization.
 void setSearchEngineFactory(LuceneSearchEngineFactory searchEngineFactory)
          Injected with the actual search engine factory upon construction or Compass startup.
 void start()
          Starts the given optimizer.
 void stop()
          Stops the given optimizer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.compass.core.lucene.engine.optimizer.LuceneSearchEngineOptimizer
canBeScheduled
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Constructor Detail

AbstractOptimizer

public AbstractOptimizer()
Method Detail

start

public void start()
           throws SearchEngineException
Description copied from interface: SearchEngineOptimizer
Starts the given optimizer. Will start a scheduled optimizer if configured.

Specified by:
start in interface SearchEngineOptimizer
Throws:
SearchEngineException

doStart

protected void doStart()
                throws SearchEngineException
Throws:
SearchEngineException

stop

public void stop()
          throws SearchEngineException
Description copied from interface: SearchEngineOptimizer
Stops the given optimizer. Will stop the scheduled optimizer if configured.

Note that if the optimizer is stopped while optimizing, it might take some time till the optimizer will actually stop.

Specified by:
stop in interface SearchEngineOptimizer
Throws:
SearchEngineException

doStop

protected void doStop()
               throws SearchEngineException
Throws:
SearchEngineException

isRunning

public boolean isRunning()
Description copied from interface: SearchEngineOptimizer
Returns true if the optimizer is running.

Specified by:
isRunning in interface SearchEngineOptimizer

optimize

public void optimize()
              throws SearchEngineException
Description copied from interface: SearchEngineOptimizer
Optimizes the search engine index if it requires optimization.

Specified by:
optimize in interface SearchEngineOptimizer
Throws:
SearchEngineException

forceOptimize

public void forceOptimize()
                   throws SearchEngineException
Description copied from interface: SearchEngineOptimizer
Optimzies the search engine regardless if it required optimization or not.

Specified by:
forceOptimize in interface SearchEngineOptimizer
Throws:
SearchEngineException

optimize

public void optimize(String subIndex)
              throws SearchEngineException
Description copied from interface: SearchEngineOptimizer
Optimizes the sub index if it requires optimization.

Specified by:
optimize in interface SearchEngineOptimizer
Parameters:
subIndex - The sub index to optimize
Throws:
SearchEngineException

forceOptimize

public void forceOptimize(String subIndex)
                   throws SearchEngineException
Description copied from interface: SearchEngineOptimizer
Optimzies the sub index regardless if it required optimization or not.

Specified by:
forceOptimize in interface SearchEngineOptimizer
Parameters:
subIndex - The sub index to optimize
Throws:
SearchEngineException

doOptimize

protected abstract void doOptimize(String subIndex)
                            throws SearchEngineException
Throws:
SearchEngineException

doForceOptimize

protected abstract void doForceOptimize(String subIndex)
                                 throws SearchEngineException
Throws:
SearchEngineException

getSearchEngineFactory

protected LuceneSearchEngineFactory getSearchEngineFactory()

setSearchEngineFactory

public void setSearchEngineFactory(LuceneSearchEngineFactory searchEngineFactory)
Description copied from interface: LuceneSearchEngineOptimizer
Injected with the actual search engine factory upon construction or Compass startup.

Specified by:
setSearchEngineFactory in interface LuceneSearchEngineOptimizer


Copyright (c) 2004-2008 The Compass Project.