Search in sources :

Example 11 with RMDeployingNode

use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode in project scheduling by ow2-proactive.

the class NodeSource method internalAddNode.

/**
 * Updates internal node source structures.
 */
@VisibleForTesting
RMDeployingNode internalAddNode(Node node) throws RMException {
    String nodeUrl = node.getNodeInformation().getURL();
    if (this.nodes.containsKey(nodeUrl)) {
        throw new RMException("The node " + nodeUrl + " already added to the node source " + name);
    }
    logger.info("[" + name + "] new node available : " + node.getNodeInformation().getURL());
    RMDeployingNode rmDeployingNode = infrastructureManager.internalRegisterAcquiredNode(node);
    nodes.put(nodeUrl, node);
    if (removedNodes.containsKey(nodeUrl)) {
        removedNodes.remove(nodeUrl);
    }
    return rmDeployingNode;
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMException(org.ow2.proactive.resourcemanager.exception.RMException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 12 with RMDeployingNode

use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode in project scheduling by ow2-proactive.

the class NodeSource method acquireNode.

/**
 * Acquires the existing node with specific url. The node have to be up and running.
 *
 * @param nodeUrl the url of the node
 * @param provider
 */
public BooleanWrapper acquireNode(String nodeUrl, Client provider) {
    if (toShutdown) {
        throw new AddingNodesException("[" + name + "] node " + nodeUrl + " adding request discarded because node source is shutting down");
    }
    // checking that client has a right to change this node source
    // if the provider is the administrator of the node source it always has this permission
    provider.checkPermission(providerPermission, provider + " is not authorized to add node " + nodeUrl + " to " + name, new RMCoreAllPermission(), new NSAdminPermission());
    // lookup for a new Node
    int lookUpTimeout = PAResourceManagerProperties.RM_NODELOOKUP_TIMEOUT.getValueAsInt();
    Node nodeToAdd = null;
    try {
        logger.info("Looking up the node " + nodeUrl + " with " + lookUpTimeout + " ms timeout");
        nodeToAdd = lookupNode(nodeUrl, lookUpTimeout);
        logger.info("The node " + nodeUrl + " has been successfully looked up");
    } catch (Exception e) {
        logger.warn("Cannot look up the node " + nodeUrl + " within " + lookUpTimeout + " ms due to " + e.getMessage(), e);
        throw new AddingNodesException(e);
    }
    // node should be not null at this point...
    if (nodeToAdd == null) {
        throw new AddingNodesException("Cannot lookup node for unknown reason : " + nodeUrl);
    }
    // now checking if this node has been registered before in the node source
    if (downNodes.containsKey(nodeUrl)) {
        // it was registered but detected as down node,
        // so basically the node was restarted.
        // adding a new node and removing old one from the down list
        logger.debug("Removing existing node from down nodes list");
        BooleanWrapper result = rmcore.removeNodeFromCore(nodeUrl);
        if (result.getBooleanValue()) {
            if (logger.isDebugEnabled())
                logger.debug("[" + name + "] successfully removed node " + nodeUrl + " from the core");
            // just removing it from down nodes list
            removeNode(nodeUrl, provider);
        }
    } else if (nodes.containsKey(nodeUrl)) {
        // adding a node which exists in node source
        Node existingNode = nodes.get(nodeUrl);
        if (nodeToAdd.equals(existingNode)) {
            // don't do anything
            if (logger.isDebugEnabled())
                logger.debug("An attempt to add the same node twice " + nodeUrl + " - ignoring");
            return new BooleanWrapper(false);
        } else {
            // adding another node with the same url
            // replacing the old node by the new one
            logger.debug("Removing existing node from the RM without request propagation to the infrastructure manager");
            BooleanWrapper result = rmcore.removeNodeFromCore(nodeUrl);
            if (result.getBooleanValue()) {
                if (logger.isDebugEnabled())
                    logger.debug("[" + name + "] successfully removed node " + nodeUrl + " from the core");
                // removing it from the nodes list but don't propagate
                // the request the the infrastructure because the restarted node will be killed
                nodes.remove(nodeUrl);
            }
        }
    }
    // if any exception occurs in internalAddNode(node) do not add the node to the core
    RMDeployingNode deployingNode;
    try {
        deployingNode = internalAddNode(nodeToAdd);
    } catch (RMException e) {
        throw new AddingNodesException(e);
    }
    // we build the rmnode
    RMNode rmNode = buildRMNode(nodeToAdd, provider);
    if (deployingNode != null) {
        // inherit locking status from associated deploying node created before
        ((AbstractRMNode) rmNode).copyLockStatusFrom(deployingNode);
    }
    BooleanWrapper nodeAdded = rmcore.registerAvailableNode(rmNode);
    rmcore.internalRegisterConfiguringNode(rmNode);
    return nodeAdded;
}
Also used : RMCoreAllPermission(org.ow2.proactive.permissions.RMCoreAllPermission) NSAdminPermission(org.ow2.proactive.permissions.NSAdminPermission) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) AbstractRMNode(org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) Node(org.objectweb.proactive.core.node.Node) AbstractRMNode(org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode) AddingNodesException(org.ow2.proactive.resourcemanager.exception.AddingNodesException) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMException(org.ow2.proactive.resourcemanager.exception.RMException) AddingNodesException(org.ow2.proactive.resourcemanager.exception.AddingNodesException) RMException(org.ow2.proactive.resourcemanager.exception.RMException) AbstractRMNode(org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode)

Example 13 with RMDeployingNode

use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode 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(ns -> {
        if (deployedNodeSources.containsKey(ns.getName())) {
            return PAFuture.getFutureValue(deployedNodeSources.get(ns.getName()).createNodeSourceEvent());
        } else {
            return ns.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) ConfigurableField(org.ow2.proactive.resourcemanager.nodesource.common.ConfigurableField) 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) RMException(org.ow2.proactive.resourcemanager.exception.RMException) 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) PluginNotFoundException(org.ow2.proactive.resourcemanager.nodesource.PluginNotFoundException) UserData(org.ow2.proactive.authentication.UserData) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) 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) NSAdminPermission(org.ow2.proactive.permissions.NSAdminPermission) Files(java.nio.file.Files) NodeUserAllPermission(org.ow2.proactive.permissions.NodeUserAllPermission) Node(org.objectweb.proactive.core.node.Node) StubObject(org.objectweb.proactive.core.mop.StubObject) File(java.io.File) InfrastructureManagerFactory(org.ow2.proactive.resourcemanager.nodesource.infrastructure.InfrastructureManagerFactory) TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) Paths(java.nio.file.Paths) 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) ThreadDumpNotAccessibleException(org.ow2.proactive.resourcemanager.rmnode.ThreadDumpNotAccessibleException) 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) RMNodeHistory(org.ow2.proactive.resourcemanager.common.event.RMNodeHistory) Collectors(java.util.stream.Collectors) List(java.util.List) ActiveObject(org.objectweb.proactive.extensions.annotation.ActiveObject) NodesHouseKeepingService(org.ow2.proactive.resourcemanager.housekeeping.NodesHouseKeepingService) Entry(java.util.Map.Entry) NodesRecoveryManager(org.ow2.proactive.resourcemanager.core.recovery.NodesRecoveryManager) 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) RMCoreAllPermission(org.ow2.proactive.permissions.RMCoreAllPermission) 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) NodeSourceConfiguration(org.ow2.proactive.resourcemanager.nodesource.common.NodeSourceConfiguration) 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) NodeHistory(org.ow2.proactive.resourcemanager.core.history.NodeHistory) RMNodeHelper(org.ow2.proactive.resourcemanager.utils.RMNodeHelper) AbstractMap(java.util.AbstractMap) 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 14 with RMDeployingNode

use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode in project scheduling by ow2-proactive.

the class InfrastructureManager method removeDeployingNodeWithLockAndPersist.

private RMDeployingNode removeDeployingNodeWithLockAndPersist(final String nodeUrl) {
    return setPersistedInfraVariable(() -> {
        RMDeployingNode removedDeployingNode = this.deployingNodesMap.remove(nodeUrl);
        getPersistedDeployingNodesUrl().remove(nodeUrl);
        return removedDeployingNode;
    });
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)

Example 15 with RMDeployingNode

use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode in project scheduling by ow2-proactive.

the class InfrastructureManager method addDeployingNodeWithLockAndPersist.

protected RMDeployingNode addDeployingNodeWithLockAndPersist(final String nodeUrl, final RMDeployingNode deployingNode) {
    return setPersistedInfraVariable(() -> {
        RMDeployingNode previousDeployingNode = this.deployingNodesMap.put(nodeUrl, deployingNode);
        getPersistedDeployingNodesUrl().add(nodeUrl);
        return previousDeployingNode;
    });
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)

Aggregations

RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)23 Test (org.junit.Test)9 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)6 RMException (org.ow2.proactive.resourcemanager.exception.RMException)4 Client (org.ow2.proactive.resourcemanager.authentication.Client)3 NodeState (org.ow2.proactive.resourcemanager.common.NodeState)3 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Node (org.objectweb.proactive.core.node.Node)2 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)2 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)2 Function (com.google.common.base.Function)1 Predicate (com.google.common.base.Predicate)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 File (java.io.File)1 Serializable (java.io.Serializable)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1