Search in sources :

Example 1 with SingleHostDescriptor

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

ParallelEnvironment (org.ow2.proactive.scheduler.common.task.ParallelEnvironment)1 ArbitraryTopologyDescriptor (org.ow2.proactive.topology.descriptor.ArbitraryTopologyDescriptor)1 BestProximityDescriptor (org.ow2.proactive.topology.descriptor.BestProximityDescriptor)1 DifferentHostsExclusiveDescriptor (org.ow2.proactive.topology.descriptor.DifferentHostsExclusiveDescriptor)1 MultipleHostsExclusiveDescriptor (org.ow2.proactive.topology.descriptor.MultipleHostsExclusiveDescriptor)1 SingleHostDescriptor (org.ow2.proactive.topology.descriptor.SingleHostDescriptor)1 SingleHostExclusiveDescriptor (org.ow2.proactive.topology.descriptor.SingleHostExclusiveDescriptor)1 ThresholdProximityDescriptor (org.ow2.proactive.topology.descriptor.ThresholdProximityDescriptor)1 TopologyDescriptor (org.ow2.proactive.topology.descriptor.TopologyDescriptor)1 Element (org.w3c.dom.Element)1