Search in sources :

Example 61 with NodeSource

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

the class RMRest method createNodeSource.

/**
 * @deprecated  As of version 8.1, replaced by {@link #defineNodeSource(String, String,String, String[], String[],
 * String, String[], String[], String)} and {@link #deployNodeSource(String, String)}
 *
 * Create a NodeSource
 * <p>
 *
 * @param sessionId
 *            current session id
 * @param nodeSourceName
 *            name of the node source to create
 * @param infrastructureType
 *            fully qualified class name of the infrastructure to create
 * @param infrastructureParameters
 *            String parameters of the infrastructure, without the
 *            parameters containing files or credentials
 * @param infrastructureFileParameters
 *            File or credential parameters
 * @param policyType
 *            fully qualified class name of the policy to create
 * @param policyParameters
 *            String parameters of the policy, without the parameters
 *            containing files or credentials
 * @param policyFileParameters
 *            File or credential parameters
 * @param nodesRecoverable
 *            Whether the nodes can be recovered after a crash of the RM
 * @return true if a node source has been created
 * @throws NotConnectedException
 */
@Deprecated
@Override
@POST
@Path("nodesource/create/recovery")
@Produces("application/json")
public NSState createNodeSource(@HeaderParam("sessionid") String sessionId, @FormParam("nodeSourceName") String nodeSourceName, @FormParam("infrastructureType") String infrastructureType, @FormParam("infrastructureParameters") String[] infrastructureParameters, @FormParam("infrastructureFileParameters") String[] infrastructureFileParameters, @FormParam("policyType") String policyType, @FormParam("policyParameters") String[] policyParameters, @FormParam("policyFileParameters") String[] policyFileParameters, @FormParam("nodesRecoverable") String nodesRecoverable) throws NotConnectedException {
    ResourceManager rm = checkAccess(sessionId);
    NSState nsState = new NSState();
    Object[] allInfrastructureParameters = this.getAllInfrastructureParameters(infrastructureType, infrastructureParameters, infrastructureFileParameters, rm);
    Object[] allPolicyParameters = this.getAllPolicyParameters(policyType, policyParameters, policyFileParameters, rm);
    try {
        nsState.setResult(rm.createNodeSource(nodeSourceName, infrastructureType, allInfrastructureParameters, policyType, allPolicyParameters, Boolean.parseBoolean(nodesRecoverable)).getBooleanValue());
    } catch (RuntimeException ex) {
        nsState.setResult(false);
        nsState.setErrorMessage(cleanDisplayedErrorMessage(ex.getMessage()));
        nsState.setStackTrace(StringEscapeUtils.escapeJson(getStackTrace(ex)));
    } finally {
        return nsState;
    }
}
Also used : ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) NSState(org.ow2.proactive.resourcemanager.common.NSState) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 62 with NodeSource

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

the class RMRest method undeployNodeSource.

/**
 * Remove the nodes of the node source and keep the node source undeployed
 *
 * @param sessionId a valid session id
 * @param nodeSourceName the name of the node source to undeploy
 * @return the result of the action, possibly containing the error message
 * @throws NotConnectedException
 */
@Override
@PUT
@Path("nodesource/undeploy")
@Produces("application/json")
public NSState undeployNodeSource(@HeaderParam("sessionid") String sessionId, @FormParam("nodeSourceName") String nodeSourceName, @FormParam("preempt") boolean preempt) throws NotConnectedException {
    ResourceManager rm = checkAccess(sessionId);
    NSState nsState = new NSState();
    try {
        nsState.setResult(rm.undeployNodeSource(nodeSourceName, preempt).getBooleanValue());
    } catch (RuntimeException ex) {
        nsState.setResult(false);
        nsState.setErrorMessage(cleanDisplayedErrorMessage(ex.getMessage()));
        nsState.setStackTrace(StringEscapeUtils.escapeJson(getStackTrace(ex)));
    }
    return nsState;
}
Also used : ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) NSState(org.ow2.proactive.resourcemanager.common.NSState) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 63 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 64 with NodeSource

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

the class NodesRecoveryManager method recoverFullyDeployedInfrastructureOrReset.

protected boolean recoverFullyDeployedInfrastructureOrReset(String nodeSourceName, NodeSource nodeSourceToDeploy, NodeSourceDescriptor descriptor) {
    boolean recoverNodes = false;
    boolean existPersistedNodes = this.existPersistedNodes(nodeSourceName);
    if (existPersistedNodes) {
        InfrastructureManager im = InfrastructureManagerFactory.recover(descriptor);
        if (!im.getDeployingAndLostNodes().isEmpty()) {
            // if there are deploying nodes, we will not recover
            this.rmCore.getDbManager().removeAllNodesFromNodeSource(nodeSourceName);
        } else {
            recoverNodes = true;
            nodeSourceToDeploy.setInfrastructureManager(im);
        }
    }
    return recoverNodes;
}
Also used : InfrastructureManager(org.ow2.proactive.resourcemanager.nodesource.infrastructure.InfrastructureManager)

Example 65 with NodeSource

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

the class NodesRecoveryManager method recoverNodes.

protected void recoverNodes(NodeSource nodeSource) {
    // this log line is important for performance tests
    logger.info(START_TO_RECOVER_NODES);
    int lookUpTimeout = PAResourceManagerProperties.RM_NODELOOKUP_TIMEOUT.getValueAsInt();
    String nodeSourceName = nodeSource.getName();
    this.logWarnIfNodeSourceHasNoNode(nodeSource, nodeSourceName);
    Collection<RMNodeData> nodesData = this.rmCore.getDbManager().getNodesByNodeSource(nodeSourceName);
    logger.info("Number of nodes found in database for node source " + nodeSourceName + ": " + nodesData.size());
    List<RMNode> recoveredEligibleNodes = Collections.synchronizedList(new ArrayList<RMNode>());
    Map<NodeState, Integer> recoveredNodeStatesCounter = new HashMap<>();
    // as down node
    for (RMNodeData rmNodeData : nodesData) {
        String nodeUrl = rmNodeData.getNodeUrl();
        Node node = this.tryToLookupNode(nodeSource, lookUpTimeout, nodeUrl);
        RMNode rmnode = this.recoverRMNode(nodeSource, recoveredNodeStatesCounter, rmNodeData, nodeUrl, node);
        if (this.isEligible(rmnode)) {
            recoveredEligibleNodes.add(rmnode);
        }
    }
    this.rmCore.setEligibleNodesToRecover(recoveredEligibleNodes);
    this.logNodeRecoverySummary(nodeSourceName, recoveredNodeStatesCounter, recoveredEligibleNodes.size());
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) NodeState(org.ow2.proactive.resourcemanager.common.NodeState) HashMap(java.util.HashMap) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData)

Aggregations

NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)21 Test (org.junit.Test)17 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)13 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)11 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)11 Client (org.ow2.proactive.resourcemanager.authentication.Client)9 Node (org.objectweb.proactive.core.node.Node)8 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)7 ArrayList (java.util.ArrayList)6 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)6 Permission (java.security.Permission)5 NodeSourceData (org.ow2.proactive.resourcemanager.db.NodeSourceData)5 RMException (org.ow2.proactive.resourcemanager.exception.RMException)5 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)4 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Matchers.anyString (org.mockito.Matchers.anyString)4