org.alfresco.repo.node.index
Class AbstractReindexComponent

java.lang.Object
  extended by org.alfresco.repo.node.index.AbstractReindexComponent
All Implemented Interfaces:
IndexRecovery
Direct Known Subclasses:
AVMFullIndexRecoveryComponent, AVMRemoteSnapshotTracker, FullIndexRecoveryComponent, IndexRemoteTransactionTracker, IndexTransactionTracker, MissingContentReindexComponent

public abstract class AbstractReindexComponent
extends java.lang.Object
implements IndexRecovery

Abstract helper for reindexing.

See Also:
AbstractReindexComponent.reindexImpl(), AbstractReindexComponent.getIndexerWriteLock(), AbstractReindexComponent.isShuttingDown()

Nested Class Summary
static class AbstractReindexComponent.InIndex
           
protected static interface AbstractReindexComponent.ReindexNodeCallback
          Callback to notify caller whenever a node has been indexed
static class AbstractReindexComponent.ReindexTerminatedException
          Marker exception to neatly handle VM-driven termination of a reindex
 
Field Summary
protected  FullTextSearchIndexer ftsIndexer
          the FTS indexer that we will prompt to pick up on any un-indexed text
protected  Indexer indexer
          the component to index the node hierarchy
protected  NodeDAO nodeDAO
          the component giving direct access to transaction instances
protected  org.alfresco.service.cmr.repository.NodeService nodeService
          the component giving direct access to store instances
protected  org.alfresco.service.cmr.search.SearchService searcher
          the component providing searches of the indexed nodes
protected  TransactionServiceImpl transactionService
          provides transactions to atomically index each missed transaction
 
Constructor Summary
AbstractReindexComponent()
           
 
Method Summary
protected  java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock getIndexerWriteLock()
          Convenience method to get a common write lock.
 boolean isIgnorableStore(org.alfresco.service.cmr.repository.StoreRef storeRef)
          Find out if a store is ignored by the indexing code
protected  boolean isShuttingDown()
           
 AbstractReindexComponent.InIndex isTxnPresentInIndex(Transaction txn)
          Determines if a given transaction is definitely in the index or not.
 AbstractReindexComponent.InIndex isTxnPresentInIndex(Transaction txn, boolean readThrough)
           
 void reindex()
          If this object is currently busy, then it just nothing
protected abstract  void reindexImpl()
          Perform the actual work.
protected  void reindexTransaction(long txnId, AbstractReindexComponent.ReindexNodeCallback callback, boolean isFull)
          Perform a full reindexing of the given transaction on the current thread.
protected  void reindexTransaction(java.lang.Long txnId, boolean isFull)
           
protected  void reindexTransactionAsynchronously(java.util.List txnIds, boolean isFull)
          Performs indexing off the current thread, which may return quickly if there are threads immediately available in the thread pool.
protected  boolean requireTransaction()
          Determines if calls to AbstractReindexComponent.reindexImpl() should be wrapped in a transaction or not.
 void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
          No longer required
 void setFtsIndexer(FullTextSearchIndexer ftsIndexer)
           
 void setIndexer(Indexer indexer)
           
 void setNodeDAO(NodeDAO nodeDAO)
           
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
           
 void setSearcher(org.alfresco.service.cmr.search.SearchService searcher)
           
 void setShutdown(boolean shutdown)
          Programmatically notify a reindex thread to terminate
 void setStoreProtocolsToIgnore(java.util.List storeProtocolsToIgnore)
           
 void setStoresToIgnore(java.util.List storesToIgnore)
           
 void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
           
 void setThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor threadPoolExecutor)
          Set the thread pool to use when doing asynchronous reindexing.
 void setTransactionService(TransactionServiceImpl transactionService)
          Set the low-level transaction component to use
protected  void waitForAsynchronousReindexing()
          Wait for all asynchronous indexing to finish before returning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transactionService

protected TransactionServiceImpl transactionService
provides transactions to atomically index each missed transaction


indexer

protected Indexer indexer
the component to index the node hierarchy


ftsIndexer

protected FullTextSearchIndexer ftsIndexer
the FTS indexer that we will prompt to pick up on any un-indexed text


searcher

protected org.alfresco.service.cmr.search.SearchService searcher
the component providing searches of the indexed nodes


nodeService

protected org.alfresco.service.cmr.repository.NodeService nodeService
the component giving direct access to store instances


nodeDAO

protected NodeDAO nodeDAO
the component giving direct access to transaction instances

Constructor Detail

AbstractReindexComponent

public AbstractReindexComponent()
Method Detail

getIndexerWriteLock

protected java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock getIndexerWriteLock()
Convenience method to get a common write lock. This can be used to avoid concurrent access to the work methods.


setShutdown

public void setShutdown(boolean shutdown)
Programmatically notify a reindex thread to terminate

Parameters:
shutdown - true to shutdown, false to reset

isShuttingDown

protected boolean isShuttingDown()
Returns:
Returns true if the VM shutdown hook has been triggered, or the instance was programmatically shut down

setAuthenticationComponent

public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
No longer required


setTransactionService

public void setTransactionService(TransactionServiceImpl transactionService)
Set the low-level transaction component to use

Parameters:
transactionComponent - provide transactions to index each missed transaction

setIndexer

public void setIndexer(Indexer indexer)
Parameters:
indexer - the indexer that will be index

setFtsIndexer

public void setFtsIndexer(FullTextSearchIndexer ftsIndexer)
Parameters:
ftsIndexer - the FTS background indexer

setSearcher

public void setSearcher(org.alfresco.service.cmr.search.SearchService searcher)
Parameters:
searcher - component providing index searches

setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
Parameters:
nodeService - provides information about nodes for indexing

setNodeDAO

public void setNodeDAO(NodeDAO nodeDAO)
Parameters:
nodeDAO - provides access to transaction-related queries

setThreadPoolExecutor

public void setThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor threadPoolExecutor)
Set the thread pool to use when doing asynchronous reindexing. Use null to have the calling thread do the indexing.

Parameters:
threadPoolExecutor - a pre-configured thread pool for the reindex work
Since:
2.1.4

setTenantService

public void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)

setStoreProtocolsToIgnore

public void setStoreProtocolsToIgnore(java.util.List storeProtocolsToIgnore)
Parameters:
storeProtocolsToIgnore - a list of store protocols that will be ignored by the index check code e.g. 'deleted' in 'deleted://MyStore'
Since:
3.4

setStoresToIgnore

public void setStoresToIgnore(java.util.List storesToIgnore)
Parameters:
storesToIgnore - a list of store references that will be ignored by the index check code e.g. 'test://TestOne'

isIgnorableStore

public boolean isIgnorableStore(org.alfresco.service.cmr.repository.StoreRef storeRef)
Find out if a store is ignored by the indexing code

Parameters:
storeRef - the store to check
Returns:
Returns true if the store reference provided is not indexed

requireTransaction

protected boolean requireTransaction()
Determines if calls to AbstractReindexComponent.reindexImpl() should be wrapped in a transaction or not. The default is true.

Returns:
Returns true if an existing transaction is required for reindexing.

reindexImpl

protected abstract void reindexImpl()
Perform the actual work. This method will be called as the system user and within an existing transaction. This thread will only ever be accessed by a single thread per instance.


reindex

public final void reindex()
If this object is currently busy, then it just nothing

Specified by:
reindex in interface IndexRecovery

isTxnPresentInIndex

public AbstractReindexComponent.InIndex isTxnPresentInIndex(Transaction txn)
Determines if a given transaction is definitely in the index or not.

Parameters:
txn - a specific transaction
Returns:
Returns true if the transaction is definitely in the index

isTxnPresentInIndex

public AbstractReindexComponent.InIndex isTxnPresentInIndex(Transaction txn,
                                                            boolean readThrough)

reindexTransaction

protected void reindexTransaction(java.lang.Long txnId,
                                  boolean isFull)

reindexTransaction

protected void reindexTransaction(long txnId,
                                  AbstractReindexComponent.ReindexNodeCallback callback,
                                  boolean isFull)
Perform a full reindexing of the given transaction on the current thread. The calling thread must be in the context of a read-only transaction.

Parameters:
txnId - the transaction identifier
callback - the callback to notify of each node indexed
Throws:
AbstractReindexComponent.ReindexTerminatedException - if the VM is shutdown during the reindex

reindexTransactionAsynchronously

protected void reindexTransactionAsynchronously(java.util.List txnIds,
                                                boolean isFull)
Performs indexing off the current thread, which may return quickly if there are threads immediately available in the thread pool.

Commits are guaranteed to occur in the order in which this reindex jobs are added to the queue.

Since:
2.1.4
See Also:
#reindexTransaction(long), AbstractReindexComponent.waitForAsynchronousReindexing()

waitForAsynchronousReindexing

protected void waitForAsynchronousReindexing()
Wait for all asynchronous indexing to finish before returning. This is useful if the calling thread wants to ensure that all reindex work has finished before continuing.



Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.