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

java.lang.Object
  extended by org.compass.core.lucene.engine.optimizer.LuceneSearchEngineOptimizerManager
All Implemented Interfaces:
CompassConfigurable, SearchEngineOptimizer

public class LuceneSearchEngineOptimizerManager
extends Object
implements CompassConfigurable, SearchEngineOptimizer

A SearchEngineOptimizer manager that manages the actual LuceneSearchEngineOptimizer.

When configured (configure(org.compass.core.config.CompassSettings), creates the optimizer that will be used based on the LuceneEnvironment.Optimizer.TYPE. The default optimizer used is the DefaultLuceneSearchEngineOptimizer.

When started, will check the LuceneEnvironment.Optimizer.SCHEDULE flag, and if set to true (the default) will schedule a periodic optimization process. The period is taken from the LuceneEnvironment.Optimizer.SCHEDULE_PERIOD setting, which is set in seconds and defaults to 10.

Author:
kimchy

Constructor Summary
LuceneSearchEngineOptimizerManager(LuceneSearchEngineFactory searchEngineFactory)
           
 
Method Summary
 void configure(CompassSettings settings)
          Configure using the given settings.
 boolean isRunning()
          Returns true if the optimizer is running a scheduled optimizer.
 void optimize()
          Optimizes the search engine index if it requires optimization.
 void optimize(int maxNumberOfSegments)
          Optimizes all the sub indexes down to the required maximum number of segments.
 void optimize(String subIndex)
          Optimizes the sub index does to a configured max number of segments.
 void optimize(String subIndex, int maxNumberOfSegments)
          Optimizes a specific sub index down to a required maximum number of segments.
 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
 

Constructor Detail

LuceneSearchEngineOptimizerManager

public LuceneSearchEngineOptimizerManager(LuceneSearchEngineFactory searchEngineFactory)
Method Detail

configure

public void configure(CompassSettings settings)
               throws CompassException
Description copied from interface: CompassConfigurable
Configure using the given settings.

Specified by:
configure in interface CompassConfigurable
Parameters:
settings - The settings for the configured object
Throws:
CompassException

start

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

Specified by:
start in interface SearchEngineOptimizer
Throws:
SearchEngineException

stop

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

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

isRunning

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

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. The optimization will be perfomed on all sub indexes and based on configuration. For example, the default optimizer will use the configured maxNumberOfSegments in order to perform the optimization.

Specified by:
optimize in interface SearchEngineOptimizer
Throws:
SearchEngineException

optimize

public void optimize(String subIndex)
              throws SearchEngineException
Description copied from interface: SearchEngineOptimizer
Optimizes the sub index does to a configured max number of segments.

Specified by:
optimize in interface SearchEngineOptimizer
Throws:
SearchEngineException

optimize

public void optimize(int maxNumberOfSegments)
              throws SearchEngineException
Description copied from interface: SearchEngineOptimizer
Optimizes all the sub indexes down to the required maximum number of segments.

Specified by:
optimize in interface SearchEngineOptimizer
Throws:
SearchEngineException

optimize

public void optimize(String subIndex,
                     int maxNumberOfSegments)
              throws SearchEngineException
Description copied from interface: SearchEngineOptimizer
Optimizes a specific sub index down to a required maximum number of segments.

Specified by:
optimize in interface SearchEngineOptimizer
Throws:
SearchEngineException


Copyright (c) 2004-2009 The Compass Project.