Search in sources :

Example 26 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class RMCoreTest method createRmNodeEvent.

private RMNodeEvent createRmNodeEvent(NodeState previousNodeState) {
    RMNodeDescriptor rmNodeDescriptor = new RMNodeDescriptor();
    rmNodeDescriptor.setState(NodeState.DOWN);
    return new RMNodeEvent(rmNodeDescriptor, RMEventType.NODE_STATE_CHANGED, previousNodeState, "initiator");
}
Also used : RMNodeDescriptor(org.ow2.proactive.resourcemanager.common.event.RMNodeDescriptor) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 27 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class RMCore method getRMInitialState.

/**
 * Builds and returns a snapshot of RMCore's current state. Initial state
 * must be understood as a new Monitor point of view. A new monitor start to
 * receive RMCore events, so must be informed of the current state of the
 * Core at the beginning of monitoring. The monitor is built in three parts
 * first with all the nodes knows by the RMCore, then with all deploying
 * nodes known by the deployed node sources and then with all the defined
 * node sources.
 *
 * @return RMInitialState containing nodes and nodeSources of the RMCore.
 */
public RMInitialState getRMInitialState() {
    final Map<String, RMNodeEvent> nodeEvents = this.allNodes.values().stream().map(RMNode::createNodeEvent).collect(Collectors.toMap(RMNodeEvent::getNodeUrl, event -> event));
    for (NodeSource source : this.deployedNodeSources.values()) {
        for (RMDeployingNode node : source.getDeployingAndLostNodes()) {
            final RMNodeEvent nodeEvent = node.createNodeEvent();
            nodeEvents.put(nodeEvent.getNodeUrl(), nodeEvent);
        }
    }
    final List<RMNodeSourceEvent> nodeSourceEvents = new ArrayList<>(this.definedNodeSources.values().stream().map(NodeSource::createNodeSourceEvent).collect(Collectors.toList()));
    long eventCounter = 0;
    for (RMNodeSourceEvent nodeSourceEvent : nodeSourceEvents) {
        nodeSourceEvent.setCounter(eventCounter++);
    }
    for (RMNodeEvent nodeEvent : nodeEvents.values()) {
        nodeEvent.setCounter(eventCounter++);
    }
    final RMInitialState rmInitialState = new RMInitialState();
    rmInitialState.addAll(nodeEvents.values());
    rmInitialState.addAll(nodeSourceEvents);
    return rmInitialState;
}
Also used : Arrays(java.util.Arrays) NodeSet(org.ow2.proactive.utils.NodeSet) ScriptResult(org.ow2.proactive.scripting.ScriptResult) SelectionScript(org.ow2.proactive.scripting.SelectionScript) RMAuthenticationImpl(org.ow2.proactive.resourcemanager.authentication.RMAuthenticationImpl) Matcher(java.util.regex.Matcher) Body(org.objectweb.proactive.Body) NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) DefaultInfrastructureManager(org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager) ImmediateService(org.objectweb.proactive.annotation.ImmediateService) Map(java.util.Map) Script(org.ow2.proactive.scripting.Script) RMInitialState(org.ow2.proactive.resourcemanager.common.event.RMInitialState) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) RMJMXHelper(org.ow2.proactive.resourcemanager.core.jmx.RMJMXHelper) NodeSourceStatus(org.ow2.proactive.resourcemanager.nodesource.NodeSourceStatus) RMState(org.ow2.proactive.resourcemanager.common.RMState) Set(java.util.Set) InitActive(org.objectweb.proactive.InitActive) NodeState(org.ow2.proactive.resourcemanager.common.NodeState) Serializable(java.io.Serializable) RMMonitoringImpl(org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl) CountDownLatch(java.util.concurrent.CountDownLatch) SimpleScript(org.ow2.proactive.scripting.SimpleScript) NodeException(org.objectweb.proactive.core.node.NodeException) Permission(java.security.Permission) Predicate(com.google.common.base.Predicate) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) ScriptException(org.ow2.proactive.scripting.ScriptException) RMEvent(org.ow2.proactive.resourcemanager.common.event.RMEvent) Service(org.objectweb.proactive.Service) StaticPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy) UserData(org.ow2.proactive.authentication.UserData) ArrayList(java.util.ArrayList) NodeSourceDescriptor(org.ow2.proactive.resourcemanager.nodesource.NodeSourceDescriptor) RMNodeConfigurator(org.ow2.proactive.resourcemanager.nodesource.RMNodeConfigurator) Client(org.ow2.proactive.resourcemanager.authentication.Client) TopologyException(org.ow2.proactive.resourcemanager.frontend.topology.TopologyException) RMEventType(org.ow2.proactive.resourcemanager.common.event.RMEventType) Criteria(org.ow2.proactive.utils.Criteria) Node(org.objectweb.proactive.core.node.Node) StubObject(org.objectweb.proactive.core.mop.StubObject) InfrastructureManagerFactory(org.ow2.proactive.resourcemanager.nodesource.infrastructure.InfrastructureManagerFactory) TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) StringWrapper(org.objectweb.proactive.core.util.wrapper.StringWrapper) PluginDescriptor(org.ow2.proactive.resourcemanager.nodesource.common.PluginDescriptor) RunActive(org.objectweb.proactive.RunActive) InfrastructureManager(org.ow2.proactive.resourcemanager.nodesource.infrastructure.InfrastructureManager) RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PAFuture(org.objectweb.proactive.api.PAFuture) URISyntaxException(java.net.URISyntaxException) ClientPinger(org.ow2.proactive.resourcemanager.utils.ClientPinger) LocalBodyStore(org.objectweb.proactive.core.body.LocalBodyStore) IdentityPrincipal(org.ow2.proactive.authentication.principals.IdentityPrincipal) ProbablisticSelectionManager(org.ow2.proactive.resourcemanager.selection.statistics.ProbablisticSelectionManager) MethodCallPermission(org.ow2.proactive.permissions.MethodCallPermission) Logger(org.apache.log4j.Logger) TopologyDescriptor(org.ow2.proactive.topology.descriptor.TopologyDescriptor) RMStateNodeUrls(org.ow2.proactive.resourcemanager.common.RMStateNodeUrls) SelectionManager(org.ow2.proactive.resourcemanager.selection.SelectionManager) URI(java.net.URI) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) Topology(org.ow2.proactive.resourcemanager.frontend.topology.Topology) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Request(org.objectweb.proactive.core.body.request.Request) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Collectors(java.util.stream.Collectors) List(java.util.List) ActiveObject(org.objectweb.proactive.extensions.annotation.ActiveObject) Entry(java.util.Map.Entry) Pattern(java.util.regex.Pattern) RMDBManager(org.ow2.proactive.resourcemanager.db.RMDBManager) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) RMMonitoring(org.ow2.proactive.resourcemanager.frontend.RMMonitoring) UniqueID(org.objectweb.proactive.core.UniqueID) UserNamePrincipal(org.ow2.proactive.authentication.principals.UserNamePrincipal) TargetType(org.ow2.proactive.resourcemanager.utils.TargetType) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) NodeSourcePolicy(org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy) HashMap(java.util.HashMap) AddingNodesException(org.ow2.proactive.resourcemanager.exception.AddingNodesException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) NodeSourceData(org.ow2.proactive.resourcemanager.db.NodeSourceData) HashSet(java.util.HashSet) UserHistory(org.ow2.proactive.resourcemanager.core.history.UserHistory) NotConnectedException(org.ow2.proactive.resourcemanager.exception.NotConnectedException) LinkedList(java.util.LinkedList) RMAccountsManager(org.ow2.proactive.resourcemanager.core.account.RMAccountsManager) RMConstants(org.ow2.proactive.resourcemanager.common.RMConstants) IntWrapper(org.objectweb.proactive.core.util.wrapper.IntWrapper) ProActiveException(org.objectweb.proactive.core.ProActiveException) PAResourceManagerProperties(org.ow2.proactive.resourcemanager.core.properties.PAResourceManagerProperties) RMNodeHelper(org.ow2.proactive.resourcemanager.utils.RMNodeHelper) ClientsPolicy(org.ow2.proactive.policy.ClientsPolicy) NodeSourcePolicyFactory(org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicyFactory) PrincipalPermission(org.ow2.proactive.permissions.PrincipalPermission) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) NodesCleaner(org.ow2.proactive.resourcemanager.cleaning.NodesCleaner) NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) RMInitialState(org.ow2.proactive.resourcemanager.common.event.RMInitialState) ArrayList(java.util.ArrayList) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 28 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class InfrastructureManager method internalRemoveDeployingNode.

/**
 * To remove a deploying node given its url
 *
 * @param pnUrl
 *            the url of the deploying node to remove.
 * @return true if successful, false otherwise
 */
public final boolean internalRemoveDeployingNode(String pnUrl) {
    RMDeployingNode pn = null;
    boolean isLost = false;
    writeLock.lock();
    try {
        pn = removeDeployingNodeWithLockAndPersist(pnUrl);
        if (pn == null) {
            pn = removeLostNodeWithLockAndPersist(pnUrl);
            isLost = true;
        }
    } catch (RuntimeException e) {
        logger.error("Exception while removing deploying node: " + e.getMessage());
        throw e;
    } finally {
        writeLock.unlock();
    }
    // if such a deploying or lost node exists
    if (pn != null) {
        String url = pn.getNodeURL();
        RMNodeEvent event = pn.createNodeEvent(RMEventType.NODE_REMOVED, pn.getState(), pn.getProvider().getName());
        emitEvent(event);
        logger.trace("DeployingNode " + url + " removed from IM");
        // if the node is not lost
        if (!isLost) {
            this.notifyDeployingNodeLost(pn.getNodeURL());
        }
        return true;
    } else {
        logger.trace("DeployingNode: " + pnUrl + " no more managed by IM, cannot remove it");
        return false;
    }
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 29 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class InfrastructureManager method internalRegisterAcquiredNode.

/**
 * This method is called by the RMCore to notify the InfrastructureManager
 * that a new node was added to the core. If the IM throws an exception, the
 * node is not added. Note that this method is in mutual exclusion with
 * {@link #checkNodeIsAcquiredAndDo(String, Runnable, Runnable)} At this
 * point, if a previous call to
 * {@link InfrastructureManager#addDeployingNode(String, String, String, long)}
 * was made (means that implementor uses deploying nodes features), this
 * method ensures that the implementation method (see
 * {@link InfrastructureManager#notifyAcquiredNode(Node)} is only called if
 * no timeout has occurred for the associated deploying node.
 *
 * @param node
 *            the newly added node
 * @throws RMException
 */
public final RMDeployingNode internalRegisterAcquiredNode(Node node) throws RMException {
    if (!isUsingDeployingNode()) {
        this.notifyAcquiredNode(node);
        return null;
    }
    // here we use deploying nodes and timeout
    RMDeployingNode pn;
    // we build the url of the associated deploying node
    String deployingNodeURL = this.buildDeployingNodeURL(node.getNodeInformation().getName());
    writeLock.lock();
    try {
        pn = removeDeployingNodeWithLockAndPersist(deployingNodeURL);
        // implementation callback
        if (pn != null) {
            RMNodeEvent event = pn.createNodeEvent(RMEventType.NODE_REMOVED, pn.getState(), pn.getProvider().getName());
            emitEvent(event);
            this.notifyAcquiredNode(node);
            // if everything went well with the new node, caching it
            addAcquiredNodeNameWithLockAndPersist(node.getNodeInformation().getName());
        } else {
            String url = node.getNodeInformation().getURL();
            logger.warn("Not expected node registered, discarding it: " + url);
            throw new RMException("Not expected node registered, discarding it: " + url);
        }
    } catch (RuntimeException e) {
        logger.error("Exception while moving deploying node to acquired node", e);
        throw e;
    } finally {
        writeLock.unlock();
    }
    return pn;
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 30 with RMNodeEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeEvent in project scheduling by ow2-proactive.

the class InfrastructureManager method declareDeployingNodeLost.

/**
 * Declares a deploying node lost. Future attempts to modify the deploying
 * node will be ignored.
 *
 * @param toUpdateURL
 *            The RMDeployingNode's URL which is to be declared as lost
 * @param description
 *            the new rmdeployingnode's description, can be null.
 * @return true if the method ran successfully, false otherwise.
 */
protected final boolean declareDeployingNodeLost(String toUpdateURL, String description) {
    RMDeployingNode deployingNode;
    // we need to atomically move the node from the deploying collection to
    // the lost one.
    writeLock.lock();
    try {
        deployingNode = removeDeployingNodeWithLockAndPersist(toUpdateURL);
        if (deployingNode != null) {
            addLostNodeWithLockAndPersist(toUpdateURL, deployingNode);
        }
    } catch (RuntimeException e) {
        logger.error("Exception while moving a node from deploying to lost: " + e.getMessage());
        throw e;
    } finally {
        writeLock.unlock();
    }
    if (deployingNode != null) {
        logger.warn("Declaring node as lost: " + toUpdateURL + ", " + description);
        NodeState previousState = deployingNode.getState();
        RMDeployingNodeAccessor.getDefault().setLost(deployingNode);
        if (description != null) {
            RMDeployingNodeAccessor.getDefault().setDescription(deployingNode, description);
        }
        RMNodeEvent event = deployingNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousState, deployingNode.getProvider().getName());
        emitEvent(event);
        if (logger.isTraceEnabled()) {
            logger.trace(RMDeployingNode.class.getSimpleName() + " " + toUpdateURL + " declared lost in IM");
        }
        return true;
    } else {
        if (logger.isTraceEnabled()) {
            logger.trace(RMDeployingNode.class.getSimpleName() + " " + toUpdateURL + " no more managed by IM, cannot declare it as lost");
        }
        return false;
    }
}
Also used : NodeState(org.ow2.proactive.resourcemanager.common.NodeState) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Aggregations

RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)27 Test (org.junit.Test)14 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)13 NodeSet (org.ow2.proactive.utils.NodeSet)13 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)10 File (java.io.File)8 TestNode (functionaltests.utils.TestNode)7 Node (org.objectweb.proactive.core.node.Node)7 HashMap (java.util.HashMap)6 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)6 SelectionScript (org.ow2.proactive.scripting.SelectionScript)6 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)5 NodeState (org.ow2.proactive.resourcemanager.common.NodeState)4 RMState (org.ow2.proactive.resourcemanager.common.RMState)4 Criteria (org.ow2.proactive.utils.Criteria)4 ArrayList (java.util.ArrayList)3 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)3 DefaultInfrastructureManager (org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager)3 URI (java.net.URI)2 HashSet (java.util.HashSet)2