Search in sources :

Example 1 with WorkersReconciliationOptions

use of com.evolveum.midpoint.repo.common.activity.run.distribution.WorkersReconciliationOptions in project midpoint by Evolveum.

the class TaskActivityManager method reconcileWorkersForActivity.

/**
 * Note: common exceptions are not propagated - these are reflected only in the operation result
 */
@NotNull
private WorkersReconciliationResultType reconcileWorkersForActivity(@NotNull Task rootTask, @NotNull TaskType coordinatorTaskBean, @NotNull ActivityPath path, OperationResult parentResult) {
    OperationResult result = parentResult.subresult(OP_RECONCILE_WORKERS_FOR_ACTIVITY).addArbitraryObjectAsParam("rootTask", rootTask).addParam("coordinatorTask", coordinatorTaskBean).addArbitraryObjectAsParam("path", path).build();
    try {
        Task coordinatorTask = taskManager.createTaskInstance(coordinatorTaskBean.asPrismObject(), result);
        WorkersReconciliationOptions options = new WorkersReconciliationOptions();
        // TODO
        options.setDontCloseWorkersWhenWorkDone(true);
        return new WorkersReconciliation(rootTask, coordinatorTask, path, options, beans).execute(result);
    } catch (CommonException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't reconcile workers for activity path '{}' in {}/{}", e, path, coordinatorTaskBean, rootTask);
        result.recordFatalError(e);
        return new WorkersReconciliationResultType(prismContext).status(OperationResultStatusType.FATAL_ERROR);
    } catch (Throwable t) {
        result.recordFatalError(t);
        throw t;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) WorkersReconciliation(com.evolveum.midpoint.repo.common.activity.run.distribution.WorkersReconciliation) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) WorkersReconciliationOptions(com.evolveum.midpoint.repo.common.activity.run.distribution.WorkersReconciliationOptions) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with WorkersReconciliationOptions

use of com.evolveum.midpoint.repo.common.activity.run.distribution.WorkersReconciliationOptions in project midpoint by Evolveum.

the class DistributingActivityRun method createSuspendedChildren.

private List<Task> createSuspendedChildren(OperationResult result) throws ActivityRunException {
    try {
        WorkersReconciliationOptions options = new WorkersReconciliationOptions();
        options.setCreateSuspended(true);
        options.setDontCloseWorkersWhenWorkDone(true);
        WorkersReconciliation workersReconciliation = new WorkersReconciliation(getRunningTask().getRootTask(), getRunningTask(), getActivityPath(), options, getBeans());
        workersReconciliation.execute(result);
        return workersReconciliation.getCurrentWorkers(result);
    } catch (CommonException e) {
        throw new ActivityRunException("Couldn't create/update activity children (workers)", FATAL_ERROR, PERMANENT_ERROR, e);
    }
}
Also used : WorkersReconciliation(com.evolveum.midpoint.repo.common.activity.run.distribution.WorkersReconciliation) CommonException(com.evolveum.midpoint.util.exception.CommonException) WorkersReconciliationOptions(com.evolveum.midpoint.repo.common.activity.run.distribution.WorkersReconciliationOptions)

Aggregations

WorkersReconciliation (com.evolveum.midpoint.repo.common.activity.run.distribution.WorkersReconciliation)2 WorkersReconciliationOptions (com.evolveum.midpoint.repo.common.activity.run.distribution.WorkersReconciliationOptions)2 CommonException (com.evolveum.midpoint.util.exception.CommonException)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 NotNull (org.jetbrains.annotations.NotNull)1