Search in sources :

Example 1 with ThresholdProximityDescriptor

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

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

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

the class SelectionTest method action.

@Test
public void action() throws Exception {
    String currentHost = System.getenv("HOSTNAME");
    // checking if properties distantHost and neighborHost are defined
    String distantHost = System.getProperty("distantHost");
    String neighborHost = System.getProperty("neighborHost");
    if (distantHost != null && !distantHost.equals("${distantHost}") && neighborHost != null && !neighborHost.equals("${neighborHost}")) {
        String rmHome = System.getProperty("pa.rm.home");
        String rmCredPath = rmHome + "/config/authentication/rm.cred";
        String javaExec = System.getenv("JAVA_HOME") + "/bin/java";
        // properties are defined, trying to deploy nodes to these hosts
        BooleanWrapper result = rmHelper.getResourceManager().createNodeSource("remote", SSHInfrastructure.class.getName(), new Object[] { // ssh options
        "", // java executable path
        javaExec, // rmHelper distrib path
        rmHome, // node lookup timeout
        "30000", // attempts
        "2", // os
        "Linux", // java options
        "", // rmHelper credential
        FileToBytesConverter.convertFileToByteArray(new File(rmCredPath)), (distantHost + " 2\n" + neighborHost).getBytes() }, StaticPolicy.class.getName(), null, NODES_NOT_RECOVERABLE);
        if (result.getBooleanValue()) {
            rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
            rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
            rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
            // wait for the nodes to be in free state
            rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
            rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
            rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        }
    // we are good - all remote nodes registered
    } else {
        // no parameters provided
        RMTHelper.log("Nothing to do. Set up distantHost & neighborHost parameters.");
        return;
    }
    // creating the selection script object
    SelectionScript script = new SelectionScript(new File(vmPropSelectionScriptpath), new String[] { this.vmPropKey1, this.vmPropValue1 }, true);
    List<SelectionScript> scriptList = new LinkedList<>();
    scriptList.add(script);
    ResourceManager resourceManager = rmHelper.getResourceManager();
    String node1 = "node1";
    // a node with the VM properties
    HashMap<String, String> vmProperties = new HashMap<>();
    vmProperties.put(this.vmPropKey1, this.vmPropValue1);
    testNode = rmHelper.createNode(node1, vmProperties);
    String node1URL = testNode.getNode().getNodeInformation().getURL();
    resourceManager.addNode(node1URL, NodeSource.DEFAULT);
    // wait node adding event
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node1URL);
    // wait for the nodes to be in free state
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    // so now we have 9 node in total
    // 6 local nodes (5 default, 1 marked with property)
    // 2 nodes on distant host
    // 1 node on neighbor host
    Assert.assertEquals(9, resourceManager.getState().getFreeNodesNumber());
    // checking TopologyDescriptor.ARBITRARY
    NodeSet ns = resourceManager.getAtMostNodes(1, TopologyDescriptor.ARBITRARY, null, null);
    Assert.assertEquals(1, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(8, TopologyDescriptor.ARBITRARY, null, null);
    Assert.assertEquals(8, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, TopologyDescriptor.ARBITRARY, null, null);
    Assert.assertEquals(9, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, TopologyDescriptor.ARBITRARY, scriptList, null);
    Assert.assertEquals(1, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    // checking TopologyDescriptor.BEST_PROXIMITY
    ns = resourceManager.getAtMostNodes(1, TopologyDescriptor.BEST_PROXIMITY, null, null);
    Assert.assertEquals(1, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(9, TopologyDescriptor.BEST_PROXIMITY, null, null);
    Assert.assertEquals(9, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, TopologyDescriptor.BEST_PROXIMITY, null, null);
    Assert.assertEquals(9, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    // Node pivotNode = null;
    ns = resourceManager.getAtMostNodes(6, TopologyDescriptor.BEST_PROXIMITY, null, null);
    Assert.assertEquals(6, ns.size());
    for (Node node : ns) {
        // pivotNode = node;
        if (!node.getNodeInformation().getURL().contains(currentHost)) {
            Assert.assertTrue("All nodes have to be from " + currentHost, false);
        }
    }
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(7, TopologyDescriptor.BEST_PROXIMITY, null, null);
    Assert.assertEquals(7, ns.size());
    for (Node node : ns) {
        if (node.getNodeInformation().getURL().contains(distantHost)) {
            Assert.assertTrue("Node from distant host selected", false);
        }
    }
    resourceManager.releaseNodes(ns).getBooleanValue();
    // pivot scenario
    // List<Node> pivot = new LinkedList<Node>();
    // pivot.add(pivotNode);
    // ns = resourceManager.getAtMostNodes(6,
    // new BestProximityDescriptor(BestProximityDescriptor.MAX, pivot), null, null);
    // Assert.assertEquals(6, ns.size());
    // for (Node node : ns) {
    // if (node.getNodeInformation().getURL().equals(pivotNode.getNodeInformation().getURL())) {
    // Assert.assertTrue("Pivot must not be in results", false);
    // }
    // if (node.getNodeInformation().getURL().contains(distantHost)) {
    // Assert.assertTrue("Node from distant host selected", false);
    // }
    // }
    // resourceManager.releaseNodes(ns).getBooleanValue();
    // 
    // ns = resourceManager.getAtMostNodes(7,
    // new BestProximityDescriptor(BestProximityDescriptor.MAX, pivot), null, null);
    // Assert.assertEquals(7, ns.size());
    // for (Node node : ns) {
    // if (node.getNodeInformation().getURL().equals(pivotNode.getNodeInformation().getURL())) {
    // Assert.assertTrue("Pivot must not be in results", false);
    // }
    // }
    // resourceManager.releaseNodes(ns).getBooleanValue();
    // checking TopologyDescriptor.ThresholdProximityDescriptor
    ns = resourceManager.getAtMostNodes(1, new ThresholdProximityDescriptor(Long.MAX_VALUE), null, null);
    Assert.assertEquals(1, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(9, new ThresholdProximityDescriptor(Long.MAX_VALUE), null, null);
    Assert.assertEquals(9, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, new ThresholdProximityDescriptor(Long.MAX_VALUE), null, null);
    Assert.assertEquals(9, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    // getting information about topology
    Topology topology = resourceManager.getTopology();
    Assert.assertEquals(3, topology.getHosts().size());
    // looking for distances consistency
    Long current2neighborDistance = topology.getDistance(currentHost, neighborHost);
    Long current2distantDistance = topology.getDistance(currentHost, distantHost);
    Long distant2neightborDistance = topology.getDistance(neighborHost, distantHost);
    if (current2neighborDistance == null || current2distantDistance == null) {
        Assert.assertTrue("Please put full host names to the parameters", false);
    }
    if (current2neighborDistance > current2distantDistance) {
        Assert.assertTrue("Distant host is close to current than neighbor according to the topology", false);
    }
    System.out.println("Distance between " + currentHost + " and " + neighborHost + " is " + current2neighborDistance);
    System.out.println("Distance between " + currentHost + " and " + distantHost + " is " + current2distantDistance);
    System.out.println("Distance between " + neighborHost + " and " + distantHost + " is " + distant2neightborDistance);
    long maxThreshold = Math.max(current2neighborDistance, Math.max(current2distantDistance, distant2neightborDistance));
    ns = resourceManager.getAtMostNodes(100, new ThresholdProximityDescriptor(current2neighborDistance - 1), null, null);
    Assert.assertEquals(6, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, new ThresholdProximityDescriptor(current2neighborDistance), null, null);
    Assert.assertEquals(7, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, new ThresholdProximityDescriptor(maxThreshold - 1), null, null);
    for (Node node : ns) {
        if (node.getNodeInformation().getURL().contains(distantHost)) {
            Assert.assertTrue("Node from distant host selected", false);
        }
    }
    Assert.assertEquals(7, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(10, new ThresholdProximityDescriptor(maxThreshold), null, null);
    Assert.assertEquals(9, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    // pivot scenario
    // ns = resourceManager.getAtMostNodes(1, new ThresholdProximityDescriptor(0, pivot), null, null);
    // Assert.assertEquals(1, ns.size());
    // for (Node node : ns) {
    // if (node.getNodeInformation().getURL().equals(pivotNode.getNodeInformation().getURL())) {
    // Assert.assertTrue("Pivot must not be in results", false);
    // }
    // if (node.getNodeInformation().getURL().contains(distantHost) ||
    // node.getNodeInformation().getURL().contains(neighborHost)) {
    // Assert.assertTrue("Incorrect node selected", false);
    // }
    // }
    // resourceManager.releaseNodes(ns).getBooleanValue();
    // 
    // ns = resourceManager.getAtMostNodes(6, new ThresholdProximityDescriptor(current2neighborDistance,
    // pivot), null, null);
    // Assert.assertEquals(6, ns.size());
    // for (Node node : ns) {
    // if (node.getNodeInformation().getURL().equals(pivotNode.getNodeInformation().getURL())) {
    // Assert.assertTrue("Pivot must not be in results", false);
    // }
    // if (node.getNodeInformation().getURL().contains(distantHost)) {
    // Assert.assertTrue("Node from distant host selected", false);
    // }
    // }
    // resourceManager.releaseNodes(ns).getBooleanValue();
    // checking TopologyDescriptor.SINGLE_HOST
    ns = resourceManager.getAtMostNodes(1, TopologyDescriptor.SINGLE_HOST, null, null);
    Assert.assertEquals(1, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(9, TopologyDescriptor.SINGLE_HOST, null, null);
    Assert.assertEquals(6, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, TopologyDescriptor.SINGLE_HOST, null, null);
    Assert.assertEquals(6, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, TopologyDescriptor.SINGLE_HOST, scriptList, null);
    Assert.assertEquals(1, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    // checking TopologyDescriptor.SINGLE_HOST_EXCLUSIVE
    ns = resourceManager.getAtMostNodes(1, TopologyDescriptor.SINGLE_HOST_EXCLUSIVE, null, null);
    Assert.assertEquals(1, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    if (!ns.get(0).getNodeInformation().getURL().contains(neighborHost)) {
        Assert.assertTrue("Neighbor host shold be selected", false);
    }
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(9, TopologyDescriptor.SINGLE_HOST_EXCLUSIVE, null, null);
    Assert.assertEquals(6, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(2, TopologyDescriptor.SINGLE_HOST_EXCLUSIVE, null, null);
    Assert.assertEquals(2, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(3, TopologyDescriptor.SINGLE_HOST_EXCLUSIVE, null, null);
    Assert.assertEquals(3, ns.size());
    Assert.assertEquals(3, ns.getExtraNodes().size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, TopologyDescriptor.SINGLE_HOST_EXCLUSIVE, scriptList, null);
    // no hosts matched selection script
    Assert.assertEquals(0, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, TopologyDescriptor.SINGLE_HOST_EXCLUSIVE, null, null);
    // return the host with max capacity
    Assert.assertEquals(6, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    // checking TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE
    ns = resourceManager.getAtMostNodes(1, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, null, null);
    Assert.assertEquals(1, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(2, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, null, null);
    Assert.assertEquals(2, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(3, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, null, null);
    Assert.assertEquals(3, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(9, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, null, null);
    Assert.assertEquals(9, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(8, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, null, null);
    // current + distant has to be selected
    Assert.assertEquals(8, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(7, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, null, null);
    // current + neighbor has to be selected
    Assert.assertEquals(7, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, scriptList, null);
    // selection script specified => no such set
    Assert.assertEquals(0, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(100, TopologyDescriptor.MULTIPLE_HOSTS_EXCLUSIVE, null, null);
    // get max possible capacity
    Assert.assertEquals(9, ns.size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    // checking TopologyDescriptor.ONE_NODE_PER_HOST_EXCLUSIVE
    ns = resourceManager.getAtMostNodes(1, TopologyDescriptor.DIFFERENT_HOSTS_EXCLUSIVE, null, null);
    Assert.assertEquals(1, ns.size());
    Assert.assertEquals(null, ns.getExtraNodes());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(2, TopologyDescriptor.DIFFERENT_HOSTS_EXCLUSIVE, null, null);
    Assert.assertEquals(2, ns.size());
    Assert.assertEquals(1, ns.getExtraNodes().size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(3, TopologyDescriptor.DIFFERENT_HOSTS_EXCLUSIVE, null, null);
    Assert.assertEquals(3, ns.size());
    Assert.assertEquals(6, ns.getExtraNodes().size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    ns = resourceManager.getAtMostNodes(4, TopologyDescriptor.DIFFERENT_HOSTS_EXCLUSIVE, null, null);
    Assert.assertEquals(3, ns.size());
    Assert.assertEquals(6, ns.getExtraNodes().size());
    resourceManager.releaseNodes(ns).getBooleanValue();
    PAFuture.waitFor(resourceManager.removeNodeSource("remote", true));
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) SSHInfrastructure(org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructure) HashMap(java.util.HashMap) StaticPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy) Node(org.objectweb.proactive.core.node.Node) ThresholdProximityDescriptor(org.ow2.proactive.topology.descriptor.ThresholdProximityDescriptor) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) Topology(org.ow2.proactive.resourcemanager.frontend.topology.Topology) LinkedList(java.util.LinkedList) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) SelectionScript(org.ow2.proactive.scripting.SelectionScript) File(java.io.File) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 4 with ThresholdProximityDescriptor

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

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

Aggregations

ThresholdProximityDescriptor (org.ow2.proactive.topology.descriptor.ThresholdProximityDescriptor)5 TopologyDescriptor (org.ow2.proactive.topology.descriptor.TopologyDescriptor)4 Test (org.junit.Test)2 ParallelEnvironment (org.ow2.proactive.scheduler.common.task.ParallelEnvironment)2 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)1 Node (org.objectweb.proactive.core.node.Node)1 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)1 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)1 Topology (org.ow2.proactive.resourcemanager.frontend.topology.Topology)1 SSHInfrastructure (org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructure)1 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)1 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)1