Search in sources :

Example 1 with NextStartTimes

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

the class TaskRetriever method addTransientTaskInformation.

// task is Task or PrismObject<TaskType>
private void addTransientTaskInformation(Object task, ClusterStatusInformation csi, boolean retrieveNextRunStartTime, boolean retrieveRetryTime, boolean retrieveNodeAsObserved, OperationResult result) {
    if (!isPersistent(task)) {
        throw new IllegalStateException("Task " + task + " is not persistent");
    }
    if (task instanceof RunningTask) {
        throw new UnsupportedOperationException("addTransientTaskInformation is not available for running tasks");
    }
    TaskType taskBean;
    if (task instanceof TaskQuartzImpl) {
        taskBean = ((TaskQuartzImpl) task).getRawTaskObject().asObjectable();
    } else if (task instanceof PrismObject<?>) {
        // noinspection unchecked
        taskBean = ((PrismObject<TaskType>) task).asObjectable();
    } else {
        throw new IllegalArgumentException("task: " + task);
    }
    if (csi != null && retrieveNodeAsObserved) {
        NodeType runsAt = csi.findNodeInfoForTask(taskBean.getOid());
        if (runsAt != null) {
            taskBean.setNodeAsObserved(runsAt.getNodeIdentifier());
        }
    }
    if (retrieveNextRunStartTime || retrieveRetryTime) {
        NextStartTimes times = localScheduler.getNextStartTimes(taskBean.getOid(), retrieveNextRunStartTime, retrieveRetryTime, result);
        if (retrieveNextRunStartTime && times.getNextScheduledRun() != null) {
            taskBean.setNextRunStartTimestamp(XmlTypeConverter.createXMLGregorianCalendar(times.getNextScheduledRun()));
        }
        if (retrieveRetryTime && times.getNextRetry() != null) {
            taskBean.setNextRetryTimestamp(XmlTypeConverter.createXMLGregorianCalendar(times.getNextRetry()));
        }
    }
    Long stalledSince = stalledTasksWatcher.getStalledSinceForTask(taskBean);
    if (stalledSince != null) {
        taskBean.setStalledSince(XmlTypeConverter.createXMLGregorianCalendar(stalledSince));
    }
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl) NextStartTimes(com.evolveum.midpoint.task.quartzimpl.quartz.NextStartTimes)

Aggregations

PrismObject (com.evolveum.midpoint.prism.PrismObject)1 TaskQuartzImpl (com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl)1 NextStartTimes (com.evolveum.midpoint.task.quartzimpl.quartz.NextStartTimes)1