本文整理汇总了Java中org.alfresco.repo.batch.BatchProcessor类的典型用法代码示例。如果您正苦于以下问题:Java BatchProcessor类的具体用法?Java BatchProcessor怎么用?Java BatchProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BatchProcessor类属于org.alfresco.repo.batch包,在下文中一共展示了BatchProcessor类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: bulkImportImpl
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
/**
* Method that does the work of importing a filesystem using the BatchProcessor.
*
* @param bulkImportParameters The bulk import parameters to apply to this bulk import.
* @param nodeImporter The node importer implementation that will import each node.
* @param lockToken The lock token to use during the bulk import.
*/
@Override
protected void bulkImportImpl(final BulkImportParameters bulkImportParameters, final NodeImporter nodeImporter, final String lockToken)
{
super.bulkImportImpl(bulkImportParameters, nodeImporter, lockToken);
final File sourceFolder = nodeImporter.getSourceFolder();
final int batchSize = getBatchSize(bulkImportParameters);
final int loggingInterval = getLoggingInterval(bulkImportParameters);
final StripingFilesystemTracker tracker = new StripingFilesystemTracker(directoryAnalyser, bulkImportParameters.getTarget(), sourceFolder, batchSize);
final BatchProcessor<ImportableItem> batchProcessor = getBatchProcessor(bulkImportParameters, tracker.getWorkProvider(), loggingInterval);
final BatchProcessor.BatchProcessWorker<ImportableItem> worker = getWorker(bulkImportParameters, lockToken, nodeImporter, tracker);
do
{
batchProcessor.process(worker, true);
if(batchProcessor.getLastError() != null)
{
throw new AlfrescoRuntimeException(batchProcessor.getLastError());
}
}
while(tracker.moreLevels());
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:StripingBulkFilesystemImporter.java
示例2: execute
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
@Override
protected int execute() throws ToolException
{
// Used for ability to be final and have a set
final AtomicInteger status = new AtomicInteger(0);
BatchProcessWorker<User> worker = new BatchProcessWorkerAdaptor<User>()
{
public void process(final User user) throws Throwable
{
RunAsWork<Void> runAsWork = new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
try
{
renameUser(user.getOldUsername(), user.getNewUsername());
}
catch (Throwable t)
{
status.set(handleError(t));
}
return null;
}
};
AuthenticationUtil.runAs(runAsWork, context.getUsername());
}
};
// Use 2 threads, 20 User objects per transaction. Log every 100 entries.
BatchProcessor<User> processor = new BatchProcessor<User>(
"HomeFolderProviderSynchronizer",
getServiceRegistry().getTransactionService().getRetryingTransactionHelper(),
new WorkProvider(context),
2, 20,
null,
logger, 100);
processor.process(worker, true);
return status.get();
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:43,代码来源:RenameUser.java
示例3: getBatchProcessor
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
protected BatchProcessor<ImportableItem> getBatchProcessor(final BulkImportParameters bulkImportParameters,
final BatchProcessWorkProvider<ImportableItem> workProvider, final int loggingInterval)
{
final int numThreads = getNumThreads(bulkImportParameters);
final int batchSize = getBatchSize(bulkImportParameters);
importStatus.setNumThreads(numThreads);
importStatus.setBatchSize(batchSize);
BatchProcessor<ImportableItem> batchProcessor = new BatchProcessor<ImportableItem>(
"Bulk Filesystem Import",
transactionHelper,
workProvider,
numThreads, batchSize,
applicationContext,
logger, loggingInterval);
return batchProcessor;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:MultiThreadedBulkFilesystemImporter.java
示例4: doWork
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
/**
* @param progress the thread-safe progress
*/
private synchronized void doWork(NodeStringLengthWorkResult progress) throws Exception
{
// Build batch processor
BatchProcessWorkProvider<NodePropertyEntity> workProvider = new NodeStringLengthWorkProvider(progress);
BatchProcessWorker<NodePropertyEntity> worker = new NodeStringLengthBatch(progress);
RetryingTransactionHelper retryingTransactionHelper = transactionService.getRetryingTransactionHelper();
retryingTransactionHelper.setForceWritable(true);
BatchProcessor<NodePropertyEntity> batchProcessor = new BatchProcessor<NodePropertyEntity>(
"NodeStringLengthWorker",
retryingTransactionHelper,
workProvider,
threadCount,
batchSize,
ctx,
logger,
1000);
batchProcessor.process(worker, true);
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:NodeStringLengthWorker.java
示例5: processGroupAssociationCreation
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
protected void processGroupAssociationCreation(final String batchId, final Analyzer groupAnalyzer, final boolean splitTxns)
{
final Map<String, Set<String>> groupParentsToAdd = groupAnalyzer.getGroupParentsToAdd();
final Collection<String> groupsToProcess = new HashSet<>(groupParentsToAdd.keySet());
if (!groupsToProcess.isEmpty())
{
@SuppressWarnings("deprecation")
final BatchProcessor<String> groupProcessor = new BatchProcessor<>(SyncProcess.GROUP_ASSOCIATION_CREATION.getTitle(batchId),
this.transactionService.getRetryingTransactionHelper(), groupsToProcess, this.workerThreads,
USER_REGISTRY_ENTITY_BATCH_SIZE, this.applicationEventPublisher,
LogFactory.getLog(TenantAwareChainingUserRegistrySynchronizer.class), this.loggingInterval);
final GroupParentAdditionWorker worker = new GroupParentAdditionWorker(groupParentsToAdd, this.createComponentLookupCallback());
groupProcessor.process(worker, splitTxns);
}
}
开发者ID:Acosix,项目名称:alfresco-mt-support,代码行数:19,代码来源:TenantAwareChainingUserRegistrySynchronizer.java
示例6: processUserAssociation
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
protected void processUserAssociation(final String batchId, final Analyzer groupAnalyzer, final boolean splitTxns)
{
final Map<String, Set<String>> userParentsToAdd = groupAnalyzer.getUserParentsToAdd();
final Map<String, Set<String>> userParentsToRemove = groupAnalyzer.getUserParentsToRemove();
final Collection<String> usersToProcess = new HashSet<>(userParentsToRemove.keySet());
usersToProcess.addAll(userParentsToAdd.keySet());
if (!usersToProcess.isEmpty())
{
@SuppressWarnings("deprecation")
final BatchProcessor<String> userProcessor = new BatchProcessor<>(SyncProcess.USER_ASSOCIATION.getTitle(batchId),
this.transactionService.getRetryingTransactionHelper(), usersToProcess, this.workerThreads,
USER_REGISTRY_ENTITY_BATCH_SIZE, this.applicationEventPublisher,
LogFactory.getLog(TenantAwareChainingUserRegistrySynchronizer.class), this.loggingInterval);
final UserParentWorker worker = new UserParentWorker(userParentsToAdd, userParentsToRemove,
this.createComponentLookupCallback());
userProcessor.process(worker, splitTxns);
}
}
开发者ID:Acosix,项目名称:alfresco-mt-support,代码行数:22,代码来源:TenantAwareChainingUserRegistrySynchronizer.java
示例7: doWork
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
/**
* @param progress the thread-safe progress
*/
private synchronized void doWork(UpgradePasswordHashWorkResult progress) throws Exception
{
// Build batch processor
BatchProcessWorkProvider<Long> workProvider = new UpgradePasswordHashWorkProvider(progress);
BatchProcessWorker<Long> worker = new UpgradePasswordHashBatch(progress);
RetryingTransactionHelper retryingTransactionHelper = transactionService.getRetryingTransactionHelper();
retryingTransactionHelper.setForceWritable(true);
//Create the QNames if they don't exist
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
qnameDAO.getOrCreateQName(ContentModel.PROP_PASSWORD_HASH);
qnameDAO.getOrCreateQName(ContentModel.PROP_HASH_INDICATOR);
return null;
}
}, false, true);
BatchProcessor<Long> batchProcessor = new BatchProcessor<Long>(
"UpgradePasswordHashWorker",
retryingTransactionHelper,
workProvider,
threadCount,
batchSize,
ctx,
logger,
1000);
batchProcessor.process(worker, true);
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:35,代码来源:UpgradePasswordHashWorker.java
示例8: purgeAllArchivedNodes
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
/**
* Uses batch processing and job locking to purge all archived nodes
*/
public void purgeAllArchivedNodes(StoreRef originalStoreRef)
{
final String user = AuthenticationUtil.getFullyAuthenticatedUser();
if (user == null)
{
throw new IllegalStateException("Cannot purge as there is no authenticated user.");
}
/**
* Worker that purges each node
*/
BatchProcessWorker<NodeRef> worker = new BatchProcessor.BatchProcessWorkerAdaptor<NodeRef>()
{
@Override
public void beforeProcess() throws Throwable
{
AuthenticationUtil.pushAuthentication();
}
public void process(NodeRef nodeRef) throws Throwable
{
AuthenticationUtil.setFullyAuthenticatedUser(user);
if (nodeService.exists(nodeRef))
{
invokeBeforePurgeNode(nodeRef);
nodeService.deleteNode(nodeRef);
}
}
@Override
public void afterProcess() throws Throwable
{
AuthenticationUtil.popAuthentication();
}
};
doBulkOperation(user, originalStoreRef, worker);
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:39,代码来源:NodeArchiveServiceImpl.java
示例9: execute
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
public int execute()
{
String lockToken = null;
FixedAclUpdaterJobLockRefreshCallback jobLockRefreshCallback = new FixedAclUpdaterJobLockRefreshCallback();
try
{
lockToken = jobLockService.getLock(lockQName, lockTimeToLive, 0, 1);
jobLockService.refreshLock(lockToken, lockQName, lockRefreshTime, jobLockRefreshCallback);
AclWorkProvider provider = new AclWorkProvider();
AclWorker worker = new AclWorker();
BatchProcessor<NodeRef> bp = new BatchProcessor<>(
"FixedAclUpdater",
transactionService.getRetryingTransactionHelper(),
provider,
numThreads, maxItemBatchSize,
applicationContext,
log, 100);
int count = bp.process(worker, true);
return count;
}
catch (LockAcquisitionException e)
{
// already running
return 0;
}
finally
{
jobLockRefreshCallback.isActive.set(false);
if(lockToken != null)
{
jobLockService.releaseLock(lockToken, lockQName);
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:FixedAclUpdater.java
示例10: queryAuditUsers
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
protected List<AuditUserInfo> queryAuditUsers(final long fromTime, final int workerThreads, final int batchSize,
final int loggingInterval)
{
final PersonAuditWorker personAuditWorker = new PersonAuditWorker(fromTime, this.queryActiveUsers);
final BatchProcessor<NodeRef> processor = new BatchProcessor<>(AuditUserGet.class.getName(),
this.transactionService.getRetryingTransactionHelper(),
new PersonBatchWorkProvider(this.namespaceService, this.nodeService, this.personService, this.searchService), workerThreads,
batchSize, null, LogFactory.getLog(AuditUserGet.class), loggingInterval);
processor.process(personAuditWorker, true);
final List<AuditUserInfo> activeUsers = new ArrayList<>(personAuditWorker.getUsers());
Collections.sort(activeUsers);
return activeUsers;
}
开发者ID:Acosix,项目名称:alfresco-audit,代码行数:15,代码来源:AuditUserGet.java
示例11: processGroupCreationAndAssociationDeletion
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
protected void processGroupCreationAndAssociationDeletion(final String id, final String batchId, final Analyzer groupAnalyzer,
final boolean splitTxns)
{
final Map<String, String> groupsToCreate = groupAnalyzer.getGroupsToCreate();
final Map<String, Set<String>> groupParentsToRemove = groupAnalyzer.getGroupParentsToRemove();
final Collection<String> groupsToProcess = new HashSet<>(groupsToCreate.keySet());
groupsToProcess.addAll(groupParentsToRemove.keySet());
if (!groupsToProcess.isEmpty())
{
@SuppressWarnings("deprecation")
final BatchProcessor<String> groupProcessor = new BatchProcessor<>(
SyncProcess.GROUP_CREATION_AND_ASSOCIATION_DELETION.getTitle(batchId),
this.transactionService.getRetryingTransactionHelper(), groupsToProcess, this.workerThreads,
USER_REGISTRY_ENTITY_BATCH_SIZE, this.applicationEventPublisher,
LogFactory.getLog(TenantAwareChainingUserRegistrySynchronizer.class), this.loggingInterval);
final String zoneId = asZoneId(id);
final Set<String> zones = new HashSet<>();
zones.add(AuthorityService.ZONE_APP_DEFAULT);
zones.add(zoneId);
final GroupCreationAndParentRemovalWorker worker = new GroupCreationAndParentRemovalWorker(zones, groupsToCreate,
groupParentsToRemove, this.createComponentLookupCallback());
groupProcessor.process(worker, splitTxns);
}
}
开发者ID:Acosix,项目名称:alfresco-mt-support,代码行数:28,代码来源:TenantAwareChainingUserRegistrySynchronizer.java
示例12: restoreAllArchivedNodes
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
/**
* Uses batch processing and job locking to purge all archived nodes
*
* @deprecated In 3.4: to be removed
*/
public List<RestoreNodeReport> restoreAllArchivedNodes(StoreRef originalStoreRef)
{
final String user = AuthenticationUtil.getFullyAuthenticatedUser();
if (user == null)
{
throw new IllegalStateException("Cannot restore as there is no authenticated user.");
}
final List<RestoreNodeReport> results = Collections.synchronizedList(new ArrayList<RestoreNodeReport>(1000));
/**
* Worker that restores each node
*/
BatchProcessWorker<NodeRef> worker = new BatchProcessor.BatchProcessWorkerAdaptor<NodeRef>()
{
@Override
public void beforeProcess() throws Throwable
{
AuthenticationUtil.pushAuthentication();
}
public void process(NodeRef entry) throws Throwable
{
AuthenticationUtil.setFullyAuthenticatedUser(user);
if (nodeService.exists(entry))
{
RestoreNodeReport report = restoreArchivedNode(entry);
// Append the results (it is synchronized)
results.add(report);
}
}
@Override
public void afterProcess() throws Throwable
{
AuthenticationUtil.popAuthentication();
}
};
doBulkOperation(user, originalStoreRef, worker);
return results;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:44,代码来源:NodeArchiveServiceImpl.java
示例13: process
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
/**
* process the given processorfunction on a set of nodes which are the
* result of the provided luceneQuery. The processing takes place in a de.jgoldhammer.alfresco.jscript.batch
* processor with the given batchName, the number of workerthreads and the
* number of nodes as batchsize.
*
* @param batchName
* the name of the de.jgoldhammer.alfresco.jscript.batch
* @param workerThreads
* the number of threads which can be used for the de.jgoldhammer.alfresco.jscript.batch
* processing
* @param batchSize
* size of the batch
* @param luceneQuery
* the lucene query to execute to make the processing on the
* nodes of the resultset
* @param processorFunction
* the javascript function to process- the function must have the
* named "process"
*
* Example:
* de.jgoldhammer.alfresco.jscript.batch.runForQuery('MyProcessor',4,10,'TEXT:alfresco',function
* process(node){ logger.error(node); }, true);
* @param runAsSystem
* true if the processing should be run as system, false to
* process as the current user
* @param beforeProcessFunction
* the function to run before the processing
* @param afterProcessFunction
* the function to run after the processing
*
*/
@ScriptMethod(code = "batch.run('MyProcessor',4,10,'TEXT:alfresco',function process(node){logger.error(node);}, true);", help = "", output = "nothing", type = ScriptMethodType.WRITE)
public void runForQuery(String batchName, int workerThreads, final int batchSize, final String luceneQuery,
final String processorFunction, final boolean runAsSystem, final String beforeProcessFunction,
final String afterProcessFunction) {
final SearchParameters params = new SearchParameters();
params.setLimitBy(LimitBy.UNLIMITED);
params.setLanguage(SearchService.LANGUAGE_LUCENE);
params.setQuery(luceneQuery);
params.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
final ResultSet searchResult = searchService.query(params);
BatchProcessor<Collection<NodeRef>> processor;
final Scriptable batchScope = this.scope;
try {
if (searchResult.length() != 0) {
searchResult.setBulkFetch(false);
processor = new BatchProcessor<>(batchName, transactionService.getRetryingTransactionHelper(),
new QueryResultBatchProcessWorkProvider(searchResult, batchSize), workerThreads, FIXED_BATCH_SIZE, null,
null, FIXED_BATCH_SIZE);
processor.process(
new ScriptedBatchProcessWorker(runAsSystem, batchScope, processorFunction, null, beforeProcessFunction,
afterProcessFunction, Context.getCurrentContext(), serviceRegistry, scriptService), true);
}
} finally {
searchResult.close();
}
}
开发者ID:jgoldhammer,项目名称:alfresco-jscript-extensions,代码行数:65,代码来源:BatchScriptFacade.java
示例14: executeBatch
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void executeBatch(final Scriptable scope, final Scriptable thisObj, final Collection<Object> workItems,
final Pair<Scriptable, Function> processCallback, final int threadCount, final int batchSize,
final Pair<Scriptable, Function> beforeProcessCallback, final Pair<Scriptable, Function> afterProcessCallback)
{
// TODO: parameter for logging interval
final Log log;
if (ScriptableObject.hasProperty(scope, "logger"))
{
final Object object = ScriptableObject.getProperty(scope, "logger");
if (object instanceof Scriptable)
{
log = new ScriptLoggerLog((Scriptable) object, this.scriptProcessor);
}
else
{
log = LogFactory.getLog(RepositoryExecuteBatchFunction.class);
}
}
else
{
log = LogFactory.getLog(RepositoryExecuteBatchFunction.class);
}
final BatchProcessor<Object> batchProcessor = new BatchProcessor<Object>("ScriptBatch",
this.transactionService.getRetryingTransactionHelper(), new CollectionBatchWorkProvider(workItems), Math.min(threadCount,
this.maxThreads), batchSize, null, log, 10);
final RepositoryExecuteBatchWorker worker = new RepositoryExecuteBatchWorker(this, scope, thisObj, processCallback,
beforeProcessCallback, afterProcessCallback, this.transactionManager);
batchProcessor.process(worker, true);
// TODO: result / status handling
}
开发者ID:AFaust,项目名称:alfresco-enhanced-script-environment,代码行数:38,代码来源:RepositoryExecuteBatchFunction.java
示例15: executeImpl
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, final Status status, final Cache cache)
{
final Map<String, Object> model = super.executeImpl(req, status, cache);
final Object users = model.get("users");
// some validation of our expectations
if (!(users instanceof List<?>))
{
throw new IllegalStateException("Model of base class web script contains an unexpected value for \"users\"");
}
((List<?>) users).forEach(userEntry -> {
if (!(userEntry instanceof Map<?, ?>))
{
throw new IllegalStateException("Model of base class web script contains an unexpected value as element of \"users\"");
}
final Object info = ((Map<?, ?>) userEntry).get("info");
if (!(info instanceof AuditUserInfo))
{
throw new IllegalStateException(
"Model of base class web script contains an unexpected value as \"info\" on element of \"users\"");
}
});
@SuppressWarnings("unchecked")
final List<Map<Object, Object>> userEntries = ((List<Map<Object, Object>>) users);
// can use the current transaction for the "before" count
model.put("authorisedUsersBefore", Long.valueOf(((AuthorizationService) this.authorisationService).getAuthorizedUsersCount()));
// though deauthorising a user should be a simple operation and not require changes affecting nodes, we still do it in batches
final PersonDeauthorisationWorker personDeauthorisationWorker = new PersonDeauthorisationWorker();
// needs to run single-threaded to try and avoid issues with authorisationService
// (observed quite a lot of update conflicts and inconsistent state in multi-threaded updates)
final BatchProcessor<Map<Object, Object>> processor = new BatchProcessor<>("DeauthoriseInactiveUsers",
this.transactionService.getRetryingTransactionHelper(), new PersonDeauthorisationWorkProvider(userEntries), 1,
this.batchSize, null, LogFactory.getLog(DeauthoriseInactiveUsers.class), this.loggingInterval);
processor.process(personDeauthorisationWorker, true);
model.put("deauthorised", Integer.valueOf(personDeauthorisationWorker.getDeauthorised()));
// need nested transaction for an "after" count
this.transactionService.getRetryingTransactionHelper().doInTransaction(() -> {
model.put("authorisedUsersAfter", Long.valueOf(((AuthorizationService) this.authorisationService).getAuthorizedUsersCount()));
return null;
}, true, true);
return model;
}
开发者ID:Acosix,项目名称:alfresco-deauth,代码行数:53,代码来源:DeauthoriseInactiveUsers.java
示例16: consolidateActiveUsersAudit
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
protected void consolidateActiveUsersAudit(final JobExecutionContext context, final RetryingTransactionHelper retryingTransactionHelper)
{
final AuditService auditService = JobUtilities.getJobDataValue(context, "auditService", AuditService.class);
final AuditComponent auditComponent = JobUtilities.getJobDataValue(context, "auditComponent", AuditComponent.class);
final NamespaceService namespaceService = JobUtilities.getJobDataValue(context, "namespaceService", NamespaceService.class);
final NodeService nodeService = JobUtilities.getJobDataValue(context, "nodeService", NodeService.class);
final PersonService personService = JobUtilities.getJobDataValue(context, "personService", PersonService.class);
final SearchService searchService = JobUtilities.getJobDataValue(context, "searchService", SearchService.class);
final String workerThreadsParam = JobUtilities.getJobDataValue(context, "workerThreads", String.class, true);
final String batchSizeParam = JobUtilities.getJobDataValue(context, "batchSize", String.class, true);
final String timeframeHoursParam = JobUtilities.getJobDataValue(context, "timeframeHours", String.class, true);
final int workerThreads = workerThreadsParam != null ? Math.min(1, Integer.parseInt(workerThreadsParam, 10)) : 4;
final int batchSize = batchSizeParam != null ? Math.min(1, Integer.parseInt(batchSizeParam, 10)) : 10;
final int timeframeHours = timeframeHoursParam != null ? Integer.parseInt(timeframeHoursParam, 10) : 1;
if (timeframeHours <= 0)
{
throw new IllegalArgumentException("timeframeHours must be a positive integer");
}
if (timeframeHours > 24)
{
throw new IllegalArgumentException("timeframeHours cannot be greater than a day of 24 hours");
}
if (24 % timeframeHours != 0)
{
throw new IllegalArgumentException("Number of hours in a day must be divisible by timeframeHours");
}
final BatchProcessor<NodeRef> processor = new BatchProcessor<>(ConsolidateActiveUsersAuditJob.class.getName(),
retryingTransactionHelper, new PersonBatchWorkProvider(namespaceService, nodeService, personService, searchService),
workerThreads, batchSize, null, LogFactory.getLog(ConsolidateActiveUsersAuditJob.class.getName() + ".batchProcessor"),
Math.max(25, workerThreads * batchSize * 2));
final PersonConsolidationAuditWorker worker = new PersonConsolidationAuditWorker(nodeService, auditService, auditComponent,
timeframeHours);
processor.process(worker, true);
}
开发者ID:Acosix,项目名称:alfresco-audit,代码行数:42,代码来源:ConsolidateActiveUsersAuditJob.java
示例17: doCleanup
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
protected void doCleanup(final JobExecutionContext context, final RetryingTransactionHelper retryingTransactionHelper,
final LockReleasedCheck lockReleaseCheck)
{
final AttributeService attributeService = JobUtilities.getJobDataValue(context, "attributeService", AttributeService.class);
final PropertyTablesCleanupDAO propertyTablesCleanupDAO = JobUtilities.getJobDataValue(context, "propertyTablesCleanupDAO",
PropertyTablesCleanupDAO.class);
final String batchSizeStr = JobUtilities.getJobDataValue(context, "batchSize", String.class);
final String idsPerWorkItemStr = JobUtilities.getJobDataValue(context, "idsPerWorkItem", String.class);
final String workerCountStr = JobUtilities.getJobDataValue(context, "workerCount", String.class);
final String checkItemsLimitStr = JobUtilities.getJobDataValue(context, "checkItemsLimit", String.class);
final int batchSize = Integer.parseInt(batchSizeStr, 10);
final int workerCount = Integer.parseInt(workerCountStr, 10);
final int idsPerWorkItem = Integer.parseInt(idsPerWorkItemStr, 10);
final int checkItemsLimit = Integer.parseInt(checkItemsLimitStr, 10);
final String simpleJobClassName = this.getClass().getSimpleName();
final Serializable attribute = attributeService.getAttribute(AuditModuleConstants.SERVICE_NAMESPACE, simpleJobClassName,
ATTR_LAST_ID);
final Long lastId = DefaultTypeConverter.INSTANCE.convert(Long.class, attribute);
this.getLogger().info(
"Running incremental cleanup from last ID {} with batchSize {}, workerCount {}, idsPerWorkrItem {} and checkItemsLimit {}",
lastId, batchSizeStr, workerCountStr, idsPerWorkItemStr, checkItemsLimitStr);
final EntryIdsWorkProvider workProvider = new EntryIdsWorkProvider(this, propertyTablesCleanupDAO, workerCount, batchSize,
idsPerWorkItem, checkItemsLimit, lastId);
final EntryIdsBatchWorker batchWorker = new EntryIdsBatchWorker(this, propertyTablesCleanupDAO);
final BatchProcessor<List<Long>> batchProcessor = new BatchProcessor<>(simpleJobClassName, retryingTransactionHelper, workProvider,
workerCount, batchSize, null, LogFactory.getLog(this.getClass().getName() + ".batchProcessor"),
Math.max(25, batchSize * workerCount * 2));
batchProcessor.process(batchWorker, true);
final Long newLastId = workProvider.getLastId();
final Long maxId = workProvider.getMaxId();
if (EqualsHelper.nullSafeEquals(lastId, newLastId) || EqualsHelper.nullSafeEquals(newLastId, maxId))
{
// just delete the attribute so next time we start from the beginning
attributeService.removeAttribute(AuditModuleConstants.SERVICE_NAMESPACE, simpleJobClassName, ATTR_LAST_ID);
}
else
{
// store the last ID so next time we start from there
attributeService.setAttribute(newLastId, AuditModuleConstants.SERVICE_NAMESPACE, simpleJobClassName, ATTR_LAST_ID);
}
this.getLogger().info("Completed incremental cleanup with last processed ID {} and deleted {} unused entries", newLastId,
batchWorker.getDeletedEntries());
}
开发者ID:Acosix,项目名称:alfresco-audit,代码行数:52,代码来源:IncrementalPropertyTableCleanupJob.java
示例18: processAuthorityDeletions
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
protected Pair<Integer, Integer> processAuthorityDeletions(final String id, final String batchId, final UserRegistry userRegistry,
final boolean isFullSync, final boolean splitTxns)
{
final String currentDomain = TenantUtil.getCurrentDomain();
final boolean allowDeletions = Boolean.TRUE.equals(
this.allowDeletions.get(TenantService.DEFAULT_DOMAIN.equals(currentDomain) ? TenantUtil.DEFAULT_TENANT : currentDomain));
final boolean syncDelete = Boolean.TRUE.equals(
this.syncDelete.get(TenantService.DEFAULT_DOMAIN.equals(currentDomain) ? TenantUtil.DEFAULT_TENANT : currentDomain));
final String zoneId = asZoneId(id);
final Set<String> groupsToDelete = new HashSet<>();
final Set<String> usersToDelete = new HashSet<>();
final Pair<Integer, Integer> counts = new Pair<>(Integer.valueOf(0), Integer.valueOf(0));
if (isFullSync)
{
final Set<String> allZoneGroups = new TreeSet<>();
final Set<String> allZoneUsers = this.personService.getUserNamesAreCaseSensitive() ? new TreeSet<>()
: new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
this.inReadOnlyTransaction(() -> {
allZoneGroups.addAll(this.authorityService.getAllAuthoritiesInZone(zoneId, AuthorityType.GROUP));
allZoneUsers.addAll(this.authorityService.getAllAuthoritiesInZone(zoneId, AuthorityType.USER));
return null;
}, splitTxns);
groupsToDelete.addAll(allZoneGroups);
groupsToDelete.removeAll(userRegistry.getGroupNames());
usersToDelete.addAll(allZoneUsers);
for (final String userName : userRegistry.getPersonNames())
{
final String domainUser;
final String primaryDomain = this.tenantService.getPrimaryDomain(userName);
if (!EqualsHelper.nullSafeEquals(primaryDomain, currentDomain))
{
domainUser = this.tenantService.getDomainUser(userName, currentDomain);
}
else
{
domainUser = userName;
}
usersToDelete.remove(domainUser);
}
final Set<String> authoritiesToDelete = new TreeSet<>();
authoritiesToDelete.addAll(groupsToDelete);
authoritiesToDelete.addAll(usersToDelete);
if (!authoritiesToDelete.isEmpty() && (allowDeletions || syncDelete))
{
@SuppressWarnings("deprecation")
final BatchProcessor<String> deletionProcessor = new BatchProcessor<>(SyncProcess.AUTHORITY_DELETION.getTitle(batchId),
this.transactionService.getRetryingTransactionHelper(), authoritiesToDelete, this.workerThreads,
USER_REGISTRY_ENTITY_BATCH_SIZE, this.applicationEventPublisher,
LogFactory.getLog(TenantAwareChainingUserRegistrySynchronizer.class), this.loggingInterval);
final AuthorityDeleter deleter = new AuthorityDeleter(zoneId, groupsToDelete, usersToDelete, allowDeletions,
this.createComponentLookupCallback());
deletionProcessor.process(deleter, splitTxns);
counts.setFirst(Integer.valueOf(usersToDelete.size()));
counts.setSecond(Integer.valueOf(groupsToDelete.size()));
}
}
return counts;
}
开发者ID:Acosix,项目名称:alfresco-mt-support,代码行数:68,代码来源:TenantAwareChainingUserRegistrySynchronizer.java
示例19: Runner
import org.alfresco.repo.batch.BatchProcessor; //导入依赖的package包/类
private Runner(BatchProcessor<Collection<NodeRef>> processor, ScriptedBatchProcessWorker scriptedBatchProcessWorker) {
this.processor = processor;
this.scriptedBatchProcessWorker = scriptedBatchProcessWorker;
}
开发者ID:jgoldhammer,项目名称:alfresco-jscript-extensions,代码行数:5,代码来源:BatchScriptFacade.java
注:本文中的org.alfresco.repo.batch.BatchProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论