Search in sources :

Example 1 with TopologyDescriptor

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

the class JobComparator method isEqualParallelEnvironment.

private boolean isEqualParallelEnvironment(ParallelEnvironment e1, ParallelEnvironment e2) {
    if ((e1 == null) && (e2 == null))
        return true;
    if ((e1 == null) ^ (e2 == null)) {
        stack.push("One value out of 2 is null");
        return false;
    }
    if (e1.getNodesNumber() != e2.getNodesNumber()) {
        stack.push("nodes number");
        return false;
    }
    // check same instance of topology decsriptor
    TopologyDescriptor topologyDescriptor1 = e1.getTopologyDescriptor();
    TopologyDescriptor topologyDescriptor2 = e2.getTopologyDescriptor();
    if (topologyDescriptor1 == null && topologyDescriptor2 == null) {
        return true;
    }
    if (topologyDescriptor1 == null ^ topologyDescriptor2 == null) {
        return isEqualClass(TopologyDescriptor.ARBITRARY.getClass(), (topologyDescriptor1 == null ? topologyDescriptor2.getClass() : topologyDescriptor1.getClass()));
    }
    if (!isEqualClass(topologyDescriptor1.getClass(), topologyDescriptor2.getClass())) {
        stack.push("topology descriptor type");
        return false;
    }
    if (topologyDescriptor1 instanceof ThresholdProximityDescriptor) {
        if (!(topologyDescriptor2 instanceof ThresholdProximityDescriptor)) {
            stack.push("Only one is ThresholdProximityDescriptor type.");
            return false;
        }
        if (((ThresholdProximityDescriptor) topologyDescriptor1).getThreshold() != ((ThresholdProximityDescriptor) topologyDescriptor2).getThreshold()) {
            stack.push("ThresholdProximityDescriptor.threshold");
            return false;
        }
    }
    return true;
}
Also used : ThresholdProximityDescriptor(org.ow2.proactive.topology.descriptor.ThresholdProximityDescriptor) TopologyDescriptor(org.ow2.proactive.topology.descriptor.TopologyDescriptor)

Example 2 with TopologyDescriptor

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

the class StaxJobFactory method createParallelEnvironment.

/**
 * Creates the parallel environment from the xml descriptor.
 */
private ParallelEnvironment createParallelEnvironment(XMLStreamReader cursorTask, Map<String, String> variables) throws JobCreationException {
    int event = -1;
    int nodesNumber = 0;
    TopologyDescriptor topologyDescriptor = null;
    // parallelEnvironment -> <topology>
    try {
        // cursor is parallelEnvironment
        for (int i = 0; i < cursorTask.getAttributeCount(); i++) {
            String attrName = cursorTask.getAttributeLocalName(i);
            if (XMLAttributes.TASK_NB_NODES.matches(attrName)) {
                String value = replace(cursorTask.getAttributeValue(i), variables);
                nodesNumber = Integer.parseInt(value);
            }
        }
        while (cursorTask.hasNext()) {
            event = cursorTask.next();
            if (event == XMLEvent.START_ELEMENT) {
                break;
            } else if (event == XMLEvent.END_ELEMENT && XMLTags.PARALLEL_ENV.matches(cursorTask.getLocalName())) {
                return new ParallelEnvironment(nodesNumber, TopologyDescriptor.ARBITRARY);
            }
        }
        if (XMLTags.TOPOLOGY.matches(cursorTask.getLocalName())) {
            // topology element found
            while (cursorTask.hasNext()) {
                event = cursorTask.next();
                if (event == XMLEvent.START_ELEMENT) {
                    break;
                } else if (event == XMLEvent.END_ELEMENT && XMLTags.TOPOLOGY.matches(cursorTask.getLocalName())) {
                    throw new RuntimeException("Incorrect topology description");
                }
            }
            // arbitrary : no attributes
            if (XMLTags.TOPOLOGY_ARBITRARY.matches(cursorTask.getLocalName())) {
                topologyDescriptor = TopologyDescriptor.ARBITRARY;
            } else // bestProximity : no attributes
            if (XMLTags.TOPOLOGY_BEST_PROXIMITY.matches(cursorTask.getLocalName())) {
                topologyDescriptor = TopologyDescriptor.BEST_PROXIMITY;
            } else // thresholdProximity : elements threshold
            if (XMLTags.TOPOLOGY_THRESHOLD_PROXIMITY.matches(cursorTask.getLocalName())) {
                // attribute threshold
                for (int i = 0; i < cursorTask.getAttributeCount(); i++) {
                    String attrName = cursorTask.getAttributeLocalName(i);
                    if (XMLAttributes.TOPOLOGY_THRESHOLD.matches(attrName)) {
                        String value = replace(cursorTask.getAttributeValue(i), variables);
                        long threshold = Long.parseLong(value);
                        topologyDescriptor = new ThresholdProximityDescriptor(threshold);
                    }
                }
            } else // singleHost : no attributes
            if (XMLTags.TOPOLOGY_SINGLE_HOST.matches(cursorTask.getLocalName())) {
                topologyDescriptor = TopologyDescriptor.SINGLE_HOST;
            } else // singleHostExclusive : no attributes
            if (XMLTags.TOPOLOGY_SINGLE_HOST_EXCLUSIVE.matches(cursorTask.getLocalName())) {
                topologyDescriptor = TopologyDescriptor.SINGLE_HOST_EXCLUSIVE;
            } else // multipleHostsExclusive : no attributes
            if (XMLTags.TOPOLOGY_MULTIPLE_HOSTS_EXCLUSIVE.matches(cursorTask.getLocalName())) {
                topologyDescriptor = TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE;
            } else // oneNodePerHostHostsExclusive : no attributes
            if (XMLTags.TOPOLOGY_DIFFERENT_HOSTS_EXCLUSIVE.matches(cursorTask.getLocalName())) {
                topologyDescriptor = TopologyDescriptor.DIFFERENT_HOSTS_EXCLUSIVE;
            }
        }
    } catch (Exception e) {
        throw new JobCreationException(XMLTags.TOPOLOGY.getXMLName(), null, e);
    }
    return new ParallelEnvironment(nodesNumber, topologyDescriptor);
}
Also used : ParallelEnvironment(org.ow2.proactive.scheduler.common.task.ParallelEnvironment) ThresholdProximityDescriptor(org.ow2.proactive.topology.descriptor.ThresholdProximityDescriptor) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) TopologyDescriptor(org.ow2.proactive.topology.descriptor.TopologyDescriptor) XMLStreamException(javax.xml.stream.XMLStreamException) JobValidationException(org.ow2.proactive.scheduler.common.exception.JobValidationException) FileNotFoundException(java.io.FileNotFoundException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) VerifierConfigurationException(org.iso_relax.verifier.VerifierConfigurationException)

Example 3 with TopologyDescriptor

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

the class LocalSelectionTest method getNodesAndReleaseThem.

private void getNodesAndReleaseThem(int number, TopologyDescriptor descriptor, int expectedReceived, int expectedExtraNodesSize) {
    Criteria c = new Criteria(number);
    c.setTopology(descriptor);
    NodeSet ns = resourceManager.getNodes(c);
    Assert.assertEquals(expectedReceived, ns.size());
    Collection<Node> extra = ns.getExtraNodes();
    if (expectedExtraNodesSize == 0) {
        Assert.assertNull(extra);
    } else {
        Assert.assertEquals(expectedExtraNodesSize, extra.size());
    }
    resourceManager.releaseNodes(ns).getBooleanValue();
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Node(org.objectweb.proactive.core.node.Node) Criteria(org.ow2.proactive.utils.Criteria)

Example 4 with TopologyDescriptor

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

the class TestTaskAttributes method testParallelEnv.

@Test
public void testParallelEnv() throws Exception {
    JavaTask task = createDefaultTask("task");
    ParallelEnvironment env = new ParallelEnvironment(5);
    task.setParallelEnvironment(env);
    InternalTask taskData = saveSingleTask(task).getTask(task.getName());
    Assert.assertEquals(5, taskData.getParallelEnvironment().getNodesNumber());
    Assert.assertNull(taskData.getParallelEnvironment().getTopologyDescriptor());
    TopologyDescriptor[] descs = { TopologyDescriptor.ARBITRARY, TopologyDescriptor.BEST_PROXIMITY, TopologyDescriptor.DIFFERENT_HOSTS_EXCLUSIVE, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, TopologyDescriptor.SINGLE_HOST, TopologyDescriptor.SINGLE_HOST_EXCLUSIVE, new ThresholdProximityDescriptor(123) };
    for (TopologyDescriptor desc : descs) {
        task = createDefaultTask("task");
        env = new ParallelEnvironment(10, desc);
        task.setParallelEnvironment(env);
        taskData = saveSingleTask(task).getTask(task.getName());
        Assert.assertEquals(10, taskData.getParallelEnvironment().getNodesNumber());
        Assert.assertEquals(taskData.getParallelEnvironment().getTopologyDescriptor().getClass(), desc.getClass());
        if (desc instanceof ThresholdProximityDescriptor) {
            Assert.assertEquals(((ThresholdProximityDescriptor) taskData.getParallelEnvironment().getTopologyDescriptor()).getThreshold(), 123);
        }
    }
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ThresholdProximityDescriptor(org.ow2.proactive.topology.descriptor.ThresholdProximityDescriptor) TopologyDescriptor(org.ow2.proactive.topology.descriptor.TopologyDescriptor) Test(org.junit.Test)

Example 5 with TopologyDescriptor

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

the class TestRMProxy method requestWithExtraNodes.

private void requestWithExtraNodes(RMProxy proxy, ResourceManager rm) throws Exception {
    log("Request NodeSet with extra nodes");
    TopologyDescriptor topology = TopologyDescriptor.SINGLE_HOST_EXCLUSIVE;
    Criteria criteria = new Criteria(1);
    criteria.setTopology(topology);
    NodeSet nodeSet = proxy.getNodes(criteria);
    PAFuture.waitFor(nodeSet);
    assertEquals(1, nodeSet.size());
    Assert.assertNotNull("Extra nodes are expected", nodeSet.getExtraNodes());
    assertEquals(NODES_NUMBER - 1, nodeSet.getExtraNodes().size());
    assertEquals(0, rm.getState().getFreeNodesNumber());
    proxy.releaseNodes(nodeSet);
    waitWhenNodesAreReleased(NODES_NUMBER);
    assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria) 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