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();
}
}
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);
}
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);
}
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;
}
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);
}
Aggregations