use of org.ow2.proactive.topology.descriptor.MultipleHostsExclusiveDescriptor 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;
}
Aggregations