Search in sources :

Example 6 with TopologyDescriptor

use of org.ow2.proactive.topology.descriptor.TopologyDescriptor in project scheduling by ow2-proactive.

the class SelectionManagerTest method selectWithDifferentPermissions.

@Test
public void selectWithDifferentPermissions() throws Exception {
    PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER.updateProperty("10");
    System.out.println("PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER=" + PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER);
    System.setSecurityManager(securityManagerRejectingUser());
    RMCore.topologyManager = mock(TopologyManager.class);
    RMCore rmCore = mock(RMCore.class);
    when(RMCore.topologyManager.getHandler(Matchers.<TopologyDescriptor>any())).thenReturn(selectAllTopology());
    SelectionManager selectionManager = createSelectionManager(rmCore);
    ArrayList<RMNode> freeNodes = new ArrayList<>();
    freeNodes.add(createMockedNode("admin"));
    freeNodes.add(createMockedNode("user"));
    when(rmCore.getFreeNodes()).thenReturn(freeNodes);
    Criteria criteria = new Criteria(2);
    criteria.setTopology(TopologyDescriptor.ARBITRARY);
    Subject subject = Subjects.create("admin");
    NodeSet nodes = selectionManager.selectNodes(criteria, new Client(subject, false));
    assertEquals(1, nodes.size());
}
Also used : TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) ArrayList(java.util.ArrayList) Criteria(org.ow2.proactive.utils.Criteria) Client(org.ow2.proactive.resourcemanager.authentication.Client) Subject(javax.security.auth.Subject) Test(org.junit.Test)

Example 7 with TopologyDescriptor

use of org.ow2.proactive.topology.descriptor.TopologyDescriptor in project scheduling by ow2-proactive.

the class TopologyNodesFilterTest method unifedTestMethod.

private void unifedTestMethod(TopologyDescriptor topology, int requiredNodesNumber, Map<String, Integer> groupedNodeByHost, int outputNodesNumber) {
    Criteria crit = new Criteria(requiredNodesNumber);
    crit.setTopology(topology);
    crit.setScripts(null);
    crit.setBlackList(null);
    crit.setBestEffort(false);
    List<RMNode> arrangedNodes = new ArrayList<>();
    for (String host : groupedNodeByHost.keySet()) {
        for (int i = 0; i < groupedNodeByHost.get(host); i++) {
            arrangedNodes.add(createMockeNode(host));
        }
    }
    List<RMNode> arrangedFilteredNodes = new TopologyNodesFilter().filterNodes(crit, arrangedNodes);
    assertEquals(outputNodesNumber, arrangedFilteredNodes.size());
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) ArrayList(java.util.ArrayList) Criteria(org.ow2.proactive.utils.Criteria)

Example 8 with TopologyDescriptor

use of org.ow2.proactive.topology.descriptor.TopologyDescriptor in project scheduling by ow2-proactive.

the class Attribute method createParallelEnvironment.

/**
 * Creates the parallel environment element for the given task. Corresponds
 * to <define name="parallel">
 *
 * @return the {@link XMLTags#PARALLEL_ENV} element if the task has a
 *         parallel environment, null otherwise
 */
private Element createParallelEnvironment(Document doc, Task task) {
    ParallelEnvironment penv = task.getParallelEnvironment();
    if (penv == null)
        return null;
    Element parallelEnvE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.PARALLEL_ENV.getXMLName());
    setAttribute(parallelEnvE, XMLAttributes.TASK_NB_NODES, Integer.toString(penv.getNodesNumber()));
    // <ref name="topology"/>
    TopologyDescriptor topologyDescr = penv.getTopologyDescriptor();
    if (topologyDescr != null) {
        // <choice>
        // <ref name="arbitrary"/>
        // <ref name="bestProximity"/>
        // <ref name="thresholdProximity"/>
        // <ref name="singleHost"/>
        // <ref name="singleHostExclusive"/>
        // <ref name="multipleHostsExclusive"/>
        // <ref name="differentHostsExclusive"/>
        // </choice>
        Element topologyE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.TOPOLOGY.getXMLName());
        Element topologyDescrE = null;
        if (topologyDescr instanceof ArbitraryTopologyDescriptor) {
            topologyDescrE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.TOPOLOGY_ARBITRARY.getXMLName());
        } else if (topologyDescr instanceof ThresholdProximityDescriptor) {
            topologyDescrE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.TOPOLOGY_THRESHOLD_PROXIMITY.getXMLName());
            long threshold = ((ThresholdProximityDescriptor) topologyDescr).getThreshold();
            topologyDescrE.setAttribute(XMLAttributes.TOPOLOGY_THRESHOLD.getXMLName(), Long.toString(threshold));
        } else if (topologyDescr instanceof BestProximityDescriptor) {
            topologyDescrE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.TOPOLOGY_BEST_PROXIMITY.getXMLName());
        } else if (topologyDescr instanceof SingleHostExclusiveDescriptor) {
            topologyDescrE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.TOPOLOGY_SINGLE_HOST_EXCLUSIVE.getXMLName());
        } else if (topologyDescr instanceof SingleHostDescriptor) {
            topologyDescrE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.TOPOLOGY_SINGLE_HOST.getXMLName());
        } else if (topologyDescr instanceof MultipleHostsExclusiveDescriptor) {
            topologyDescrE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.TOPOLOGY_MULTIPLE_HOSTS_EXCLUSIVE.getXMLName());
        }
        if (topologyDescr instanceof DifferentHostsExclusiveDescriptor) {
            topologyDescrE = doc.createElementNS(Schemas.SCHEMA_LATEST.getNamespace(), XMLTags.TOPOLOGY_DIFFERENT_HOSTS_EXCLUSIVE.getXMLName());
        }
        if (topologyDescrE != null) {
            topologyE.appendChild(topologyDescrE);
        }
        parallelEnvE.appendChild(topologyE);
    }
    return parallelEnvE;
}
Also used : DifferentHostsExclusiveDescriptor(org.ow2.proactive.topology.descriptor.DifferentHostsExclusiveDescriptor) ParallelEnvironment(org.ow2.proactive.scheduler.common.task.ParallelEnvironment) ArbitraryTopologyDescriptor(org.ow2.proactive.topology.descriptor.ArbitraryTopologyDescriptor) Element(org.w3c.dom.Element) ThresholdProximityDescriptor(org.ow2.proactive.topology.descriptor.ThresholdProximityDescriptor) BestProximityDescriptor(org.ow2.proactive.topology.descriptor.BestProximityDescriptor) SingleHostExclusiveDescriptor(org.ow2.proactive.topology.descriptor.SingleHostExclusiveDescriptor) TopologyDescriptor(org.ow2.proactive.topology.descriptor.TopologyDescriptor) ArbitraryTopologyDescriptor(org.ow2.proactive.topology.descriptor.ArbitraryTopologyDescriptor) SingleHostDescriptor(org.ow2.proactive.topology.descriptor.SingleHostDescriptor) MultipleHostsExclusiveDescriptor(org.ow2.proactive.topology.descriptor.MultipleHostsExclusiveDescriptor)

Example 9 with TopologyDescriptor

use of org.ow2.proactive.topology.descriptor.TopologyDescriptor 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 10 with TopologyDescriptor

use of org.ow2.proactive.topology.descriptor.TopologyDescriptor 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)

Aggregations

TopologyDescriptor (org.ow2.proactive.topology.descriptor.TopologyDescriptor)6 Criteria (org.ow2.proactive.utils.Criteria)6 ThresholdProximityDescriptor (org.ow2.proactive.topology.descriptor.ThresholdProximityDescriptor)4 NodeSet (org.ow2.proactive.utils.NodeSet)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)2 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)2 ParallelEnvironment (org.ow2.proactive.scheduler.common.task.ParallelEnvironment)2 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Subject (javax.security.auth.Subject)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)1 Node (org.objectweb.proactive.core.node.Node)1 Client (org.ow2.proactive.resourcemanager.authentication.Client)1 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)1 TopologyDisabledException (org.ow2.proactive.resourcemanager.frontend.topology.TopologyDisabledException)1 TopologyManager (org.ow2.proactive.resourcemanager.selection.topology.TopologyManager)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1