Search in sources :

Example 11 with ClusterStatusInformation

use of com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation 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)

Example 12 with ClusterStatusInformation

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

the class TaskManagerQuartzImpl method searchNodes.

/*
     * Gets nodes from repository and adds runtime information to them (taken from ClusterStatusInformation).
     */
//    @Override
//    public int countNodes(ObjectQuery query, OperationResult result) throws SchemaException {
//        return repositoryService.countObjects(NodeType.class, query, result);
//    }
private SearchResultList<PrismObject<NodeType>> searchNodes(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
    ClusterStatusInformation clusterStatusInformation = getClusterStatusInformation(options, NodeType.class, true, result);
    List<PrismObject<NodeType>> nodesInRepository;
    try {
        nodesInRepository = repositoryService.searchObjects(NodeType.class, query, options, result);
    } catch (SchemaException e) {
        result.recordFatalError("Couldn't get nodes from repository: " + e.getMessage());
        throw e;
    }
    List<PrismObject<NodeType>> list = new ArrayList<PrismObject<NodeType>>();
    if (clusterStatusInformation != null) {
        for (PrismObject<NodeType> nodeInRepositoryPrism : nodesInRepository) {
            NodeType returnedNode = nodeInRepositoryPrism.asObjectable();
            NodeType nodeRuntimeInfo = clusterStatusInformation.findNodeById(returnedNode.getNodeIdentifier());
            if (nodeRuntimeInfo != null) {
                returnedNode.setExecutionStatus(nodeRuntimeInfo.getExecutionStatus());
                returnedNode.setErrorStatus(nodeRuntimeInfo.getErrorStatus());
                returnedNode.setConnectionResult(nodeRuntimeInfo.getConnectionResult());
            } else {
                // node is in repo, but no information on it is present in CSI
                // (should not occur except for some temporary conditions, because CSI contains info on all nodes from repo)
                returnedNode.setExecutionStatus(NodeExecutionStatusType.COMMUNICATION_ERROR);
                OperationResult r = new OperationResult("connect");
                r.recordFatalError("Node not known at this moment");
                returnedNode.setConnectionResult(r.createOperationResultType());
            }
            list.add(returnedNode.asPrismObject());
        }
    } else {
        list = nodesInRepository;
    }
    LOGGER.trace("searchNodes returning {}", list);
    result.computeStatus();
    return new SearchResultList(list);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation)

Example 13 with ClusterStatusInformation

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

the class NodeRetriever method searchNodes.

/**
 * Gets nodes from repository and adds runtime information to them (taken from ClusterStatusInformation).
 */
@NotNull
public SearchResultList<PrismObject<NodeType>> searchNodes(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
    ClusterStatusInformation csi = clusterStatusInformationRetriever.getClusterStatusInformation(options, NodeType.class, true, result);
    List<PrismObject<NodeType>> nodesInRepository;
    try {
        nodesInRepository = repositoryService.searchObjects(NodeType.class, query, options, result);
    } catch (SchemaException e) {
        result.recordFatalError("Couldn't get nodes from repository: " + e.getMessage());
        throw e;
    }
    List<PrismObject<NodeType>> list = new ArrayList<>();
    if (csi != null) {
        for (PrismObject<NodeType> nodeInRepositoryPrism : nodesInRepository) {
            NodeType returnedNode = nodeInRepositoryPrism.asObjectable();
            NodeType nodeRuntimeInfo = csi.findNodeById(returnedNode.getNodeIdentifier());
            if (nodeRuntimeInfo != null) {
                returnedNode.setExecutionState(nodeRuntimeInfo.getExecutionState());
                returnedNode.setErrorState(nodeRuntimeInfo.getErrorState());
                returnedNode.setConnectionResult(nodeRuntimeInfo.getConnectionResult());
            } else {
                // node is in repo, but no information on it is present in CSI
                // (should not occur except for some temporary conditions, because CSI contains info on all nodes from repo)
                returnedNode.setExecutionState(NodeExecutionStateType.COMMUNICATION_ERROR);
                OperationResult r = new OperationResult("connect");
                r.recordFatalError("Node not known at this moment");
                returnedNode.setConnectionResult(r.createOperationResultType());
            }
            list.add(returnedNode.asPrismObject());
        }
    } else {
        list = nodesInRepository;
    }
    LOGGER.trace("searchNodes returning {}", list);
    return new SearchResultList<>(list);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) NodeType(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with ClusterStatusInformation

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

the class GroupLimitsChecker method createGroupMap.

@NotNull
private Map<String, GroupExecInfo> createGroupMap(RunningTaskQuartzImpl task, OperationResult result) {
    Map<String, GroupExecInfo> groupMap = new HashMap<>();
    Map<String, Integer> groupsWithLimits = task.getGroupsWithLimits();
    if (!groupsWithLimits.isEmpty()) {
        groupsWithLimits.forEach((g, l) -> groupMap.put(g, new GroupExecInfo(l)));
        ClusterStatusInformation csi = beans.clusterStatusInformationRetriever.getClusterStatusInformation(true, false, result);
        for (ClusterStatusInformation.TaskInfo taskInfo : csi.getTasks()) {
            if (task.getOid().equals(taskInfo.getOid())) {
                continue;
            }
            Task otherTask;
            try {
                otherTask = beans.taskRetriever.getTaskPlain(taskInfo.getOid(), result);
            } catch (ObjectNotFoundException e) {
                LOGGER.debug("Couldn't find running task {} when checking execution constraints: {}", taskInfo.getOid(), e.getMessage());
                continue;
            } catch (SchemaException e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't retrieve running task {} when checking execution constraints", e, taskInfo.getOid());
                continue;
            }
            addToGroupMap(groupMap, otherTask);
        }
    }
    return groupMap;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with ClusterStatusInformation

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

the class TaskStopper method stopAllTasksOnNodes.

public boolean stopAllTasksOnNodes(Collection<String> nodeIdentifiers, long timeToWait, OperationResult result) throws SchemaException {
    ClusterStatusInformation csi = clusterStatusInformationRetriever.getClusterStatusInformation(true, false, result);
    Set<ClusterStatusInformation.TaskInfo> taskInfoList = csi.getTasksOnNodes(nodeIdentifiers);
    LOGGER.debug("{} task(s) found on nodes that are going down, stopping them.", taskInfoList.size());
    List<Task> tasks = getTasksSafely(taskInfoList, result);
    return stopTasksRunAndWait(tasks, csi, timeToWait, true, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation)

Aggregations

ClusterStatusInformation (com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)6 NotNull (org.jetbrains.annotations.NotNull)5 SearchResultList (com.evolveum.midpoint.schema.SearchResultList)4 ArrayList (java.util.ArrayList)4 Task (com.evolveum.midpoint.task.api.Task)3 NodeType (com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 TaskQuartzImpl (com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 XmlTypeConverter (com.evolveum.midpoint.prism.xml.XmlTypeConverter)1 com.evolveum.midpoint.task.api (com.evolveum.midpoint.task.api)1 TaskRunResultStatus (com.evolveum.midpoint.task.api.TaskRunResult.TaskRunResultStatus)1 TaskManagerQuartzImpl (com.evolveum.midpoint.task.quartzimpl.TaskManagerQuartzImpl)1 TaskQuartzImplUtil (com.evolveum.midpoint.task.quartzimpl.TaskQuartzImplUtil)1 LoggingUtils (com.evolveum.midpoint.util.logging.LoggingUtils)1