Search in sources :

Example 51 with NodeSource

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

the class RMCore method defineNodeSource.

/**
 * {@inheritDoc}
 */
@Override
public BooleanWrapper defineNodeSource(String nodeSourceName, String infrastructureType, Object[] infraParams, String policyType, Object[] policyParams, boolean nodesRecoverable) {
    this.validateNodeSourceNameOrFail(nodeSourceName);
    nodeSourceName = nodeSourceName.trim();
    logger.info("Define node source " + nodeSourceName + REQUESTED_BY_STRING + this.caller.getName());
    NodeSourceDescriptor nodeSourceDescriptor = this.persistNodeSourceAndGetDescriptor(nodeSourceName, infrastructureType, infraParams, policyType, policyParams, nodesRecoverable);
    NodeSource nodeSource = this.createNodeSourceInstance(nodeSourceDescriptor);
    this.definedNodeSources.put(nodeSourceName, nodeSource);
    this.monitoring.nodeSourceEvent(new RMNodeSourceEvent(RMEventType.NODESOURCE_DEFINED, this.caller.getName(), nodeSourceName, nodeSource.getDescription(), nodeSourceDescriptor.getProvider().getName(), nodeSource.getStatus().toString()));
    logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully defined");
    return new BooleanWrapper(true);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) NodeSourceDescriptor(org.ow2.proactive.resourcemanager.nodesource.NodeSourceDescriptor)

Example 52 with NodeSource

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

the class RMCore method shutDownNodeSourceIfDeployed.

private void shutDownNodeSourceIfDeployed(String nodeSourceName, boolean preempt) {
    if (this.deployedNodeSources.containsKey(nodeSourceName)) {
        NodeSource nodeSourceToRemove = this.deployedNodeSources.get(nodeSourceName);
        this.removeAllNodes(nodeSourceName, preempt);
        // delegate the removal process to the node source that will
        // eventually do a call back to remove the node source from the
        // deployed node sources map
        nodeSourceToRemove.shutdown(this.caller);
    }
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource)

Example 53 with NodeSource

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

the class RMCore method executeScript.

/**
 * {@inheritDoc}
 */
public <T> List<ScriptResult<T>> executeScript(Script<T> script, String targetType, Set<String> targets) {
    // Depending on the target type, select nodes for script execution
    final TargetType tType = TargetType.valueOf(targetType);
    final HashSet<RMNode> selectedRMNodes = new HashSet<>();
    switch(tType) {
        case NODESOURCE_NAME:
            // If target is a nodesource name select all its nodes
            for (String target : targets) {
                NodeSource nodeSource = this.deployedNodeSources.get(target);
                if (nodeSource != null) {
                    for (RMNode candidateNode : this.allNodes.values()) {
                        if (candidateNode.getNodeSource().equals(nodeSource)) {
                            this.selectCandidateNode(selectedRMNodes, candidateNode);
                        }
                    }
                }
            }
            break;
        case NODE_URL:
            // If target is node url select the node
            for (String target : targets) {
                RMNode candidateNode = this.allNodes.get(target);
                if (candidateNode != null) {
                    this.selectCandidateNode(selectedRMNodes, candidateNode);
                }
            }
            break;
        case HOSTNAME:
            // If target is hostname select first node from that host
            for (String target : targets) {
                for (RMNode node : this.allNodes.values()) {
                    if (node.getHostName().equals(target)) {
                        this.selectCandidateNode(selectedRMNodes, node);
                        break;
                    }
                }
            }
            break;
        default:
            throw new IllegalArgumentException("Unable to execute script, unknown target type: " + targetType);
    }
    // Return a ProActive future on the list of results
    return this.selectionManager.executeScript(script, selectedRMNodes, null);
// To avoid blocking rmcore ao the call is delegated to the selection
// manager ao and each node is unlocked as soon as the script has
// finished it's execution.
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) TargetType(org.ow2.proactive.resourcemanager.utils.TargetType) HashSet(java.util.HashSet)

Example 54 with NodeSource

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

the class NodeSource method detectedPingedDownNode.

/**
 * Marks node as down. Remove it from node source node set. It remains in rmcore nodes list until
 * user decides to remove them or node source is shutdown.
 * @see NodeSource#detectedPingedDownNode(String, String)
 */
public void detectedPingedDownNode(String nodeName, String nodeUrl) {
    if (toShutdown) {
        logger.warn("[" + name + "] detectedPingedDownNode request discarded because node source is shutting down");
        return;
    }
    logger.warn("[" + name + "] Detected down node: " + nodeUrl);
    Node downNode = nodes.remove(nodeUrl);
    if (downNode != null) {
        downNodes.put(nodeUrl, downNode);
        try {
            RMCore.topologyManager.removeNode(downNode);
            infrastructureManager.internalNotifyDownNode(nodeName, nodeUrl, downNode);
        } catch (RMException e) {
            logger.error("Error while removing down node: " + nodeUrl, e);
        }
    } else {
        // almost no information about the node apart from its name and url
        try {
            infrastructureManager.internalNotifyDownNode(nodeName, nodeUrl, null);
        } catch (RMException e) {
            logger.error("New empty node " + nodeUrl + " could not be created to handle down node", e);
        }
    }
    rmcore.setDownNode(nodeUrl);
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) AbstractRMNode(org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 55 with NodeSource

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

the class NodeSource method initActivity.

/**
 * Initialization of node source. Creates and activates a pinger to monitor nodes.
 *
 * @param body active object body
 */
public void initActivity(Body body) {
    this.stub = (NodeSource) PAActiveObject.getStubOnThis();
    this.infrastructureManager.setNodeSource(this);
    // Infrastructure has been configured and linked to the node source, so we can now persist the runtime
    // variables of the infrastructure for the first time (they have been initialized during the creation of the
    // infrastructure, in its configuration.
    this.infrastructureManager.persistInfrastructureVariables();
    this.activePolicy.setNodeSource((NodeSource) PAActiveObject.getStubOnThis());
    // Set permissions again according to the activated node source policy
    // node source admin permission
    // it's the PrincipalPermission of the user who created the node source
    this.adminPermission = new PrincipalPermission(this.administrator.getName(), this.administrator.getSubject().getPrincipals(UserNamePrincipal.class));
    // creating node source provider permission
    // could be one of the following: PrincipalPermission (NS creator) or PrincipalPermission (NS creator groups)
    // or PrincipalPermission (anyone)
    this.providerPermission = new PrincipalPermission(this.administrator.getName(), this.activePolicy.getProviderAccessType().getIdentityPrincipals(this.administrator));
    this.nodeUserAccessType = this.activePolicy.getUserAccessType();
    Thread.currentThread().setName("Node Source \"" + this.name + "\"");
}
Also used : PrincipalPermission(org.ow2.proactive.permissions.PrincipalPermission)

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