use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper in project scheduling by ow2-proactive.
the class NodesCleaner method cleanAndRelease.
/**
* Cleans nodes in parallel for the nodes specified.
*
* @param nodes to be cleaned
* @return true if all the nodes were freed, false if error occurs on one of the node (it will be marked as down in this case)
*/
public BooleanWrapper cleanAndRelease(List<RMNode> nodes) {
List<Callable<Boolean>> cleaners = new LinkedList<>();
for (RMNode node : nodes) {
logger.debug("Cleaning the node " + node.getNodeURL());
cleaners.add(new NodeCleaner(node));
}
try {
Collection<Future<Boolean>> cleanNodes = scriptExecutorThreadPool.invokeAll(cleaners);
int index = 0;
for (Future<Boolean> cleanNode : cleanNodes) {
RMNode node = nodes.get(index);
if (!cleanNode.isCancelled()) {
Boolean isClean = null;
try {
isClean = cleanNode.get();
if (!isClean.booleanValue()) {
logger.warn("Cannot clean the node " + node.getNodeURL());
rmcore.setDownNode(node.getNodeURL());
} else {
logger.debug("The node " + node.getNodeURL() + " has been successfully cleaned");
}
} catch (ExecutionException e) {
logger.warn("Cannot clean the node " + node.getNodeURL(), e);
rmcore.setDownNode(node.getNodeURL());
}
} else {
logger.warn("Cannot clean the node " + node.getNodeURL());
rmcore.setDownNode(node.getNodeURL());
}
index++;
}
// in this case rmcore.setFreeNodes() will return false
return rmcore.setFreeNodes(nodes);
} catch (InterruptedException e) {
logger.error("", e);
}
return new BooleanWrapper(false);
}
Aggregations