Search in sources :

Example 71 with Node

use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.

the class CLIInfrastructure method killNodeImpl.

/**
 * {@inheritDoc}
 */
@Override
protected void killNodeImpl(Node node, InetAddress h) {
    final Node n = node;
    final InetAddress host = h;
    incrementNbRemovalThread();
    this.nodeSource.executeInParallel(new Runnable() {

        public void run() {
            try {
                final String commandLine = interpreter + " " + removalScript.getAbsolutePath() + " " + host.getHostName() + " " + n.getNodeInformation().getURL();
                Process p;
                try {
                    logger.debug("Launching the command: " + commandLine);
                    p = Runtime.getRuntime().exec(commandLine);
                    // TODO add timeout behavior
                    int exitCode = p.waitFor();
                    String pOutPut = Utils.extractProcessOutput(p);
                    String pErrPut = Utils.extractProcessErrput(p);
                    String lf = System.lineSeparator();
                    final String description = "Removal script ouput" + lf + "   >Error code: " + exitCode + lf + "   >Errput: " + pErrPut + "   >Output: " + pOutPut;
                    if (exitCode != 0) {
                        logger.error("Child process at " + host.getHostName() + " exited abnormally (" + exitCode + ").");
                        logger.error(description);
                    } else {
                        logger.info("Removal node process has exited normally for " + n.getNodeInformation().getURL());
                        logger.debug(description);
                    }
                } catch (IOException e1) {
                    logger.error(e1);
                }
            } catch (Exception e) {
                logger.trace("An exception occurred during node removal", e);
            }
            decrementNbRemovalThread();
        }
    });
}
Also used : Node(org.objectweb.proactive.core.node.Node) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString) IOException(java.io.IOException) InetAddress(java.net.InetAddress) IOException(java.io.IOException) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 72 with Node

use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.

the class DefaultInfrastructureManager method removeNode.

/**
 * {@inheritDoc}
 */
@Override
public void removeNode(Node node) throws RMException {
    try {
        logger.info("Terminating the node " + node.getNodeInformation().getName());
        if (!isThereNodesInSameJVM(node)) {
            final Node n = node;
            nodeSource.executeInParallel(new Runnable() {

                public void run() {
                    try {
                        logger.info("Terminating the runtime " + n.getProActiveRuntime().getURL());
                        n.getProActiveRuntime().killRT(false);
                    } catch (Exception e) {
                    // do nothing, no exception treatment for node just
                    // killed before
                    }
                }
            });
        }
        decrementNodesCount();
    } catch (Exception e) {
        throw new RMException(e);
    }
}
Also used : Node(org.objectweb.proactive.core.node.Node) RMException(org.ow2.proactive.resourcemanager.exception.RMException) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 73 with Node

use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.

the class RMRest method releaseNode.

/**
 * Release a node
 *
 * @param sessionId a valid session id
 * @param url node's URL
 * @return true of the node has been released
 * @throws NodeException
 * @throws NotConnectedException
 */
@Override
@POST
@Path("node/release")
@Produces("application/json")
public boolean releaseNode(@HeaderParam("sessionid") String sessionId, @FormParam("url") String url) throws NodeException, NotConnectedException {
    ResourceManager rm = checkAccess(sessionId);
    Node n;
    n = NodeFactory.getNode(url);
    return rm.releaseNode(n).getBooleanValue();
}
Also used : Node(org.objectweb.proactive.core.node.Node) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 74 with Node

use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.

the class HAC method initClusterDistances.

private HashMap<Cluster<Node>, HashMap<Cluster<Node>, Long>> initClusterDistances(List<Node> from) {
    if (pivot.size() > 0) {
        from = new LinkedList<>(from);
        for (Node piv : pivot) {
            if (!from.contains(piv))
                from.add(piv);
        }
    }
    HashMap<Cluster<Node>, HashMap<Cluster<Node>, Long>> clusterDistances = new HashMap<>();
    for (Node node : from) {
        Cluster<Node> newCluster = new Cluster<>(getNodeId(node), node);
        HashMap<Cluster<Node>, Long> dist = new HashMap<>();
        for (Cluster<Node> cluster : clusterDistances.keySet()) {
            dist.put(cluster, getDistance(node, cluster.getElements().get(0)));
        }
        clusterDistances.put(newCluster, dist);
    }
    return clusterDistances;
}
Also used : HashMap(java.util.HashMap) Node(org.objectweb.proactive.core.node.Node)

Example 75 with Node

use of org.objectweb.proactive.core.node.Node in project scheduling by ow2-proactive.

the class HostsPinger method ping.

/**
 * Pings remote nodes and returns distances to hosts where these nodes are located.
 *
 * @param nodes to ping
 * @return distances map to hosts where these nodes are located
 */
public HashMap<InetAddress, Long> ping(NodeSet nodes) {
    HashMap<InetAddress, Long> results = new HashMap<>();
    for (Node node : nodes) {
        try {
            InetAddress current = NodeFactory.getDefaultNode().getVMInformation().getInetAddress();
            InetAddress nodeAddress = node.getVMInformation().getInetAddress();
            if (current.equals(nodeAddress)) {
                // nodes on the same host
                results.put(nodeAddress, new Long(0));
            } else {
                results.put(nodeAddress, pingHost(nodeAddress));
            }
        } catch (NodeException e) {
        }
    }
    return results;
}
Also used : HashMap(java.util.HashMap) Node(org.objectweb.proactive.core.node.Node) NodeException(org.objectweb.proactive.core.node.NodeException) InetAddress(java.net.InetAddress)

Aggregations

Node (org.objectweb.proactive.core.node.Node)80 Test (org.junit.Test)28 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)21 NodeSet (org.ow2.proactive.utils.NodeSet)19 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)18 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)16 HashMap (java.util.HashMap)15 TestNode (functionaltests.utils.TestNode)11 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)11 NodeException (org.objectweb.proactive.core.node.NodeException)9 DefaultInfrastructureManager (org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager)9 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)9 Criteria (org.ow2.proactive.utils.Criteria)8 IOException (java.io.IOException)7 LinkedList (java.util.LinkedList)7 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)7 RMException (org.ow2.proactive.resourcemanager.exception.RMException)7 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)6 InetAddress (java.net.InetAddress)5 ArrayList (java.util.ArrayList)5