use of com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType in project midpoint by Evolveum.
the class NodeRegistrar method createNodeObject.
/**
* Executes node startup registration: if Node object with a give name (node ID) exists, deletes it.
* Then creates a new Node with the information relevant to this node.
*
* @param result Node prism to be used for periodic re-registrations.
*/
PrismObject<NodeType> createNodeObject(OperationResult result) throws TaskManagerInitializationException {
nodePrism = createNodePrism(taskManager.getConfiguration());
NodeType node = nodePrism.asObjectable();
LOGGER.info("Registering this node in the repository as " + node.getNodeIdentifier() + " at " + node.getHostname() + ":" + node.getJmxPort());
List<PrismObject<NodeType>> nodes;
try {
nodes = findNodesWithGivenName(result, node.getName());
} catch (SchemaException e) {
throw new TaskManagerInitializationException("Node registration failed because of schema exception", e);
}
for (PrismObject<NodeType> n : nodes) {
LOGGER.trace("Removing existing NodeType with oid = {}, name = {}", n.getOid(), n.getElementName());
try {
getRepositoryService().deleteObject(NodeType.class, n.getOid(), result);
} catch (ObjectNotFoundException e) {
LoggingUtils.logException(LOGGER, "Cannot remove NodeType with oid = {}, name = {}, because it does not exist.", e, n.getOid(), n.getElementName());
// continue, because the error is not that severe (we hope so)
}
}
try {
String oid = getRepositoryService().addObject(nodePrism, null, result);
nodePrism.setOid(oid);
} catch (ObjectAlreadyExistsException e) {
taskManager.setNodeErrorStatus(NodeErrorStatusType.NODE_REGISTRATION_FAILED);
throw new TaskManagerInitializationException("Cannot register this node, because it already exists (this should not happen, as nodes with such a name were just removed)", e);
} catch (SchemaException e) {
taskManager.setNodeErrorStatus(NodeErrorStatusType.NODE_REGISTRATION_FAILED);
throw new TaskManagerInitializationException("Cannot register this node because of schema exception", e);
}
LOGGER.trace("Node was successfully registered in the repository.");
return nodePrism;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType in project midpoint by Evolveum.
the class ExecutionManager method stopTaskRun.
// if clusterwide, csi must not be null
// on entry we do not know if the task is really running
private void stopTaskRun(Task task, ClusterStatusInformation csi, boolean clusterwide, OperationResult parentResult) {
String oid = task.getOid();
LOGGER.trace("stopTaskRun: task = {}, csi = {}, clusterwide = {}", task, csi, clusterwide);
if (!clusterwide) {
stopLocalTaskIfRunning(oid, parentResult);
} else {
NodeType node = csi.findNodeInfoForTask(task.getOid());
if (node != null) {
if (taskManager.getClusterManager().isCurrentNode(node.getNodeIdentifier())) {
stopLocalTaskIfRunning(oid, parentResult);
} else {
remoteNodesManager.stopRemoteTaskRun(task.getOid(), node, parentResult);
}
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType 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.xml.ns._public.common.common_3.NodeType in project midpoint by Evolveum.
the class ClusterExecutionHelperImpl method execute.
@Override
public void execute(@NotNull ClientCode code, ClusterExecutionOptions options, String context, OperationResult parentResult) {
OperationResult result = parentResult.createSubresult(DOT_CLASS + "execute");
if (!taskManager.isClustered()) {
LOGGER.trace("Node is not part of a cluster, skipping remote code execution");
result.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Node not in cluster");
return;
}
SearchResultList<PrismObject<NodeType>> otherClusterNodes = searchOtherClusterNodes(context, result);
if (otherClusterNodes == null) {
return;
}
for (PrismObject<NodeType> node : otherClusterNodes.getList()) {
try {
execute(node.asObjectable(), code, options, context, result);
} catch (SchemaException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute operation ({}) on node {}", e, context, node);
}
}
result.computeStatus();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType in project midpoint by Evolveum.
the class LocalNodeState method getLocalNode.
/**
* @return current local node information, updated with local node execution and error status.
* Returned value is fresh, so it can be modified as needed.
*/
@Nullable
public NodeType getLocalNode() {
PrismObject<NodeType> localNode = clusterManager.getLocalNodeObject();
if (localNode == null) {
return null;
}
NodeType node = localNode.clone().asObjectable();
node.setExecutionState(getExecutionState());
node.setErrorState(errorState);
return node;
}
Aggregations