Search in sources :

Example 6 with RMDeployingNode

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

the class RMDeployingNodeTest method createDeployingNode.

private RMDeployingNode createDeployingNode(String name) {
    Client client = Mockito.mock(Client.class);
    NodeSource nodeSource = Mockito.mock(NodeSource.class);
    return new RMDeployingNode(name, nodeSource, "command", client);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) Client(org.ow2.proactive.resourcemanager.authentication.Client)

Example 7 with RMDeployingNode

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

the class InfrastructureManager method removeLostNodeWithLockAndPersist.

private RMDeployingNode removeLostNodeWithLockAndPersist(final String nodeUrl) {
    return setPersistedInfraVariable(() -> {
        RMDeployingNode removedLostNode = this.lostNodesMap.remove(nodeUrl);
        getPersistedLostNodesUrl().remove(nodeUrl);
        return removedLostNode;
    });
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)

Example 8 with RMDeployingNode

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

the class InfrastructureManager method update.

/**
 * Updates a deploying node.
 * <p>
 * The update is performed on deploying nodes first.
 * If no node if found, lost nodes are considered.
 *
 * @param rmNode the new deploying node instance to use.
 * @return the previous value or {@code null}.
 */
public RMDeployingNode update(RMDeployingNode rmNode) {
    String nodeUrl = rmNode.getNodeURL();
    RMDeployingNode previousDeployingNode;
    if (rmNode.isLost() && containsLostNodeWithLock(nodeUrl)) {
        previousDeployingNode = addLostNodeWithLockAndPersist(nodeUrl, rmNode);
    } else if (containsDeployingNodeWithLock(nodeUrl)) {
        previousDeployingNode = addDeployingNodeWithLockAndPersist(nodeUrl, rmNode);
    } else {
        previousDeployingNode = null;
    }
    return previousDeployingNode;
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)

Example 9 with RMDeployingNode

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

the class InfrastructureManager method addDeployingNode.

/**
 * Creates a new RMDeployingNode's, stores it in a local ArrayList and
 * notify the owning NodeSource of the RMDeployingNode creation
 *
 * @param name
 *            The RMDeployingNode's name.
 * @param description
 *            The RMDeployingNode's description
 * @param timeout
 *            after which one the deploying node will be declared lost. (
 *            node acquisition after this timeout is discarded )
 * @return The newly created RMDeployingNode's URL.
 * @throws UnsupportedOperationException
 *             if the infrastructure manager is shuting down
 */
protected final String addDeployingNode(String name, String command, String description, final long timeout) {
    checkName(name);
    checkTimeout(timeout);
    if (shutDown.get()) {
        throw new UnsupportedOperationException("The infrastructure manager is shuting down.");
    }
    // if the user calls this method, we use the require nodes/timeout
    // mecanism
    setUsingDeployingNodesWithLockAndPersist();
    NodeSource nsStub = this.nodeSource.getStub();
    RMDeployingNode deployingNode = RMDeployingNodeAccessor.getDefault().newRMDeployingNode(name, nsStub, command, nsStub.getAdministrator(), description);
    final String deployingNodeUrl = deployingNode.getNodeURL();
    addDeployingNodeWithLockAndPersist(deployingNodeUrl, deployingNode);
    if (RM_NODES_LOCK_RESTORATION.getValueAsBoolean()) {
        logger.debug("Checking lock status for node " + deployingNodeUrl);
        nodeSource.setDeploying(deployingNode);
        // The value for 'deployingNode' is retrieved before calling 'nodeSource.setDeploying'
        // However, 'nodeSource.setDeploying' may lock the node that is currently handled
        // (e.g. node lock restoration on RM startup) and thus update 'deployingNodes'.
        // In such a case, the 'deployingNodes' collection is updated with a new deploying node instance which has the
        // same URL as 'deployingNode' but different state information (e.g. lock status).
        // This is due to deep copies made by ProActive Programming with method invocation on Active Objects.
        // As a consequence, the 'deployingNode' variable must be updated with the last value available
        // in the 'deployingNodes' collection
        RMDeployingNode statefulDeployingNode = getDeployingOrLostNode(deployingNodeUrl);
        if (statefulDeployingNode != null) {
            deployingNode = statefulDeployingNode;
        }
    }
    if (logger.isTraceEnabled()) {
        logger.trace("New DeployingNode " + name + " instantiated in IM");
    }
    RMNodeEvent event = deployingNode.createNodeEvent(RMEventType.NODE_ADDED, null, deployingNode.getProvider().getName());
    emitNodeEvent(event);
    this.sched(new TimerTask() {

        @Override
        public void run() {
            InfrastructureManager.this.timeout(deployingNodeUrl, timeout);
        }
    }, timeout);
    return deployingNode.getNodeURL();
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 10 with RMDeployingNode

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

the class InfrastructureManager method updateDeployingNodeDescription.

/**
 * To update the description of a deploying node. If a timeout has occurred
 * for this node, the update is discarded.
 *
 * @param toUpdateURL
 *            The RMDeployingNode's URL whose description will be updated.
 * @param newDescription
 *            The new description
 * @return true in case of success, false if the deploying node is not
 *         managed by the IM anymore.
 */
protected final boolean updateDeployingNodeDescription(String toUpdateURL, String newDescription) {
    RMDeployingNode pn = getDeployingNodeWithLock(toUpdateURL);
    if (pn != null) {
        NodeState previousState = pn.getState();
        RMDeployingNodeAccessor.getDefault().setDescription(pn, newDescription);
        RMNodeEvent event = pn.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousState, pn.getProvider().getName());
        emitNodeEvent(event);
        logger.trace("Deploying node " + toUpdateURL + " updated in IM");
        return true;
    } else {
        logger.trace("Deploying node " + toUpdateURL + " no more managed by the IM, cannot update it");
        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

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