Search in sources :

Example 21 with TaskQuartzImpl

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

the class ResumeHelper method resumeTask.

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

Example 22 with TaskQuartzImpl

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

the class SuspendAndDeleteHelper method deleteTask.

public void deleteTask(String oid, OperationResult result) throws ObjectNotFoundException, SchemaException {
    TaskQuartzImpl task = taskRetriever.getTaskPlain(oid, result);
    if (task.getNode() != null) {
        result.recordWarning("Deleting a task that seems to be currently executing on node " + task.getNode());
    }
    listenerRegistry.notifyTaskDeleted(task, result);
    try {
        repositoryService.deleteObject(TaskType.class, oid, result);
    } finally {
        localScheduler.deleteTaskFromQuartz(oid, false, result);
    }
// We could consider unpausing the dependents here. However, they might be already deleted,
// so we have to be prepared to get ObjectNotFoundException here. Or perhaps to unpause something
// that will be deleted milliseconds later (in the case of task tree deletion). Therefore it is
// better NOT to unpause anything -- and to avoid relying on waiting on tasks that are going to be deleted.
// TODO Reconsider. What if there are suspended subtasks that are deleted, and their parents should
// be then unpaused? Maybe the forceful close of the task should be introduced.
}
Also used : TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl)

Example 23 with TaskQuartzImpl

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

the class SuspendAndDeleteHelper method deleteTaskTree.

public void deleteTaskTree(String rootOid, OperationResult result) throws SchemaException, ObjectNotFoundException {
    TaskQuartzImpl root = taskRetriever.getTaskPlain(rootOid, result);
    LOGGER.debug("Deleting task tree {}", root);
    List<TaskQuartzImpl> allTasks = new ArrayList<>(root.listSubtasksDeeply(true, result));
    allTasks.add(root);
    deleteTasks(allTasks, result);
}
Also used : TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl) ArrayList(java.util.ArrayList)

Example 24 with TaskQuartzImpl

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

the class TaskRetriever method updateFromTaskInMemory.

/**
 * Updates selected fields (operation statistics, progress) from in-memory running task.
 */
private void updateFromTaskInMemory(Task task0) {
    TaskQuartzImpl task = (TaskQuartzImpl) task0;
    if (task.getTaskIdentifier() == null) {
        // shouldn't really occur
        return;
    }
    RunningTask taskInMemory = localNodeState.getLocallyRunningTaskByIdentifier(task.getTaskIdentifier());
    if (taskInMemory == null) {
        return;
    }
    OperationStatsType operationStats = taskInMemory.getAggregatedLiveOperationStats();
    if (operationStats != null) {
        operationStats.setLiveInformation(true);
    }
    task.setOperationStatsTransient(operationStats);
    task.setProgressTransient(taskInMemory.getLegacyProgress());
// We intentionally do not try to get operation result from the task. OperationResult class is not thread-safe,
// so it cannot be safely accessed from a different thread. It is not a big problem, because the result should be
// periodically updated in the repository, so we get (at worst) an information that is a few seconds out-of-date.
}
Also used : TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl)

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