Search in sources :

Example 6 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException in project scheduling by ow2-proactive.

the class RMMonitoringImpl method removeRMEventListener.

/**
 * Removes a listener from RMMonitoring. Only listener itself must call this method
 */
public void removeRMEventListener() throws RMException {
    UniqueID id = PAActiveObject.getContext().getCurrentRequest().getSourceBodyID();
    String shortId = id.shortString();
    if (removeRMEventListener(id)) {
        logger.debug("Removing the RM listener for " + shortId);
    } else {
        throw new RMException("Unknown listener found: " + shortId);
    }
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 7 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException 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);
    // 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);
    }
    boolean isNodeAdded = rmcore.registerAvailableNode(rmNode).getBooleanValue();
    if (isNodeAdded) {
        // if the node is successfully added we can let it configure
        // asynchronously. It will then be seen as "configuring"
        rmcore.internalRegisterConfiguringNode(rmNode);
        return new BooleanWrapper(true);
    } else {
        return new BooleanWrapper(false);
    }
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) AbstractRMNode(org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode) RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) 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) AddingNodesException(org.ow2.proactive.resourcemanager.exception.AddingNodesException) RMException(org.ow2.proactive.resourcemanager.exception.RMException) RMException(org.ow2.proactive.resourcemanager.exception.RMException) AbstractRMNode(org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode)

Example 8 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException 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);
    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 9 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException in project scheduling by ow2-proactive.

the class BatchJobInfrastructure method removeNode.

/**
 * {@inheritDoc}
 */
@Override
public void removeNode(Node node) throws RMException {
    String deleteCmd = getDeleteJobCommand();
    String jobID = null;
    String nodeName = node.getNodeInformation().getName();
    if ((jobID = getCurrentNode(nodeName)) != null) {
        try {
            deleteJob(jobID);
        } catch (RMException e) {
            logger.warn(deleteCmd + " command failed, cannot ensure job " + jobID + " is deleted. Anyway, node " + nodeName + " is removed from the infrastructure manager.", e);
        }
        // atomic remove is important, furthermore we ensure consistent
        // trace
        writeLock.lock();
        try {
            removeCurrentNode(nodeName);
            logger.debug("Node " + nodeName + " removed. # of current nodes: " + getCurrentNodesSize() + " # of deploying nodes: " + getNbDeployingNodes());
        } catch (RuntimeException e) {
            logger.error("Exception while removing a node: " + e.getMessage());
            throw e;
        } finally {
            writeLock.unlock();
        }
    } else {
        logger.error("Node " + nodeName + " is not known as a Node belonging to this " + getClass().getSimpleName());
    }
}
Also used : Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 10 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException in project scheduling by ow2-proactive.

the class BatchJobInfrastructure method handleFailedDeployment.

/**
 * Creates a lost node to notify the user that the deployment
 * has failed because of an error
 *
 * @param clb
 * @param e
 *            the error that caused the deployment to failed.
 * @throws RMException
 */
private void handleFailedDeployment(CommandLineBuilder clb, Throwable e) throws RMException {
    String error = getStackTraceAsString(e);
    String command = null;
    try {
        command = clb.buildCommandLine(false);
    } catch (Exception ex) {
        command = "Cannot determine the command used to start the node.";
    }
    String lostNode = super.addDeployingNode(clb.getNodeName(), command, "Cannot deploy the node because of an error:" + System.lineSeparator() + error, 60000);
    super.declareDeployingNodeLost(lostNode, null);
    throw new RMException("The deployment failed because of an error", e);
}
Also used : Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString) KeyException(java.security.KeyException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) RMException(org.ow2.proactive.resourcemanager.exception.RMException) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Aggregations

RMException (org.ow2.proactive.resourcemanager.exception.RMException)19 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)9 IOException (java.io.IOException)8 Node (org.objectweb.proactive.core.node.Node)8 KeyException (java.security.KeyException)6 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)6 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)5 CredData (org.ow2.proactive.authentication.crypto.CredData)4 UnknownHostException (java.net.UnknownHostException)3 Test (org.junit.Test)3 Credentials (org.ow2.proactive.authentication.crypto.Credentials)3 AbstractRMNode (org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode)3 CommandLineBuilder (org.ow2.proactive.resourcemanager.utils.CommandLineBuilder)3 Permission (java.security.Permission)2 ArrayList (java.util.ArrayList)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)2 RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)2