mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
Fix for ALF-2329: Parameter to automatically remove the existing index directories before doing a FULL re-index
- full reindex now deletes any existing DM and AVM indexes - the index directory is tidied up int eh backround which may take some time - includes fix to check async snapshots are in the index (it was checking sync twice ...) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19922 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -287,6 +287,16 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
|
|||||||
else if (mode == RecoveryMode.FULL)
|
else if (mode == RecoveryMode.FULL)
|
||||||
{
|
{
|
||||||
logger.info(" Rebuilding index for " + store);
|
logger.info(" Rebuilding index for " + store);
|
||||||
|
// delete existing index
|
||||||
|
RetryingTransactionCallback<Void> deleteWork = new RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
public Void execute() throws Exception
|
||||||
|
{
|
||||||
|
avmSnapShotTriggeredIndexingMethodInterceptor.deleteIndex(store);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
transactionService.getRetryingTransactionHelper().doInTransaction(deleteWork, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
final int latest = avmService.getLatestSnapshotID(store);
|
final int latest = avmService.getLatestSnapshotID(store);
|
||||||
|
@@ -32,6 +32,7 @@ import org.alfresco.repo.node.index.IndexTransactionTracker.IndexTransactionTrac
|
|||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef.Status;
|
import org.alfresco.service.cmr.repository.NodeRef.Status;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -318,6 +319,21 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
|
|||||||
private static final int MAX_TRANSACTIONS_PER_ITERATION = 1000;
|
private static final int MAX_TRANSACTIONS_PER_ITERATION = 1000;
|
||||||
private void performFullRecovery()
|
private void performFullRecovery()
|
||||||
{
|
{
|
||||||
|
RetryingTransactionCallback<Void> deleteWork = new RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
public Void execute() throws Exception
|
||||||
|
{
|
||||||
|
// delete stores
|
||||||
|
for(StoreRef storeRef : nodeService.getStores())
|
||||||
|
{
|
||||||
|
indexer.deleteIndex(storeRef);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
transactionService.getRetryingTransactionHelper().doInTransaction(deleteWork, true, true);
|
||||||
|
|
||||||
|
|
||||||
int txnCount = nodeDaoService.getTransactionCount();
|
int txnCount = nodeDaoService.getTransactionCount();
|
||||||
// starting
|
// starting
|
||||||
String msgStart = I18NUtil.getMessage(MSG_RECOVERY_STARTING, txnCount);
|
String msgStart = I18NUtil.getMessage(MSG_RECOVERY_STARTING, txnCount);
|
||||||
|
@@ -519,4 +519,14 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteIndex(String store)
|
||||||
|
{
|
||||||
|
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||||
|
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||||
|
if (indexer instanceof AVMLuceneIndexer)
|
||||||
|
{
|
||||||
|
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||||
|
avmIndexer.deleteIndex(storeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ package org.alfresco.repo.search;
|
|||||||
|
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface abstracts how indexing is used from within the node service
|
* This interface abstracts how indexing is used from within the node service
|
||||||
@@ -102,6 +103,12 @@ public interface Indexer
|
|||||||
*/
|
*/
|
||||||
public void deleteChildRelationship(ChildAssociationRef relationshipRef);
|
public void deleteChildRelationship(ChildAssociationRef relationshipRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the index for a store
|
||||||
|
* @param storeRef
|
||||||
|
*/
|
||||||
|
public void deleteIndex(StoreRef storeRef);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@ package org.alfresco.repo.search;
|
|||||||
import org.alfresco.repo.service.StoreRedirectorProxyFactory;
|
import org.alfresco.repo.service.StoreRedirectorProxyFactory;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||||
import org.springframework.context.ApplicationEvent;
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
@@ -102,4 +103,13 @@ public class IndexerComponent extends AbstractLifecycleBean implements Indexer
|
|||||||
indexer.deleteChildRelationship(relationshipRef);
|
indexer.deleteChildRelationship(relationshipRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.search.Indexer#deleteIndex(org.alfresco.service.cmr.repository.StoreRef)
|
||||||
|
*/
|
||||||
|
public void deleteIndex(StoreRef storeRef)
|
||||||
|
{
|
||||||
|
Indexer indexer = indexerAndSearcherFactory.getIndexer(storeRef);
|
||||||
|
indexer.deleteIndex(storeRef);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ package org.alfresco.repo.search.impl;
|
|||||||
import org.alfresco.repo.search.Indexer;
|
import org.alfresco.repo.search.Indexer;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A no action indexer - the indexing is done automatically along with
|
* A no action indexer - the indexing is done automatically along with
|
||||||
@@ -64,4 +65,12 @@ public class NoActionIndexer implements Indexer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.search.Indexer#deleteIndex(org.alfresco.service.cmr.repository.StoreRef)
|
||||||
|
*/
|
||||||
|
public void deleteIndex(StoreRef storeRef)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1697,4 +1697,12 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.search.Indexer#deleteIndex(org.alfresco.service.cmr.repository.StoreRef)
|
||||||
|
*/
|
||||||
|
public void deleteIndex(StoreRef storeRef)
|
||||||
|
{
|
||||||
|
deleteIndex();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1588,7 +1588,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return isSynchronousSnapshotPresent(store, id) || isSynchronousSnapshotPresent(store, id);
|
return isSynchronousSnapshotPresent(store, id) || isAsynchronousSnapshotPresent(store, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2106,4 +2106,13 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.search.Indexer#deleteIndex(org.alfresco.service.cmr.repository.StoreRef)
|
||||||
|
*/
|
||||||
|
public void deleteIndex(StoreRef storeRef)
|
||||||
|
{
|
||||||
|
deleteIndex();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -338,6 +338,11 @@ public abstract class AbstractLuceneBase
|
|||||||
return indexInfo.doWithWriteLock(lockWork);
|
return indexInfo.doWithWriteLock(lockWork);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void deleteIndex()
|
||||||
|
{
|
||||||
|
indexInfo.delete(deltaId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -355,6 +355,81 @@ public class IndexInfo implements IndexMonitor
|
|||||||
// We do not require any of the lucene in-built locking.
|
// We do not require any of the lucene in-built locking.
|
||||||
FSDirectory.setDisableLocks(true);
|
FSDirectory.setDisableLocks(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void delete(final String deltaId)
|
||||||
|
{
|
||||||
|
|
||||||
|
getWriteLock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
doWithFileLock(new LockWork<Object>()
|
||||||
|
{
|
||||||
|
public Object doWork() throws Exception
|
||||||
|
{
|
||||||
|
setStatusFromFile();
|
||||||
|
|
||||||
|
// If the index is not shared we can do some easy clean
|
||||||
|
// up
|
||||||
|
if (!indexIsShared)
|
||||||
|
{
|
||||||
|
HashSet<String> deletable = new HashSet<String>();
|
||||||
|
// clean up
|
||||||
|
for (IndexEntry entry : indexEntries.values())
|
||||||
|
{
|
||||||
|
if(!entry.getName().equals(deltaId))
|
||||||
|
{
|
||||||
|
entry.setStatus(TransactionStatus.DELETABLE);
|
||||||
|
deletable.add(entry.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Delete entries that are not required
|
||||||
|
for (String id : deletable)
|
||||||
|
{
|
||||||
|
indexEntries.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
clearOldReaders();
|
||||||
|
|
||||||
|
cleaner.schedule();
|
||||||
|
|
||||||
|
merger.schedule();
|
||||||
|
|
||||||
|
// persist the new state
|
||||||
|
writeStatus();
|
||||||
|
|
||||||
|
if (mainIndexReader != null)
|
||||||
|
{
|
||||||
|
if (s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("... invalidating main index reader");
|
||||||
|
}
|
||||||
|
((ReferenceCounting) mainIndexReader).setInvalidForReuse();
|
||||||
|
mainIndexReader = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canRetry()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
releaseWriteLock();
|
||||||
|
}
|
||||||
|
if(s_logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
s_logger.debug("Index "+ indexDirectory+" deleted");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the IndexInfo object based in the given directory. There is only one object per directory per JVM.
|
* Get the IndexInfo object based in the given directory. There is only one object per directory per JVM.
|
||||||
|
Reference in New Issue
Block a user