本文整理汇总了Java中org.alfresco.repo.batch.BatchProcessor类的典型用法代码示例。如果您正苦于以下问题:Java BatchProcessor类的具体用法?Java BatchProcessor怎么用?Java BatchProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BatchProcessor类属于org.alfresco.repo.batch包,在下文中一共展示了BatchProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
}
示例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;
}