use of org.ow2.proactive.resourcemanager.frontend.topology.Topology 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);
}
use of org.ow2.proactive.resourcemanager.frontend.topology.Topology in project scheduling by ow2-proactive.
the class GetTopologyCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
HttpGet request = new HttpGet(currentContext.getResourceUrl("topology"));
HttpResponseWrapper response = execute(request, currentContext);
if (statusCode(OK) == statusCode(response)) {
TopologyView topology = readValue(response, TopologyView.class, currentContext);
resultStack(currentContext).push(topology);
if (!currentContext.isSilent()) {
writeLine(currentContext, "%s", StringUtility.string(topology));
}
} else {
handleError("An error occurred while retrieving the topology:", response, currentContext);
}
}
use of org.ow2.proactive.resourcemanager.frontend.topology.Topology in project scheduling by ow2-proactive.
the class StringUtility method string.
public static String string(TopologyView topology) {
StringBuilder buffer = new StringBuilder();
Set<String> hostList = topology.getDistances().keySet();
buffer.append(String.format("%nHost list(%d):", hostList.size()));
for (String host : hostList) {
buffer.append(String.format("%s", host));
}
ObjectArrayFormatter formatter = new ObjectArrayFormatter();
formatter.setMaxColumnLength(80);
formatter.setSpace(4);
List<String> titles = new ArrayList<>(3);
titles.add("Host");
titles.add("Distance (µs)");
titles.add("Host");
formatter.setTitle(titles);
formatter.addEmptyLine();
List<String> line;
for (String host : hostList) {
Map<String, String> hostTopology = topology.getDistances().get(host);
if (hostTopology != null) {
for (String anotherHost : hostTopology.keySet()) {
line = new ArrayList<>(3);
line.add(host);
line.add(hostTopology.get(anotherHost));
line.add(anotherHost);
formatter.addLine(line);
}
}
}
buffer.append(objectArrayFormatterAsString(formatter));
return buffer.toString();
}
use of org.ow2.proactive.resourcemanager.frontend.topology.Topology 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 > 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;
}
}
Aggregations