Search in sources :

Example 71 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class RMCore method removeDeployingNode.

/**
 * To handle the deploying node removal
 *
 * @param url the url of the deploying node to remove
 * @return true if successful, false otherwise
 */
private boolean removeDeployingNode(String url) {
    String nsName = "";
    try {
        URI urlObj = new URI(url);
        nsName = urlObj.getHost();
    } catch (URISyntaxException e) {
        logger.warn("No such deploying node: " + url);
        return false;
    }
    if (nsName == null) {
        // cannot compute the nsName using URI, try using Pattern
        Matcher matcher = Pattern.compile(RMDeployingNode.PROTOCOL_ID + "://([-\\w]+)/.+").matcher(url);
        if (matcher.find()) {
            try {
                nsName = matcher.group(1);
            } catch (IndexOutOfBoundsException e) {
                logger.debug("Was not able to determine nodesource's name for url " + url);
            }
        }
    }
    NodeSource ns = this.deployedNodeSources.get(nsName);
    if (ns == null) {
        logger.warn("No such nodesource: " + nsName + ", cannot remove the deploying node with url: " + url);
        return false;
    }
    return ns.removeDeployingNode(url);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) Matcher(java.util.regex.Matcher) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 72 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class RMCore method emitNodeSourceEvent.

private void emitNodeSourceEvent(NodeSource nodeSource, RMEventType eventType) {
    NodeSourceDescriptor descriptor = nodeSource.getDescriptor();
    this.monitoring.nodeSourceEvent(new RMNodeSourceEvent(eventType, this.caller.getName(), descriptor.getName(), nodeSource.getDescription(), nodeSource.getAdditionalInformation(), descriptor.getProvider().getName(), nodeSource.getStatus().toString()));
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) NodeSourceDescriptor(org.ow2.proactive.resourcemanager.nodesource.NodeSourceDescriptor)

Example 73 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class RMCore method undeployNodeSource.

/**
 * {@inheritDoc}
 */
public BooleanWrapper undeployNodeSource(String nodeSourceName, boolean preempt) {
    logger.info("Undeploy node source " + nodeSourceName + " with preempt=" + preempt + REQUESTED_BY_STRING + this.caller.getName());
    if (!this.definedNodeSources.containsKey(nodeSourceName)) {
        throw new IllegalArgumentException("Unknown node source " + nodeSourceName);
    }
    if (this.deployedNodeSources.containsKey(nodeSourceName)) {
        NodeSource nodeSourceToRemove = this.deployedNodeSources.get(nodeSourceName);
        this.caller.checkPermission(nodeSourceToRemove.getAdminPermission(), this.caller + " is not authorized to undeploy " + nodeSourceName, new RMCoreAllPermission(), new NSAdminPermission());
        nodeSourceToRemove.setStatus(NodeSourceStatus.NODES_UNDEPLOYED);
        this.removeAllNodes(nodeSourceName, preempt);
        this.updateNodeSourceDescriptorWithStatusAndPersist(this.definedNodeSources.get(nodeSourceName).getDescriptor(), NodeSourceStatus.NODES_UNDEPLOYED);
        this.nodeSourceUnregister(nodeSourceName, NodeSourceStatus.NODES_UNDEPLOYED, new RMNodeSourceEvent(RMEventType.NODESOURCE_SHUTDOWN, this.caller.getName(), nodeSourceName, nodeSourceToRemove.getDescription(), nodeSourceToRemove.getAdditionalInformation(), nodeSourceToRemove.getAdministrator().getName(), NodeSourceStatus.NODES_UNDEPLOYED.toString()));
        // asynchronously delegate the removal process to the node source
        nodeSourceToRemove.shutdown(this.caller);
    }
    return new BooleanWrapper(true);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMCoreAllPermission(org.ow2.proactive.permissions.RMCoreAllPermission) NSAdminPermission(org.ow2.proactive.permissions.NSAdminPermission) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper)

Example 74 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class CommandLineBuilder method buildCommandLineAsList.

/**
 * Same as {@link CommandLineBuilder#buildCommandLine(boolean)} but the command is a list of String.
 * @param displayCredentials if true displays the credentials in the command line if false, obfuscates them
 * @return The RMNodeStarter command line as a list of String.
 * @throws java.io.IOException if you supplied a ProActive Configuration file that doesn't exist.
 */
public List<String> buildCommandLineAsList(boolean displayCredentials) throws IOException {
    final ArrayList<String> command = new ArrayList<>();
    final OperatingSystem os = targetOS;
    final Properties paProp = paPropProperties;
    String rmHome = this.getRmHome();
    if (rmHome != null) {
        if (!rmHome.endsWith(os.fs)) {
            rmHome = rmHome + os.fs;
        }
    } else {
        rmHome = "";
    }
    if (detached) {
        makeDetachedCommand(command, os);
    }
    final String libRoot = rmHome + "dist" + os.fs + "lib" + os.fs;
    String javaPath = this.javaPath;
    if (javaPath != null) {
        command.add(javaPath);
    } else {
        RMNodeStarter.logger.warn("Java path isn't set in RMNodeStarter configuration.");
        command.add("java");
    }
    // building configuration
    if (paProp != null) {
        Set<Object> keys = paProp.keySet();
        for (Object key : keys) {
            command.add("-D" + key + "=" + paProp.get(key));
        }
    } else {
        if (this.paPropList != null) {
            command.addAll(this.paPropList);
        }
    }
    // forward current charset to the forked JVM
    String currentJvmCharset = PAProperties.getFileEncoding();
    command.add("-Dfile.encoding=" + currentJvmCharset);
    RMNodeStarter.logger.info("Using '" + currentJvmCharset + "' as file encoding");
    // building classpath
    command.add("-cp");
    final StringBuilder classpath = new StringBuilder(".");
    // add the content of addons dir on the classpath
    classpath.append(os.ps).append(rmHome).append(ADDONS_DIR);
    // add jars inside the addons directory
    classpath.append(os.ps).append(rmHome).append(ADDONS_DIR).append(os.fs).append("*");
    classpath.append(os.ps).append(libRoot).append("*");
    command.add(classpath.toString());
    command.add(RMNodeStarter.class.getName());
    // appending options
    String credsEnv = credentialsEnv;
    if (credsEnv != null) {
        command.add("-" + RMNodeStarter.OPTION_CREDENTIAL_ENV);
        command.add(credsEnv);
    }
    String credsFile = this.getCredentialsFile();
    if (credsFile != null) {
        command.add("-" + RMNodeStarter.OPTION_CREDENTIAL_FILE);
        command.add(credsFile);
    }
    String credsValue = this.getCredentialsValue();
    if (credsValue != null) {
        command.add("-" + RMNodeStarter.OPTION_CREDENTIAL_VAL);
        command.add(displayCredentials ? credsValue : OBFUSC);
    }
    String nodename = this.getNodeName();
    if (nodename != null) {
        command.add("-" + RMNodeStarter.OPTION_NODE_NAME);
        command.add(nodename);
    }
    String nodesource = this.getSourceName();
    if (nodesource != null) {
        command.add("-" + RMNodeStarter.OPTION_SOURCE_NAME);
        command.add(nodesource);
    }
    String rmurl = rmURL;
    if (rmurl != null) {
        command.add("-" + RMNodeStarter.OPTION_RM_URL);
        command.add(rmurl);
    }
    command.add("-" + RMNodeStarter.OPTION_WORKERS);
    command.add("" + nbNodes);
    if (detached && os.equals(OperatingSystem.UNIX)) {
        command.add("&");
    }
    return command;
}
Also used : ArrayList(java.util.ArrayList) PAResourceManagerProperties(org.ow2.proactive.resourcemanager.core.properties.PAResourceManagerProperties) Properties(java.util.Properties) PAProperties(org.ow2.proactive.utils.PAProperties)

Example 75 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.

the class NodesRecoveryManager method recoverNode.

private RMNode recoverNode(RMNodeData rmNodeData, NodeSource nodeSource, Map<NodeState, Integer> recoveredNodeStatesCounter) {
    Node node = null;
    String nodeUrl = rmNodeData.getNodeUrl();
    NodeState previousState = rmNodeData.getState();
    boolean isPAMR = nodeUrl.startsWith(PAMRRemoteObjectFactory.PROTOCOL_ID + "://");
    boolean connected = false;
    long initialTime = System.currentTimeMillis();
    do {
        try {
            node = nodeSource.lookupNode(nodeUrl, PAResourceManagerProperties.RM_NODELOOKUP_TIMEOUT.getValueAsInt());
            logger.info("Node " + nodeUrl + " was looked up successfully");
            connected = true;
        } catch (Exception e) {
            if (isPAMR) {
                logger.debug("Node " + nodeUrl + " could not be looked up. Wait for PAMR agent reconnection delay.");
                Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
            } else {
                logger.error("Node " + nodeUrl + " could not be looked up.");
            }
        }
    } while (!connected && isPAMR && (System.currentTimeMillis() - initialTime) < Agent.MAXIMUM_RETRY_DELAY_MS);
    if (!connected) {
        node = new FakeDownNodeForRecovery(rmNodeData.getName(), rmNodeData.getNodeUrl(), rmNodeData.getHostname());
        rmNodeData.setState(NodeState.DOWN);
        if (isPAMR) {
            logger.error("Node " + nodeUrl + " could not be looked up.");
        }
    }
    return this.addRMNodeToCoreAndSource(nodeSource, recoveredNodeStatesCounter, rmNodeData, nodeUrl, node, previousState);
}
Also used : NodeState(org.ow2.proactive.resourcemanager.common.NodeState) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) AddingNodesException(org.ow2.proactive.resourcemanager.exception.AddingNodesException)

Aggregations

NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)32 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)19 Test (org.junit.Test)17 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)17 Node (org.objectweb.proactive.core.node.Node)12 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)12 RMException (org.ow2.proactive.resourcemanager.exception.RMException)11 Client (org.ow2.proactive.resourcemanager.authentication.Client)10 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)9 AddingNodesException (org.ow2.proactive.resourcemanager.exception.AddingNodesException)9 URISyntaxException (java.net.URISyntaxException)7 ArrayList (java.util.ArrayList)7 NSAdminPermission (org.ow2.proactive.permissions.NSAdminPermission)7 RMCoreAllPermission (org.ow2.proactive.permissions.RMCoreAllPermission)7 NodeSourceData (org.ow2.proactive.resourcemanager.db.NodeSourceData)7 ScriptException (org.ow2.proactive.scripting.ScriptException)7 HashSet (java.util.HashSet)6 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)6 NodeException (org.objectweb.proactive.core.node.NodeException)6 IOException (java.io.IOException)5