org.compass.core.lucene.engine.transaction.support
Class AbstractJobBasedTransactionProcessor

java.lang.Object
  extended by org.compass.core.lucene.engine.transaction.support.AbstractTransactionProcessor
      extended by org.compass.core.lucene.engine.transaction.support.AbstractSearchTransactionProcessor
          extended by org.compass.core.lucene.engine.transaction.support.AbstractJobBasedTransactionProcessor
All Implemented Interfaces:
TransactionProcessor
Direct Known Subclasses:
AsyncTransactionProcessor, TerracottaTransactionProcessor

public abstract class AbstractJobBasedTransactionProcessor
extends AbstractSearchTransactionProcessor

Base class for jobs based (TransactionJobs) transaction processor. Mainly used for simple accumelating of TransactionJobs and then processing them during commit/rollback time.

Allows for optionl ordering guarantees of transaction operations across several concurrent transactions from the same or from different JVMs. The setting name to control it is maintainOrder and the constructor allows to control its default value.

Note, if only search based operations were performed, then prepare/commit/rollback will not be called.

Author:
kimchy

Field Summary
 
Fields inherited from class org.compass.core.lucene.engine.transaction.support.AbstractTransactionProcessor
indexManager, logger, mapping, searchEngine, searchEngineFactory
 
Constructor Summary
AbstractJobBasedTransactionProcessor(org.apache.commons.logging.Log logger, LuceneSearchEngine searchEngine, boolean defaultMaintainOrderLock)
          Constructs a new job based transction processor.
 
Method Summary
 void begin()
          Begin the transaction.
 void commit(boolean onePhase)
          Commit the trnasction.
 void create(InternalResource resource)
          Creates a resource.
 void delete(LuceneSearchEngineQuery query)
          Delets everything that match the given query.
 void delete(ResourceKey resourceKey)
          Deletes a resource based on the resource key.
protected abstract  void doCommit(boolean onePhase, TransactionJobs jobs)
           
protected abstract  void doFlushCommit(TransactionJobs jobs)
           
protected abstract  void doPrepare(TransactionJobs jobs)
           
protected abstract  void doRollback(TransactionJobs jobs)
           
 LuceneSearchEngineHits find(LuceneSearchEngineQuery query)
          Perform a search for the given query and returns the hits for it.
 void flush()
          Flush changes.
 void flushCommit(String... aliases)
          Calls doFlushCommit(org.compass.core.lucene.engine.transaction.support.job.TransactionJobs) and then clears the jobs listed to be processed.
 Resource[] get(ResourceKey resourceKey)
          Returns the resources tha match a resource key.
 LuceneSearchEngineInternalSearch internalSearch(String[] subIndexes, String[] aliases)
          Performs an internal search operation.
 void prepare()
          Prepare the transaction for commit.
 void rollback()
          Rollback the transaction.
 void update(InternalResource resource)
          Updates a resource.
 
Methods inherited from class org.compass.core.lucene.engine.transaction.support.AbstractSearchTransactionProcessor
performFind, performGet, performInternalSearch
 
Methods inherited from class org.compass.core.lucene.engine.transaction.support.AbstractTransactionProcessor
buildInternalSearch, findByQuery, getResourceMapping, getSettingName, isInvalidateCacheOnCommit
 
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.transaction.TransactionProcessor
getName
 

Constructor Detail

AbstractJobBasedTransactionProcessor

public AbstractJobBasedTransactionProcessor(org.apache.commons.logging.Log logger,
                                            LuceneSearchEngine searchEngine,
                                            boolean defaultMaintainOrderLock)
Constructs a new job based transction processor. The defaultMaintainOrderLock will control if, by default when no setting is specified (setting name is maintainOrder), what will be the default value of it.

Method Detail

begin

public void begin()
           throws SearchEngineException
Description copied from interface: TransactionProcessor
Begin the transaction.

Throws:
SearchEngineException

prepare

public void prepare()
             throws SearchEngineException
Description copied from interface: TransactionProcessor
Prepare the transaction for commit.

Throws:
SearchEngineException

doPrepare

protected abstract void doPrepare(TransactionJobs jobs)
                           throws SearchEngineException
Throws:
SearchEngineException

commit

public void commit(boolean onePhase)
            throws SearchEngineException
Description copied from interface: TransactionProcessor
Commit the trnasction. If onePhase is set to true then should perform both the prepare phase and the commit phase. If it is set to false then just needs to perform the second phase of the commit process.

Throws:
SearchEngineException

doCommit

protected abstract void doCommit(boolean onePhase,
                                 TransactionJobs jobs)
                          throws SearchEngineException
Throws:
SearchEngineException

rollback

public void rollback()
              throws SearchEngineException
Description copied from interface: TransactionProcessor
Rollback the transaction.

Throws:
SearchEngineException

doRollback

protected abstract void doRollback(TransactionJobs jobs)
                            throws SearchEngineException
Throws:
SearchEngineException

create

public void create(InternalResource resource)
            throws SearchEngineException
Description copied from interface: TransactionProcessor
Creates a resource.

Throws:
SearchEngineException

update

public void update(InternalResource resource)
            throws SearchEngineException
Description copied from interface: TransactionProcessor
Updates a resource.

Throws:
SearchEngineException

delete

public void delete(ResourceKey resourceKey)
            throws SearchEngineException
Description copied from interface: TransactionProcessor
Deletes a resource based on the resource key.

Throws:
SearchEngineException

delete

public void delete(LuceneSearchEngineQuery query)
            throws SearchEngineException
Description copied from interface: TransactionProcessor
Delets everything that match the given query.

Throws:
SearchEngineException

flush

public void flush()
           throws SearchEngineException
Description copied from interface: TransactionProcessor
Flush changes. Note, the implementation needs to strive for changes not to be visible to other transactions.

Throws:
SearchEngineException

flushCommit

public void flushCommit(String... aliases)
                 throws SearchEngineException
Calls doFlushCommit(org.compass.core.lucene.engine.transaction.support.job.TransactionJobs) and then clears the jobs listed to be processed.

Throws:
SearchEngineException

doFlushCommit

protected abstract void doFlushCommit(TransactionJobs jobs)

find

public LuceneSearchEngineHits find(LuceneSearchEngineQuery query)
                            throws SearchEngineException
Description copied from interface: TransactionProcessor
Perform a search for the given query and returns the hits for it.

Throws:
SearchEngineException

internalSearch

public LuceneSearchEngineInternalSearch internalSearch(String[] subIndexes,
                                                       String[] aliases)
                                                throws SearchEngineException
Description copied from interface: TransactionProcessor
Performs an internal search operation.

Throws:
SearchEngineException

get

public Resource[] get(ResourceKey resourceKey)
               throws SearchEngineException
Description copied from interface: TransactionProcessor
Returns the resources tha match a resource key.

Note, should usually only return one resource.

Throws:
SearchEngineException


Copyright (c) 2004-2009 The Compass Project.