Search in sources :

Example 51 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class RMCore method getNodes.

/**
 * {@inheritDoc}
 */
public NodeSet getNodes(int number, TopologyDescriptor topology, List<SelectionScript> selectionScrips, NodeSet exclusion, boolean bestEffort) {
    Criteria criteria = new Criteria(number);
    criteria.setTopology(topology);
    criteria.setScripts(selectionScrips);
    criteria.setBlackList(exclusion);
    criteria.setBestEffort(bestEffort);
    return getNodes(criteria);
}
Also used : Criteria(org.ow2.proactive.utils.Criteria)

Example 52 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class RMCore method areNodesRecoverable.

@Override
public boolean areNodesRecoverable(NodeSet nodes) {
    Set<String> nodesURL = nodes.getAllNodesUrls();
    for (String nodeURL : nodesURL) {
        RMNode rmNode = allNodes.get(nodeURL);
        if (rmNode == null || !rmNode.getNodeSource().nodesRecoverable()) {
            logger.debug("RMNode corresponding to URL " + nodeURL + " is not recoverable");
            return false;
        }
    }
    logger.debug("All given nodes are recoverable");
    return true;
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode)

Example 53 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class SchedulingMethodImpl method getRMNodes.

/**
 * Ask to the RM the given number of node resources.<br>
 * If there is a problem with these task selection (such as bad selectionScript) this method
 * will terminate the corresponding tasks and jobs. As the selection scripts contain errors, the task
 * and its surrounding jobs must be stopped.
 *
 * @param neededResourcesNumber the number of resources to ask for (must be &gt; 0).
 * @param tasksToSchedule the task to be scheduled
 * @return A nodeSet that contains at most 'neededResourcesNumber' available compatible resources.
 * 		   An empty nodeSet if no nodes could be found
 * 		   null if the their was an exception when asking for the nodes (ie : selection script has failed)
 */
protected NodeSet getRMNodes(Map<JobId, JobDescriptor> jobMap, int neededResourcesNumber, LinkedList<EligibleTaskDescriptor> tasksToSchedule, Set<String> freeResources) {
    NodeSet nodeSet;
    if (neededResourcesNumber <= 0) {
        throw new IllegalArgumentException("'neededResourcesNumber' must be greater than 0");
    }
    EligibleTaskDescriptor etd = tasksToSchedule.getFirst();
    InternalJob currentJob = ((JobDescriptorImpl) jobMap.get(etd.getJobId())).getInternal();
    InternalTask internalTask0 = currentJob.getIHMTasks().get(etd.getTaskId());
    try {
        TopologyDescriptor descriptor = null;
        boolean bestEffort = true;
        if (internalTask0.isParallel()) {
            descriptor = internalTask0.getParallelEnvironment().getTopologyDescriptor();
            bestEffort = false;
            if (descriptor == null) {
                logger.debug("Topology is not defined for the task " + internalTask0.getName());
            }
        }
        if (descriptor == null) {
            // descriptor is not defined, use default
            descriptor = TopologyDescriptor.ARBITRARY;
        }
        try {
            Criteria criteria = new Criteria(neededResourcesNumber);
            criteria.setTopology(descriptor);
            // resolve script variables (if any) in the list of selection
            // scripts and then set it as the selection criteria.
            criteria.setScripts(resolveScriptVariables(internalTask0.getSelectionScripts(), internalTask0.getRuntimeVariables()));
            criteria.setBlackList(internalTask0.getNodeExclusion());
            criteria.setBestEffort(bestEffort);
            criteria.setAcceptableNodesUrls(freeResources);
            criteria.setBindings(createBindingsForSelectionScripts(currentJob, internalTask0));
            if (internalTask0.getRuntimeGenericInformation().containsKey(SchedulerConstants.NODE_ACCESS_TOKEN)) {
                criteria.setNodeAccessToken(internalTask0.getRuntimeGenericInformation().get(SchedulerConstants.NODE_ACCESS_TOKEN));
            }
            Collection<String> computationDescriptors = new ArrayList<>(tasksToSchedule.size());
            for (EligibleTaskDescriptor task : tasksToSchedule) {
                computationDescriptors.add(TaskLogger.getTaskLogRelativePath(task.getTaskId()));
            }
            criteria.setComputationDescriptors(computationDescriptors);
            nodeSet = getRMProxiesManager().getUserRMProxy(currentJob.getOwner(), currentJob.getCredentials()).getNodes(criteria);
        } catch (TopologyDisabledException tde) {
            jlogger.warn(currentJob.getId(), "will be canceled as the topology is disabled");
            schedulingService.simulateJobStartAndCancelIt(tasksToSchedule, "Topology is disabled");
            return null;
        }
        // the following line is used to unwrap the future, warning when moving or removing
        // it may also throw a ScriptException which is a RuntimeException
        PAFuture.waitFor(nodeSet, true);
        logger.debug("provided nodes " + nodeSet.size());
        return nodeSet;
    } catch (IOException | ClassNotFoundException e) {
        logger.warn("Failed to deserialize previous task variables before selection for task " + internalTask0.getId().toString(), e);
        schedulingService.simulateJobStartAndCancelIt(tasksToSchedule, "Failed to deserialize previous task variables before selection for task " + internalTask0.getId().toString());
        return null;
    } catch (RMProxyCreationException e) {
        logger.warn("Failed to create User RM Proxy", e);
        // simulate jobs starts and cancel it
        schedulingService.simulateJobStartAndCancelIt(tasksToSchedule, "Failed to create User RM Proxy : Authentication Failed to Resource Manager for user '" + currentJob.getOwner() + "'");
        // leave the method by ss failure
        return null;
    }
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) Criteria(org.ow2.proactive.utils.Criteria) IOException(java.io.IOException) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) RMProxyCreationException(org.ow2.proactive.scheduler.core.rmproxies.RMProxyCreationException) TopologyDisabledException(org.ow2.proactive.resourcemanager.frontend.topology.TopologyDisabledException) TopologyDescriptor(org.ow2.proactive.topology.descriptor.TopologyDescriptor)

Example 54 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class RMProxyActiveObject method cleanCallBack.

/**
 * Called when a script has returned (call is made as an active object call)
 * <p>
 * Check the nodes to release and release the one that have to (clean script has returned)
 * Take care when renaming this method, method name is linked to
 * {@link #handleCleaningScript(NodeSet, Script, VariablesMap, Map, TaskId, Credentials)}
 */
@ImmediateService
public synchronized void cleanCallBack(Future<ScriptResult<?>> future, NodeSet nodes) {
    String nodeUrl = nodes.get(0).getNodeInformation().getURL();
    ScriptResult<?> sResult = null;
    TaskId taskId = nodesTaskId.get(nodes);
    try {
        sResult = future.get();
    } catch (Exception e) {
        logger.error("Exception occurred while executing cleaning script on node " + nodeUrl + ":", e);
    }
    printCleaningScriptInformations(nodes, sResult, taskId);
    releaseNodes(nodes);
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) LoginException(javax.security.auth.login.LoginException) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 55 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class TestRMProxy method requestTooManyNodes.

private void requestTooManyNodes(RMProxy proxy, ResourceManager rm) throws Exception {
    log("Request more nodes than RM has");
    Criteria criteria = new Criteria(NODES_NUMBER + 1);
    criteria.setBestEffort(false);
    NodeSet nodeSet = proxy.getNodes(criteria);
    PAFuture.waitFor(nodeSet);
    assertEquals(0, nodeSet.size());
    assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria)

Aggregations

NodeSet (org.ow2.proactive.utils.NodeSet)51 Test (org.junit.Test)28 Criteria (org.ow2.proactive.utils.Criteria)23 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)20 Node (org.objectweb.proactive.core.node.Node)18 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)17 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)12 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)11 SelectionScript (org.ow2.proactive.scripting.SelectionScript)10 File (java.io.File)9 TestNode (functionaltests.utils.TestNode)8 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)7 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)5 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)5 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)4 RMState (org.ow2.proactive.resourcemanager.common.RMState)4 IOException (java.io.IOException)3 Permission (java.security.Permission)3 HashSet (java.util.HashSet)3