Class AbstractLuceneIndexerImpl<T>
- java.lang.Object
-
- org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
-
- org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerImpl<T>
-
- Type Parameters:
T- - the type used to generate the key in the index file
- All Implemented Interfaces:
Indexer
public abstract class AbstractLuceneIndexerImpl<T> extends AbstractLuceneBase implements Indexer
Common support for indexing across implementations- Author:
- andyh
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractLuceneIndexerImpl.ActionEnum for indexing actions against a nodeprotected static classAbstractLuceneIndexerImpl.Command<S>protected static classAbstractLuceneIndexerImpl.FTSStatusprotected static classAbstractLuceneIndexerImpl.IndexUpdateStatus
-
Field Summary
Fields Modifier and Type Field Description protected NodeBulkLoaderbulkLoaderprotected java.util.List<AbstractLuceneIndexerImpl.Command<T>>commandListList of pending indexing commands.protected java.util.Set<java.lang.String>containerDeletionsA list of cascading container deletions we have made - at merge these deletions need to be made against the main index.protected java.util.Set<java.lang.String>deletionsA list of all deletions we have made - at merge these deletions need to be made against the main index.protected longdocsprotected AbstractLuceneIndexerImpl.IndexUpdateStatusindexUpdateStatusFlag to indicte if we are doing an in transactional delta or a batch update to the index.protected longmaxAtomicTransformationTimethe maximum transformation time to allow atomically, defaulting to 20msstatic java.lang.StringNOT_INDEXED_CONTENT_MISSINGNo contentstatic java.lang.StringNOT_INDEXED_NO_TRANSFORMATIONNo transform availablestatic java.lang.StringNOT_INDEXED_NO_TYPE_CONVERSIONNo type conversionstatic java.lang.StringNOT_INDEXED_TRANSFORMATION_FAILEDTranfrom failedprotected TransactionServicetransactionService-
Fields inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
deltaId, store
-
-
Constructor Summary
Constructors Constructor Description AbstractLuceneIndexerImpl()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckAbleToDoWork(AbstractLuceneIndexerImpl.IndexUpdateStatus indexUpdateStatus)Utility method to check we are in the correct state to do work Also keeps track of the dirty flag.voidcommit()Commit this indexprotected voiddelete(T ref)protected static java.util.Set<java.lang.String>deleteContainerAndBelow(java.lang.String nodeRef, org.apache.lucene.index.IndexReader reader, boolean delete, boolean cascade)protected static java.util.Set<java.lang.String>deletePrimary(java.util.Collection<java.lang.String> nodeRefs, org.apache.lucene.index.IndexReader reader, boolean delete)protected static java.util.Set<java.lang.String>deleteReference(java.util.Collection<java.lang.String> nodeRefs, org.apache.lucene.index.IndexReader reader, boolean delete)protected abstract voiddoCommit()protected <T2> T2doInReadthroughTransaction(RetryingTransactionHelper.RetryingTransactionCallback<T2> callback)protected abstract voiddoPrepare()protected abstract voiddoRollBack()protected abstract voiddoSetRollbackOnly()java.util.Set<java.lang.String>getContainerDeletions()Get the container deletionsjava.util.Set<java.lang.String>getDeletions()Get the deletionsprotected voidindex(T ref)booleanisModified()Has this index been modified?protected booleanlocateContainer(java.lang.String nodeRef, org.apache.lucene.index.IndexReader reader)intprepare()Prepare to commit At the moment this makes sure we have all the locks TODO: This is not doing proper serialisation against the index as would a data base transaction.protected voidreindex(T ref, boolean cascadeReindexDirectories)voidrollback()Roll back the index changes (this just means they are never added)voidsetBulkLoader(NodeBulkLoader bulkLoader)voidsetMaxAtomicTransformationTime(long maxAtomicTransformationTime)Set the max time allowed to transform content atomicallyvoidsetReadThrough(boolean isReadThrough)Activates 'read through' behaviour for this indexer.voidsetRollbackOnly()Mark this index for roll back only.voidsetTransactionService(TransactionService transactionService)-
Methods inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
closeDeltaReader, closeDeltaWriter, deleteIndex, doReadOnly, getDeltaId, getDeltaReader, getDeltaWriter, getDictionaryService, getLuceneConfig, getReader, getSearcher, getSearcher, getStatus, initialise, saveDelta, setDictionaryService, setInfo, setLuceneConfig, setStatus
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.alfresco.repo.search.Indexer
createChildRelationship, createNode, deleteChildRelationship, deleteIndex, deleteNode, detectNodeChanges, flushPending, updateChildRelationship, updateNode
-
-
-
-
Field Detail
-
docs
protected long docs
-
transactionService
protected TransactionService transactionService
-
bulkLoader
protected NodeBulkLoader bulkLoader
-
NOT_INDEXED_NO_TRANSFORMATION
public static final java.lang.String NOT_INDEXED_NO_TRANSFORMATION
No transform available- See Also:
- Constant Field Values
-
NOT_INDEXED_TRANSFORMATION_FAILED
public static final java.lang.String NOT_INDEXED_TRANSFORMATION_FAILED
Tranfrom failed- See Also:
- Constant Field Values
-
NOT_INDEXED_CONTENT_MISSING
public static final java.lang.String NOT_INDEXED_CONTENT_MISSING
No content- See Also:
- Constant Field Values
-
NOT_INDEXED_NO_TYPE_CONVERSION
public static final java.lang.String NOT_INDEXED_NO_TYPE_CONVERSION
No type conversion- See Also:
- Constant Field Values
-
maxAtomicTransformationTime
protected long maxAtomicTransformationTime
the maximum transformation time to allow atomically, defaulting to 20ms
-
deletions
protected java.util.Set<java.lang.String> deletions
A list of all deletions we have made - at merge these deletions need to be made against the main index. TODO: Consider if this information needs to be persisted for recovery
-
containerDeletions
protected java.util.Set<java.lang.String> containerDeletions
A list of cascading container deletions we have made - at merge these deletions need to be made against the main index.
-
commandList
protected java.util.List<AbstractLuceneIndexerImpl.Command<T>> commandList
List of pending indexing commands.
-
indexUpdateStatus
protected AbstractLuceneIndexerImpl.IndexUpdateStatus indexUpdateStatus
Flag to indicte if we are doing an in transactional delta or a batch update to the index. If true, we are just fixing up non atomically indexed things from one or more other updates.
-
-
Method Detail
-
setReadThrough
public void setReadThrough(boolean isReadThrough)
Description copied from interface:IndexerActivates 'read through' behaviour for this indexer. Rather than accessing the database through the current (potentially old) transaction, it will use a discrete read only transaction for each node it indexes. This avoids 'stale' nodes building up in the caches during long reindex runs.- Specified by:
setReadThroughin interfaceIndexer- Parameters:
isReadThrough- boolean
-
setTransactionService
public void setTransactionService(TransactionService transactionService)
-
setBulkLoader
public void setBulkLoader(NodeBulkLoader bulkLoader)
- Parameters:
bulkLoader- object to provide node loading options
-
deletePrimary
protected static java.util.Set<java.lang.String> deletePrimary(java.util.Collection<java.lang.String> nodeRefs, org.apache.lucene.index.IndexReader reader, boolean delete) throws LuceneIndexException- Throws:
LuceneIndexException
-
deleteReference
protected static java.util.Set<java.lang.String> deleteReference(java.util.Collection<java.lang.String> nodeRefs, org.apache.lucene.index.IndexReader reader, boolean delete) throws LuceneIndexException- Throws:
LuceneIndexException
-
deleteContainerAndBelow
protected static java.util.Set<java.lang.String> deleteContainerAndBelow(java.lang.String nodeRef, org.apache.lucene.index.IndexReader reader, boolean delete, boolean cascade) throws LuceneIndexException- Throws:
LuceneIndexException
-
locateContainer
protected boolean locateContainer(java.lang.String nodeRef, org.apache.lucene.index.IndexReader reader)
-
setMaxAtomicTransformationTime
public void setMaxAtomicTransformationTime(long maxAtomicTransformationTime)
Set the max time allowed to transform content atomically- Parameters:
maxAtomicTransformationTime- long
-
checkAbleToDoWork
protected void checkAbleToDoWork(AbstractLuceneIndexerImpl.IndexUpdateStatus indexUpdateStatus)
Utility method to check we are in the correct state to do work Also keeps track of the dirty flag.- Throws:
IndexerExceptionLuceneIndexException
-
commit
public void commit() throws LuceneIndexExceptionCommit this index- Throws:
LuceneIndexException
-
prepare
public int prepare() throws LuceneIndexExceptionPrepare to commit At the moment this makes sure we have all the locks TODO: This is not doing proper serialisation against the index as would a data base transaction.- Returns:
- the tx state
- Throws:
LuceneIndexException
-
isModified
public boolean isModified()
Has this index been modified?- Returns:
- true if modified
-
rollback
public void rollback() throws LuceneIndexExceptionRoll back the index changes (this just means they are never added)- Throws:
LuceneIndexException
-
setRollbackOnly
public void setRollbackOnly()
Mark this index for roll back only. This action can not be reversed. It will reject all other work and only allow roll back.
-
doPrepare
protected abstract void doPrepare() throws java.io.IOException- Throws:
java.io.IOException
-
doCommit
protected abstract void doCommit() throws java.io.IOException- Throws:
java.io.IOException
-
doRollBack
protected abstract void doRollBack() throws java.io.IOException- Throws:
java.io.IOException
-
doSetRollbackOnly
protected abstract void doSetRollbackOnly() throws java.io.IOException- Throws:
java.io.IOException
-
doInReadthroughTransaction
protected <T2> T2 doInReadthroughTransaction(RetryingTransactionHelper.RetryingTransactionCallback<T2> callback)
-
index
protected void index(T ref) throws LuceneIndexException
- Throws:
LuceneIndexException
-
reindex
protected void reindex(T ref, boolean cascadeReindexDirectories) throws LuceneIndexException
- Throws:
LuceneIndexException
-
delete
protected void delete(T ref) throws LuceneIndexException
- Throws:
LuceneIndexException
-
getDeletions
public java.util.Set<java.lang.String> getDeletions()
Get the deletions- Returns:
- - the ids to delete
-
getContainerDeletions
public java.util.Set<java.lang.String> getContainerDeletions()
Get the container deletions- Returns:
- - the ids to delete
-
-