ALF-10419:

o performance improvements: disable/enable auditing behaviour per-transaction rather than per-node
o add "disable rules" checkbox to GUI and support disabling of rules during import

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31243 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Steven Glover
2011-10-14 16:29:01 +00:00
parent bf7bc0b732
commit 50bd59630e
5 changed files with 59 additions and 20 deletions

View File

@@ -67,6 +67,7 @@
<property name="permissionService" ref="permissionService" /> <property name="permissionService" ref="permissionService" />
<property name="jobLockService" ref="jobLockService"/> <property name="jobLockService" ref="jobLockService"/>
<property name="behaviourFilter" ref="policyBehaviourFilter" /> <property name="behaviourFilter" ref="policyBehaviourFilter" />
<property name="ruleService" ref="ruleService" />
<property name="directoryAnalyser" ref="bfsiDirectoryAnalyser" /> <property name="directoryAnalyser" ref="bfsiDirectoryAnalyser" />
<property name="importStatus" ref="bfsiStatus" /> <property name="importStatus" ref="bfsiStatus" />

View File

@@ -41,8 +41,7 @@ public interface BulkFilesystemImporter
* @param source The source directory on the local filesystem to read content from <i>(must not be null and must be a valid, readable directory on the local filesystem)</i>. * @param source The source directory on the local filesystem to read content from <i>(must not be null and must be a valid, readable directory on the local filesystem)</i>.
* @param replaceExisting A flag indicating whether to replace (true) or skip (false) files that are already in the repository. * @param replaceExisting A flag indicating whether to replace (true) or skip (false) files that are already in the repository.
*/ */
// void bulkImport(NodeRef target, NodeImporter importStrategy, boolean replaceExisting); void bulkImport(BulkImportParameters bulkImportParameters, NodeImporter nodeImporter);
public void bulkImport(BulkImportParameters bulkImportParameters, NodeImporter nodeImporter);
/** /**
* Initiates a bulk filesystem import asynchronously i.e. in a background thread. * Initiates a bulk filesystem import asynchronously i.e. in a background thread.
@@ -52,8 +51,7 @@ public interface BulkFilesystemImporter
* @param source The source directory on the local filesystem to read content from <i>(must not be null and must be a valid, readable directory on the local filesystem)</i>. * @param source The source directory on the local filesystem to read content from <i>(must not be null and must be a valid, readable directory on the local filesystem)</i>.
* @param replaceExisting A flag indicating whether to replace (true) or skip (false) files that are already in the repository. * @param replaceExisting A flag indicating whether to replace (true) or skip (false) files that are already in the repository.
*/ */
// void asyncBulkImport(NodeRef target, NodeImporter nodeImporter, boolean replaceExisting); void asyncBulkImport(BulkImportParameters bulkImportParameters, NodeImporter nodeImporter);
public void asyncBulkImport(BulkImportParameters bulkImportParameters, NodeImporter nodeImporter);
/** /**
* @return A status object that describes the current state of the bulk filesystem importer. * @return A status object that describes the current state of the bulk filesystem importer.

View File

@@ -5,11 +5,20 @@ import org.alfresco.service.cmr.repository.NodeRef;
public class BulkImportParameters public class BulkImportParameters
{ {
private NodeRef target; private NodeRef target;
private boolean replaceExisting; private boolean replaceExisting = false;
private Integer batchSize; private Integer batchSize;
private Integer numThreads; private Integer numThreads;
private Integer loggingInterval; private Integer loggingInterval;
private boolean disableRulesService = false;
public boolean isDisableRulesService()
{
return disableRulesService;
}
public void setDisableRulesService(boolean disableRulesService)
{
this.disableRulesService = disableRulesService;
}
public Integer getLoggingInterval() public Integer getLoggingInterval()
{ {
return loggingInterval; return loggingInterval;

View File

@@ -47,6 +47,7 @@ import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException; import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
@@ -76,6 +77,7 @@ public abstract class AbstractBulkFilesystemImporter implements BulkFilesystemIm
protected TransactionService transactionService; protected TransactionService transactionService;
protected PermissionService permissionService; protected PermissionService permissionService;
protected RetryingTransactionHelper transactionHelper; protected RetryingTransactionHelper transactionHelper;
protected RuleService ruleService;
protected BulkImportStatusImpl importStatus; protected BulkImportStatusImpl importStatus;
protected DirectoryAnalyser directoryAnalyser = null; protected DirectoryAnalyser directoryAnalyser = null;
@@ -84,6 +86,11 @@ public abstract class AbstractBulkFilesystemImporter implements BulkFilesystemIm
protected BehaviourFilter behaviourFilter; protected BehaviourFilter behaviourFilter;
public void setRuleService(RuleService ruleService)
{
this.ruleService = ruleService;
}
public void setBehaviourFilter(BehaviourFilter behaviourFilter) public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{ {
this.behaviourFilter = behaviourFilter; this.behaviourFilter = behaviourFilter;

View File

@@ -32,6 +32,7 @@ import org.alfresco.repo.bulkimport.BulkImportParameters;
import org.alfresco.repo.bulkimport.FilesystemTracker; import org.alfresco.repo.bulkimport.FilesystemTracker;
import org.alfresco.repo.bulkimport.ImportableItem; import org.alfresco.repo.bulkimport.ImportableItem;
import org.alfresco.repo.bulkimport.NodeImporter; import org.alfresco.repo.bulkimport.NodeImporter;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -65,10 +66,16 @@ public abstract class MultiThreadedBulkFilesystemImporter extends AbstractBulkFi
return bulkImportParameters.getNumThreads() != null ? bulkImportParameters.getNumThreads() : defaultNumThreads; return bulkImportParameters.getNumThreads() != null ? bulkImportParameters.getNumThreads() : defaultNumThreads;
} }
protected void handleRuleService(final BulkImportParameters bulkImportParameters)
{
}
protected BatchProcessor.BatchProcessWorker<ImportableItem> getWorker(final BulkImportParameters bulkImportParameters, final String lockToken, protected BatchProcessor.BatchProcessWorker<ImportableItem> getWorker(final BulkImportParameters bulkImportParameters, final String lockToken,
final NodeImporter nodeImporter, final FilesystemTracker filesystemTracker) final NodeImporter nodeImporter, final FilesystemTracker filesystemTracker)
{ {
final int batchSize = bulkImportParameters.getBatchSize() != null ? bulkImportParameters.getBatchSize() : defaultBatchSize; final int batchSize = bulkImportParameters.getBatchSize() != null ? bulkImportParameters.getBatchSize() : defaultBatchSize;
final boolean rulesEnabled = ruleService.isEnabled();
BatchProcessor.BatchProcessWorker<ImportableItem> worker = new BatchProcessor.BatchProcessWorker<ImportableItem>() BatchProcessor.BatchProcessWorker<ImportableItem> worker = new BatchProcessor.BatchProcessWorker<ImportableItem>()
{ {
@@ -80,30 +87,47 @@ public abstract class MultiThreadedBulkFilesystemImporter extends AbstractBulkFi
public void beforeProcess() throws Throwable public void beforeProcess() throws Throwable
{ {
refreshLock(lockToken, batchSize * 250L); refreshLock(lockToken, batchSize * 250L);
// TODO this throws exception txn not started?? if(bulkImportParameters.isDisableRulesService() && rulesEnabled)
{
ruleService.disableRules();
}
// Disable the auditable aspect's behaviours for this transaction only, to allow creation & modification dates to be set // Disable the auditable aspect's behaviours for this transaction only, to allow creation & modification dates to be set
//behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE); transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
return null;
}
});
} }
public void afterProcess() throws Throwable public void afterProcess() throws Throwable
{ {
if(bulkImportParameters.isDisableRulesService() && rulesEnabled)
{
ruleService.enableRules();
}
importStatus.incrementNumberOfBatchesCompleted(); importStatus.incrementNumberOfBatchesCompleted();
//behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
return null;
}
});
} }
public void process(final ImportableItem importableItem) throws Throwable public void process(final ImportableItem importableItem) throws Throwable
{ {
try NodeRef nodeRef = nodeImporter.importImportableItem(importableItem, bulkImportParameters.isReplaceExisting());
{ filesystemTracker.itemImported(nodeRef, importableItem);
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
NodeRef nodeRef = nodeImporter.importImportableItem(importableItem, bulkImportParameters.isReplaceExisting());
filesystemTracker.itemImported(nodeRef, importableItem);
// importableItem.setNodeRef(nodeRef);
}
finally
{
behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
}
} }
}; };