Search in sources :

Example 46 with ResourceManager

use of org.ow2.proactive.resourcemanager.frontend.ResourceManager in project scheduling by ow2-proactive.

the class RMRest method deployNodeSource.

/**
 * Start the nodes acquisition of the node source
 *
 * @param sessionId a valid session id
 * @param nodeSourceName the name of the node source to start
 * @return the result of the action, possibly containing the error message
 * @throws NotConnectedException
 */
@Override
@PUT
@Path("nodesource/deploy")
@Produces("application/json")
public NSState deployNodeSource(@HeaderParam("sessionid") String sessionId, @FormParam("nodeSourceName") String nodeSourceName) throws NotConnectedException {
    ResourceManager rm = checkAccess(sessionId);
    NSState nsState = new NSState();
    try {
        nsState.setResult(rm.deployNodeSource(nodeSourceName).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 47 with ResourceManager

use of org.ow2.proactive.resourcemanager.frontend.ResourceManager 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 48 with ResourceManager

use of org.ow2.proactive.resourcemanager.frontend.ResourceManager 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 49 with ResourceManager

use of org.ow2.proactive.resourcemanager.frontend.ResourceManager 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 50 with ResourceManager

use of org.ow2.proactive.resourcemanager.frontend.ResourceManager in project scheduling by ow2-proactive.

the class RMNodeStarter method allNodesAreAvailable.

private boolean allNodesAreAvailable(Map<String, Node> nodes, ResourceManager rm) {
    if (rm == null) {
        throw new NotConnectedException("No connection to RM");
    }
    Set<String> unknownNodeUrls = PAFuture.getFutureValue(rm.setNodesAvailable(ImmutableSet.copyOf(nodes.keySet())), nodeAvailabilityReportTimeoutDelay);
    for (String unknownNodeUrl : unknownNodeUrls) {
        killWorkerNodeIfRemovedByUser(nodes, unknownNodeUrl);
    }
    int nodeCount = nodes.size();
    if (logger.isDebugEnabled()) {
        logger.debug("Node count is equal to " + nodeCount);
    }
    return nodeCount > 0;
}
Also used : NotConnectedException(org.ow2.proactive.resourcemanager.exception.NotConnectedException) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString)

Aggregations

ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)45 NodeSet (org.ow2.proactive.utils.NodeSet)26 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)25 Test (org.junit.Test)25 Node (org.objectweb.proactive.core.node.Node)16 File (java.io.File)14 Credentials (org.ow2.proactive.authentication.crypto.Credentials)14 Criteria (org.ow2.proactive.utils.Criteria)13 HashMap (java.util.HashMap)11 CredData (org.ow2.proactive.authentication.crypto.CredData)11 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)11 RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)10 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)10 TestNode (functionaltests.utils.TestNode)9 SelectionScript (org.ow2.proactive.scripting.SelectionScript)9 RMMonitorEventReceiver (functionaltests.monitor.RMMonitorEventReceiver)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)5 PublicKey (java.security.PublicKey)4