org.compass.core.lucene.engine.transaction.mt
Class MTTransactionProcessor

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.mt.MTTransactionProcessor
All Implemented Interfaces:
TransactionProcessor

public class MTTransactionProcessor
extends AbstractSearchTransactionProcessor

The MT (Multi Threaded) transaction processor allows for multi threaded indexing meaning several threads can perfom the indexing process using the same Transaction Processor (Search Engine or Session).

Actual operations are delegated to the respective sub index IndexWriter without any buffering or delegation to another thread pool. This makes this transaction processor useful mainly when there are several threas that will index data.

Author:
kimchy

Field Summary
 
Fields inherited from class org.compass.core.lucene.engine.transaction.support.AbstractTransactionProcessor
indexManager, mapping, searchEngine, searchEngineFactory
 
Constructor Summary
MTTransactionProcessor(MTTransactionProcessorFactory transactionProcessorFactory, LuceneSearchEngine searchEngine)
           
 
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.
 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)
          Flush changes and make them visible for other transactions.
 Resource[] get(ResourceKey resourceKey)
          Returns the resources tha match a resource key.
 String getName()
          Retuns the name of this transaction processor.
protected  IndexWriter getOrCreateIndexWriter(String subIndex)
          Opens a new index writer if there is no open one already for the provided sub index.
 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
 

Constructor Detail

MTTransactionProcessor

public MTTransactionProcessor(MTTransactionProcessorFactory transactionProcessorFactory,
                              LuceneSearchEngine searchEngine)
Method Detail

getName

public String getName()
Description copied from interface: TransactionProcessor
Retuns the name of this transaction processor.


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

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

rollback

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

Throws:
SearchEngineException

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

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

internalSearch

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

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
Description copied from interface: TransactionProcessor
Flush changes and make them visible for other transactions. Note, operations performed up until the flush commit was called might not be able to roll back.

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

getOrCreateIndexWriter

protected IndexWriter getOrCreateIndexWriter(String subIndex)
                                      throws SearchEngineException
Opens a new index writer if there is no open one already for the provided sub index.

Thread safe.

Throws:
SearchEngineException


Copyright (c) 2004-2009 The Compass Project.