org.compass.gps.device.support.parallel
Class AbstractParallelGpsDevice

java.lang.Object
  extended by org.compass.gps.device.AbstractGpsDevice
      extended by org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
All Implemented Interfaces:
CompassGpsDevice
Direct Known Subclasses:
AbstractHibernateGpsDevice, HibernateGpsDevice, JpaGpsDevice, SqlMapClientGpsDevice

public abstract class AbstractParallelGpsDevice
extends AbstractGpsDevice

A base class for gps device that can parallel the index operation.

When the device starts up, the doGetIndexEntities() callback is called (should be implemented by sub classes) in order to get the IndexEntityies. The IndexEntitiesPartitioner is then used in order to partition the index entities into several groups that can be parallel indexed. An IndexEntitiesIndexer is also obtained using the doGetIndexEntitiesIndexer() that can index entities into the search engine and is provided by sub classes as well.

The IndexEntitiesPartitioner defaults to the SubIndexIndexEntitiesPartitioner that partition the index entities based on the sub index. This is the only meanigful way to partition the index entities, as it allows for the best concurrent support (locking is performed on the sub index level).

The index(org.compass.gps.IndexPlan) operation uses the ParallelIndexExecutor in order to execute the indexing process. The default implementation used is ConcurrentParallelIndexExecutor.

Author:
kimchy

Field Summary
 
Fields inherited from class org.compass.gps.device.AbstractGpsDevice
compassGps, log
 
Constructor Summary
AbstractParallelGpsDevice()
           
 
Method Summary
protected abstract  IndexEntity[] doGetIndexEntities()
          Returns all the indexed entities for this device.
protected abstract  IndexEntitiesIndexer doGetIndexEntitiesIndexer()
          Returns an index entities indexer that knows how to index indexable entities.
protected  void doIndex(CompassSession session, IndexPlan indexPlan)
          Overriding this method and throws an IllegalStateException as it should not be called.
 void index(IndexPlan indexPlan)
          Index the indexable entities.
 void setIndexEntitiesPartitioner(IndexEntitiesPartitioner indexEntitiesPartitioner)
          Sets the index entities partitioner.
 void setParallelIndexExecutor(ParallelIndexExecutor parallelIndexExecutor)
          Sets the parallel index executor.
 void start()
          Starts the device.
 
Methods inherited from class org.compass.gps.device.AbstractGpsDevice
buildMessage, doStart, doStop, getGps, getName, injectGps, isFilteredForIndex, isPerformingIndexOperation, isRunning, refresh, setFilteredEntitiesForIndex, setName, shouldMirrorDataChanges, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractParallelGpsDevice

public AbstractParallelGpsDevice()
Method Detail

start

public void start()
           throws CompassGpsException
Starts the device. Calls doGetIndexEntities() in order to get all the indexeable entities and uses the IndexEntitiesPartitioner to partition them index groups that can be parallel indexed. Also calls doGetIndexEntitiesIndexer() in order to obtain the index entities indexer.

Specified by:
start in interface CompassGpsDevice
Overrides:
start in class AbstractGpsDevice
Throws:
CompassGpsException

index

public void index(IndexPlan indexPlan)
           throws CompassGpsException
Index the indexable entities. Calls the ParallelIndexExecutor in order to index the different groups of indexed entities partitioned at startup.

Specified by:
index in interface CompassGpsDevice
Overrides:
index in class AbstractGpsDevice
Throws:
CompassGpsException

doGetIndexEntities

protected abstract IndexEntity[] doGetIndexEntities()
                                             throws CompassGpsException
Returns all the indexed entities for this device.

Throws:
CompassGpsException

doGetIndexEntitiesIndexer

protected abstract IndexEntitiesIndexer doGetIndexEntitiesIndexer()
Returns an index entities indexer that knows how to index indexable entities.


doIndex

protected final void doIndex(CompassSession session,
                             IndexPlan indexPlan)
                      throws CompassGpsException
Overriding this method and throws an IllegalStateException as it should not be called. The index(org.compass.gps.IndexPlan) operation is implemented here and does not call this method.

Specified by:
doIndex in class AbstractGpsDevice
Throws:
CompassGpsException

setParallelIndexExecutor

public void setParallelIndexExecutor(ParallelIndexExecutor parallelIndexExecutor)
Sets the parallel index executor. Defaults to ConcurrentParallelIndexExecutor.

See Also:
index(org.compass.gps.IndexPlan)

setIndexEntitiesPartitioner

public void setIndexEntitiesPartitioner(IndexEntitiesPartitioner indexEntitiesPartitioner)
Sets the index entities partitioner. Defaults to SubIndexIndexEntitiesPartitioner.

See Also:
start()


Copyright (c) 2004-2009 The Compass Project.