Search in sources :

Example 16 with RMDeployingNode

use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode 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(), e);
        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());
        emitNodeEvent(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)

Example 17 with RMDeployingNode

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

the class InfrastructureManager method addLostNodeWithLockAndPersist.

protected RMDeployingNode addLostNodeWithLockAndPersist(final String nodeUrl, final RMDeployingNode lostNode) {
    return setPersistedInfraVariable(() -> {
        RMDeployingNode previousLostNode = this.lostNodesMap.put(nodeUrl, lostNode);
        getPersistedLostNodesUrl().add(nodeUrl);
        return previousLostNode;
    });
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)

Example 18 with RMDeployingNode

use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode 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());
            emitNodeEvent(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 19 with RMDeployingNode

use of org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode 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(), e);
        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());
        emitNodeEvent(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 20 with RMDeployingNode

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

the class InfrastructureManagerTest method testGetDeployingNodeUnknownNode.

@Test
public void testGetDeployingNodeUnknownNode() {
    RMDeployingNode rmNode = new RMDeployingNode("deploying", nodeSource, "command", null);
    assertThat(infrastructureManager.getDeployingNodesWithLock()).hasSize(0);
    assertThat(infrastructureManager.getPersistedDeployingNodesUrl()).hasSize(0);
    assertThat(infrastructureManager.getLostNodesWithLock()).hasSize(0);
    assertThat(infrastructureManager.getPersistedLostNodesUrl()).hasSize(0);
    RMDeployingNode rmNodeFound = infrastructureManager.getDeployingOrLostNode(rmNode.getNodeURL());
    assertThat(rmNodeFound).isNull();
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) Test(org.junit.Test)

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