Search in sources :

Example 1 with NodeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType in project midpoint by Evolveum.

the class NodeDtoProvider method internalIterator.

@Override
public Iterator<? extends NodeDto> internalIterator(long first, long count) {
    Collection<String> selectedOids = getSelectedOids();
    getAvailableData().clear();
    OperationResult result = new OperationResult(OPERATION_LIST_NODES);
    Task task = getTaskManager().createTaskInstance(OPERATION_LIST_NODES);
    try {
        ObjectPaging paging = createPaging(first, count);
        ObjectQuery query = getQuery();
        if (query == null) {
            query = new ObjectQuery();
        }
        query.setPaging(paging);
        List<PrismObject<NodeType>> nodes = getModel().searchObjects(NodeType.class, query, null, task, result);
        for (PrismObject<NodeType> node : nodes) {
            getAvailableData().add(createNodeDto(node));
        }
        result.recordSuccess();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing nodes", ex);
        result.recordFatalError("Couldn't list nodes.", ex);
    }
    setSelectedOids(selectedOids);
    return getAvailableData().iterator();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) NodeType(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 2 with NodeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType in project midpoint by Evolveum.

the class RNode method toJAXB.

@Override
public NodeType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
    NodeType object = new NodeType();
    RUtil.revive(object, prismContext);
    RNode.copyToJAXB(this, object, prismContext, options);
    return object;
}
Also used : NodeType(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType)

Example 3 with NodeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType in project midpoint by Evolveum.

the class ExecutionManager method getClusterStatusInformation.

/*
     * ==================== NODE-LEVEL METHODS (QUERIES) ====================
     */
public ClusterStatusInformation getClusterStatusInformation(boolean clusterwide, boolean allowCached, OperationResult parentResult) {
    OperationResult result = parentResult.createSubresult(ExecutionManager.class.getName() + ".getClusterStatusInformation");
    result.addParam("clusterwide", clusterwide);
    if (allowCached && clusterwide && lastClusterStatusInformation != null && lastClusterStatusInformation.isFresh(ALLOWED_CLUSTER_STATE_INFORMATION_AGE)) {
        result.recordSuccess();
        return lastClusterStatusInformation;
    }
    ClusterStatusInformation retval = new ClusterStatusInformation();
    if (clusterwide) {
        for (PrismObject<NodeType> node : taskManager.getClusterManager().getAllNodes(result)) {
            addNodeAndTaskInformation(retval, node, result);
        }
    } else {
        addNodeAndTaskInformation(retval, taskManager.getClusterManager().getNodePrism(), result);
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("cluster state information = {}", retval.dump());
    }
    if (clusterwide) {
        lastClusterStatusInformation = retval;
    }
    result.recomputeStatus();
    return retval;
}
Also used : NodeType(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation)

Example 4 with NodeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType in project midpoint by Evolveum.

the class JobExecutor method getAvailableNode.

private NodeType getAvailableNode(List<String> allowedNodes, List<String> disallowedNodes, OperationResult result) {
    ClusterStatusInformation clusterStatusInformation = taskManagerImpl.getExecutionManager().getClusterStatusInformation(true, false, result);
    List<NodeType> matching = clusterStatusInformation.getNodes().stream().filter(node -> passes(node.getNodeIdentifier(), allowedNodes, disallowedNodes) && node.getExecutionStatus() == NodeExecutionStatusType.RUNNING).collect(Collectors.toList());
    if (matching.isEmpty()) {
        return null;
    } else {
        return matching.get((int) (Math.random() * matching.size()));
    }
}
Also used : TaskQuartzImplUtil(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImplUtil) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) TaskRunResultStatus(com.evolveum.midpoint.task.api.TaskRunResult.TaskRunResultStatus) TaskQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskQuartzImpl) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Date(java.util.Date) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) PrismObject(com.evolveum.midpoint.prism.PrismObject) Collectors(java.util.stream.Collectors) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) ArrayList(java.util.ArrayList) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation) List(java.util.List) TaskManagerQuartzImpl(com.evolveum.midpoint.task.quartzimpl.TaskManagerQuartzImpl) Duration(javax.xml.datatype.Duration) SystemException(com.evolveum.midpoint.util.exception.SystemException) com.evolveum.midpoint.task.api(com.evolveum.midpoint.task.api) Validate(org.apache.commons.lang.Validate) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) org.quartz(org.quartz) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) ClusterStatusInformation(com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation)

Example 5 with NodeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType in project midpoint by Evolveum.

the class NodeRegistrar method createNodePrism.

private PrismObject<NodeType> createNodePrism(TaskManagerConfiguration configuration) {
    PrismObjectDefinition<NodeType> nodeTypeDef = getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(NodeType.class);
    PrismObject<NodeType> nodePrism;
    try {
        nodePrism = nodeTypeDef.instantiate();
    } catch (SchemaException e) {
        throw new SystemException(e.getMessage(), e);
    }
    NodeType node = nodePrism.asObjectable();
    node.setNodeIdentifier(configuration.getNodeId());
    node.setName(new PolyStringType(configuration.getNodeId()));
    node.setHostname(getMyAddress());
    node.setJmxPort(configuration.getJmxPort());
    node.setClustered(configuration.isClustered());
    node.setRunning(true);
    node.setLastCheckInTime(getCurrentTime());
    node.setBuild(getBuildInformation());
    generateInternalNodeIdentifier(node);
    return nodePrism;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) NodeType(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType)

Aggregations

NodeType (com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType)28 PrismObject (com.evolveum.midpoint.prism.PrismObject)13 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)11 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)9 SystemException (com.evolveum.midpoint.util.exception.SystemException)7 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)6 ClusterStatusInformation (com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation)4 ArrayList (java.util.ArrayList)4 IOException (java.io.IOException)3 List (java.util.List)3 MBeanServerConnection (javax.management.MBeanServerConnection)3 MalformedObjectNameException (javax.management.MalformedObjectNameException)3 JMXConnector (javax.management.remote.JMXConnector)3 QuartzSchedulerMBean (org.quartz.core.jmx.QuartzSchedulerMBean)3 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 SearchResultList (com.evolveum.midpoint.schema.SearchResultList)2 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)2 LoggingUtils (com.evolveum.midpoint.util.logging.LoggingUtils)2 Trace (com.evolveum.midpoint.util.logging.Trace)2