use of com.evolveum.midpoint.repo.common.activity.run.buckets.GetBucketOperationOptions in project midpoint by Evolveum.
the class IterativeActivityRun method getWorkBucket.
private WorkBucketType getWorkBucket(boolean initialRun, OperationResult result) throws ActivityRunException {
RunningTask task = taskRun.getRunningTask();
Holder<BucketProgressOverviewType> bucketProgressHolder = new Holder<>();
WorkBucketType bucket;
try {
GetBucketOperationOptions options = GetBucketOperationOptionsBuilder.anOptions().withDistributionDefinition(activity.getDefinition().getDistributionDefinition()).withFreeBucketWaitTime(FREE_BUCKET_WAIT_TIME).withCanRun(task::canRun).withExecuteInitialWait(initialRun).withImplicitSegmentationResolver(this).withIsScavenger(isScavenger(task)).withBucketProgressConsumer(bucketProgressHolder).build();
bucket = beans.bucketingManager.getWorkBucket(bucketingSituation.coordinatorTaskOid, bucketingSituation.workerTaskOid, activity.getPath(), options, getLiveBucketManagementStatistics(), result);
// We want to have the most current state of the running task.
task.refresh(result);
} catch (InterruptedException e) {
LOGGER.trace("InterruptedExecution in getWorkBucket for {}", task);
if (!task.canRun()) {
return null;
} else {
LoggingUtils.logUnexpectedException(LOGGER, "Unexpected InterruptedException in {}", e, task);
throw new SystemException("Unexpected InterruptedException: " + e.getMessage(), e);
}
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't allocate a work bucket for task {}", t, task);
throw new SystemException("Couldn't allocate a work bucket for task: " + t.getMessage(), t);
}
announceNumberOfBuckets(bucketProgressHolder.getValue(), result);
return bucket;
}
Aggregations