Search in sources :

Example 6 with RunningTask

use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.

the class IterativeActivityRun method getRootTask.

@NotNull
protected final Task getRootTask(OperationResult result) throws SchemaException {
    String rootTaskOid = getRootTaskOid();
    RunningTask task = getRunningTask();
    if (task.getOid().equals(rootTaskOid)) {
        return task;
    } else {
        try {
            return beans.taskManager.getTaskPlain(rootTaskOid, result);
        } catch (ObjectNotFoundException e) {
            // This is quite unexpected so it can be rethrown as SystemException
            throw new SystemException("The root task was not found", e);
        }
    }
}
Also used : RunningTask(com.evolveum.midpoint.task.api.RunningTask) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with RunningTask

use of com.evolveum.midpoint.task.api.RunningTask 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;
}
Also used : RunningTask(com.evolveum.midpoint.task.api.RunningTask) Holder(com.evolveum.midpoint.util.Holder) GetBucketOperationOptions(com.evolveum.midpoint.repo.common.activity.run.buckets.GetBucketOperationOptions)

Example 8 with RunningTask

use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.

the class AsyncUpdateActivityRun method iterateOverItemsInBucket.

@Override
public void iterateOverItemsInBucket(OperationResult opResult) throws CommunicationException, ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException {
    AsyncUpdateEventHandler handler = (event, hResult) -> {
        SyncItemProcessingRequest<AsyncUpdateEvent> request = new SyncItemProcessingRequest<>(event, this);
        return coordinator.submit(request, hResult);
    };
    RunningTask runningTask = getRunningTask();
    ModelImplUtils.clearRequestee(runningTask);
    getModelBeans().provisioningService.processAsynchronousUpdates(resourceObjectClass.getCoords(), handler, runningTask, opResult);
}
Also used : ItemProcessingRequest(com.evolveum.midpoint.repo.common.activity.run.processing.ItemProcessingRequest) ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) com.evolveum.midpoint.repo.common.activity.run(com.evolveum.midpoint.repo.common.activity.run) RunningTask(com.evolveum.midpoint.task.api.RunningTask) ModelBeans(com.evolveum.midpoint.model.impl.ModelBeans) ResourceObjectClass(com.evolveum.midpoint.model.impl.sync.tasks.ResourceObjectClass) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) ResourceObjectShadowChangeDescription(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription) ModelImplUtils(com.evolveum.midpoint.model.impl.util.ModelImplUtils) SyncItemProcessingRequest(com.evolveum.midpoint.model.impl.sync.tasks.SyncItemProcessingRequest) NotNull(org.jetbrains.annotations.NotNull) AsyncUpdateEvent(com.evolveum.midpoint.provisioning.api.AsyncUpdateEvent) AsyncUpdateEventHandler(com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler) SyncItemProcessingRequest(com.evolveum.midpoint.model.impl.sync.tasks.SyncItemProcessingRequest) RunningTask(com.evolveum.midpoint.task.api.RunningTask) AsyncUpdateEventHandler(com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler)

Example 9 with RunningTask

use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.

the class AsyncUpdateActivityRun method beforeRun.

@Override
public void beforeRun(OperationResult result) throws ActivityRunException, CommonException {
    RunningTask runningTask = getRunningTask();
    ResourceObjectSetType resourceObjectSet = getResourceObjectSet();
    resourceObjectClass = getModelBeans().syncTaskHelper.getResourceObjectClassCheckingMaintenance(resourceObjectSet, runningTask, result);
}
Also used : RunningTask(com.evolveum.midpoint.task.api.RunningTask)

Example 10 with RunningTask

use of com.evolveum.midpoint.task.api.RunningTask in project midpoint by Evolveum.

the class LiveSyncActivityRun method beforeRun.

@Override
public void beforeRun(OperationResult result) throws ActivityRunException, CommonException {
    RunningTask runningTask = getRunningTask();
    ResourceObjectSetType resourceObjectSet = getResourceObjectSet();
    resourceObjectClass = getModelBeans().syncTaskHelper.getResourceObjectClassCheckingMaintenance(resourceObjectSet, runningTask, result);
}
Also used : RunningTask(com.evolveum.midpoint.task.api.RunningTask)

Aggregations

RunningTask (com.evolveum.midpoint.task.api.RunningTask)20 NotNull (org.jetbrains.annotations.NotNull)6 Task (com.evolveum.midpoint.task.api.Task)4 ActivityRunException (com.evolveum.midpoint.repo.common.activity.run.ActivityRunException)2 IterationItemInformation (com.evolveum.midpoint.schema.statistics.IterationItemInformation)2 IterativeOperationStartInfo (com.evolveum.midpoint.schema.statistics.IterativeOperationStartInfo)2 Operation (com.evolveum.midpoint.schema.statistics.Operation)2 CommonException (com.evolveum.midpoint.util.exception.CommonException)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ModelBeans (com.evolveum.midpoint.model.impl.ModelBeans)1 ResourceObjectClass (com.evolveum.midpoint.model.impl.sync.tasks.ResourceObjectClass)1 SyncItemProcessingRequest (com.evolveum.midpoint.model.impl.sync.tasks.SyncItemProcessingRequest)1 ModelImplUtils (com.evolveum.midpoint.model.impl.util.ModelImplUtils)1 Containerable (com.evolveum.midpoint.prism.Containerable)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 AsyncUpdateEvent (com.evolveum.midpoint.provisioning.api.AsyncUpdateEvent)1 AsyncUpdateEventHandler (com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler)1 ResourceObjectShadowChangeDescription (com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription)1