Search in sources :

Example 6 with NodeException

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

the class RMTHelper method createNode.

public static TestNode createNode(String nodeName, String expectedUrl, JVMProcess nodeProcess) throws IOException, NodeException, InterruptedException {
    Node newNode = null;
    long startTimeStamp = System.currentTimeMillis();
    NodeException toThrow = null;
    while ((System.currentTimeMillis() - startTimeStamp) < DEFAULT_NODES_TIMEOUT) {
        try {
            newNode = NodeFactory.getNode(expectedUrl);
        } catch (NodeException e) {
            toThrow = e;
        // nothing, wait another loop
        }
        if (newNode != null) {
            return new TestNode(nodeProcess, newNode);
        } else {
            Thread.sleep(100);
        }
    }
    throw toThrow == null ? new NodeException("unable to create the node " + nodeName) : toThrow;
}
Also used : StartNode(org.objectweb.proactive.core.node.StartNode) Node(org.objectweb.proactive.core.node.Node) NodeException(org.objectweb.proactive.core.node.NodeException)

Example 7 with NodeException

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

the class RMTHelper method createNode.

/**
 * Create a ProActive Node in a new JVM on the local host
 * with specific java parameters.
 * This method can be used to test adding nodes mechanism
 * with already deploy ProActive nodes.
 * @param nodeName node's name to create
 * @param vmParameters an HashMap containing key and value String
 * of type :-Dkey=value
 * @return created node URL
 * @throws IOException if the external JVM cannot be created
 * @throws NodeException if lookup of the new node fails.
 */
private static TestNode createNode(String nodeName, Map<String, String> vmParameters, List<String> vmOptions, int pnpPort) throws IOException, NodeException, InterruptedException {
    boolean exceptionOccurredWhileCreatingNode = false;
    NodeException lastException = null;
    int numberOfAttempts = 0;
    do {
        try {
            if (pnpPort <= 0) {
                pnpPort = findFreePort();
            }
            String nodeUrl = "pnp://localhost:" + pnpPort + "/" + nodeName;
            vmParameters.put(PNPConfig.PA_PNP_PORT.getName(), Integer.toString(pnpPort));
            JVMProcessImpl nodeProcess = createJvmProcess(StartNode.class.getName(), Collections.singletonList(nodeName), vmParameters, vmOptions);
            return createNode(nodeName, nodeUrl, nodeProcess);
        } catch (NodeException e) {
            exceptionOccurredWhileCreatingNode = true;
            lastException = e;
            numberOfAttempts++;
        }
    } while (exceptionOccurredWhileCreatingNode && numberOfAttempts < 20);
    throw lastException;
}
Also used : StartNode(org.objectweb.proactive.core.node.StartNode) JVMProcessImpl(org.objectweb.proactive.core.process.JVMProcessImpl) NodeException(org.objectweb.proactive.core.node.NodeException)

Example 8 with NodeException

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

the class RMNodeImpl method clean.

/**
 * Clean the node.
 * kill all active objects on the node.
 * @throws NodeException
 */
@Override
public synchronized void clean() throws NodeException {
    handler = null;
    try {
        logger.debug(getNodeURL() + " : cleaning");
        node.killAllActiveObjects();
    } catch (IOException e) {
        throw new NodeException("Node is down");
    }
    // Wait until all active objects are terminated
    waitUntilNodeIsCleaned();
}
Also used : NodeException(org.objectweb.proactive.core.node.NodeException) IOException(java.io.IOException)

Example 9 with NodeException

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

the class RMTHelper method killRuntime.

/**
 * Kills the runtime associated with specified node url
 *
 * @param url of the node
 * @throws NodeException if node cannot be looked up
 */
public static void killRuntime(String url) throws NodeException {
    try {
        Node node = NodeFactory.getNode(url);
        node.getProActiveRuntime().killRT(false);
    } catch (Exception ignored) {
    }
}
Also used : StartNode(org.objectweb.proactive.core.node.StartNode) Node(org.objectweb.proactive.core.node.Node) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) NodeException(org.objectweb.proactive.core.node.NodeException) AlreadyBoundException(java.rmi.AlreadyBoundException)

Example 10 with NodeException

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

the class RMTHelper method killNode.

/**
 * Kills the node with specified url
 * @param url of the node
 * @throws NodeException if node cannot be looked up
 */
public static void killNode(String url) throws NodeException {
    Node node = NodeFactory.getNode(url);
    try {
        ProActiveRuntime rt = node.getProActiveRuntime();
        rt.killNode(node.getNodeInformation().getName());
    } catch (Exception ignored) {
    }
}
Also used : StartNode(org.objectweb.proactive.core.node.StartNode) Node(org.objectweb.proactive.core.node.Node) ProActiveRuntime(org.objectweb.proactive.core.runtime.ProActiveRuntime) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) NodeException(org.objectweb.proactive.core.node.NodeException) AlreadyBoundException(java.rmi.AlreadyBoundException)

Aggregations

NodeException (org.objectweb.proactive.core.node.NodeException)13 IOException (java.io.IOException)5 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)5 Node (org.objectweb.proactive.core.node.Node)5 StartNode (org.objectweb.proactive.core.node.StartNode)4 InetAddress (java.net.InetAddress)3 LoginException (javax.security.auth.login.LoginException)3 HttpSession (javax.servlet.http.HttpSession)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)3 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)3 MalformedURLException (java.net.MalformedURLException)2 AlreadyBoundException (java.rmi.AlreadyBoundException)2 KeyException (java.security.KeyException)2 HashMap (java.util.HashMap)2 ExecutionException (java.util.concurrent.ExecutionException)2 Consumes (javax.ws.rs.Consumes)2 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)2