Search in sources :

Example 6 with TaskQuartzImpl

use of com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl in project midpoint by Evolveum.

the class TaskStateManager method resumeTask.

public void resumeTask(String taskOid, OperationResult result) throws SchemaException, ObjectNotFoundException {
    TaskQuartzImpl task = taskRetriever.getTaskPlain(taskOid, result);
    resumeHelper.resumeTask(task, result);
}
Also used : TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl)

Example 7 with TaskQuartzImpl

use of com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl in project midpoint by Evolveum.

the class ResumeHelper method getOidsToResume.

@NotNull
private List<String> getOidsToResume(String rootTaskOid, OperationResult result) throws ObjectNotFoundException, SchemaException {
    TaskQuartzImpl root = taskRetriever.getTaskPlain(rootTaskOid, result);
    List<TaskQuartzImpl> subtasks = root.listSubtasksDeeply(true, result);
    List<String> oidsToResume = new ArrayList<>(subtasks.size() + 1);
    if (root.getSchedulingState() == TaskSchedulingStateType.SUSPENDED) {
        oidsToResume.add(rootTaskOid);
    }
    for (Task subtask : subtasks) {
        if (subtask.getSchedulingState() == TaskSchedulingStateType.SUSPENDED) {
            oidsToResume.add(subtask.getOid());
        }
    }
    return oidsToResume;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with TaskQuartzImpl

use of com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl in project midpoint by Evolveum.

the class SuspendAndDeleteHelper method getTasksToBeDeleted.

@NotNull
private List<TaskQuartzImpl> getTasksToBeDeleted(String taskOid, boolean alsoSubtasks, OperationResult result) throws ObjectNotFoundException, SchemaException {
    List<TaskQuartzImpl> tasksToBeDeleted = new ArrayList<>();
    TaskQuartzImpl thisTask = taskRetriever.getTaskPlain(taskOid, result);
    tasksToBeDeleted.add(thisTask);
    if (alsoSubtasks) {
        tasksToBeDeleted.addAll(thisTask.listSubtasksDeeply(true, result));
    }
    return tasksToBeDeleted;
}
Also used : TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with TaskQuartzImpl

use of com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl in project midpoint by Evolveum.

the class SuspendAndDeleteHelper method suspendTaskTree.

public boolean suspendTaskTree(String rootTaskOid, long waitTime, OperationResult result) throws SchemaException, ObjectNotFoundException {
    List<TaskQuartzImpl> allTasks = new ArrayList<>();
    TaskQuartzImpl root = taskRetriever.getTaskPlain(rootTaskOid, result);
    LOGGER.info("Suspending task tree for {}; {}.", root, waitingInfo(waitTime));
    allTasks.add(root);
    allTasks.addAll(root.listSubtasksDeeply(true, result));
    return suspendTasksInternal(allTasks, waitTime, result);
}
Also used : TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl) ArrayList(java.util.ArrayList)

Example 10 with TaskQuartzImpl

use of com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl in project midpoint by Evolveum.

the class TaskRetriever method getTask.

/**
 * Connects to the remote node if needed.
 */
@NotNull
public TaskQuartzImpl getTask(String oid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException, ObjectNotFoundException {
    try {
        // returns null if noFetch is set
        ClusterStatusInformation csi = clusterStatusInformationRetriever.getClusterStatusInformation(options, TaskType.class, true, result);
        PrismObject<TaskType> taskPrism = getTaskFromRemoteNode(oid, options, csi, result);
        if (taskPrism == null) {
            taskPrism = repositoryService.getObject(TaskType.class, oid, options, result);
        }
        TaskQuartzImpl task = taskInstantiator.createTaskInstance(taskPrism, result);
        addTransientTaskInformation(task, csi, SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RUN_START_TIMESTAMP, options), SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RETRY_TIMESTAMP, options), SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options), result);
        if (SelectorOptions.hasToLoadPath(TaskType.F_SUBTASK_REF, options)) {
            fillInSubtasks(task, csi, options, result);
        }
        updateFromTaskInMemory(task);
        return task;
    } catch (Throwable t) {
        result.recordFatalError(t);
        throw t;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TaskQuartzImpl (com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl)24 ArrayList (java.util.ArrayList)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 Task (com.evolveum.midpoint.task.api.Task)4 NotNull (org.jetbrains.annotations.NotNull)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 HashSet (java.util.HashSet)2 JobKey (org.quartz.JobKey)2 Scheduler (org.quartz.Scheduler)2 SchedulerException (org.quartz.SchedulerException)2 PreconditionViolationException (com.evolveum.midpoint.repo.api.PreconditionViolationException)1 IterationItemInformation (com.evolveum.midpoint.schema.statistics.IterationItemInformation)1 IterativeOperationStartInfo (com.evolveum.midpoint.schema.statistics.IterativeOperationStartInfo)1 Operation (com.evolveum.midpoint.schema.statistics.Operation)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 RunningTask (com.evolveum.midpoint.task.api.RunningTask)1