use of es.bsc.compss.scheduler.exceptions.BlockedActionException in project compss by bsc-wdc.
the class ExecutionAction method schedule.
private final <T extends WorkerResourceDescription> void schedule(Score actionScore, List<ResourceScheduler<? extends WorkerResourceDescription>> candidates) throws BlockedActionException, UnassignedActionException {
// COMPUTE BEST WORKER AND IMPLEMENTATION
StringBuilder debugString = new StringBuilder("Scheduling " + this + " execution:\n");
ResourceScheduler<? extends WorkerResourceDescription> bestWorker = null;
Implementation bestImpl = null;
Score bestScore = null;
int usefulResources = 0;
for (ResourceScheduler<? extends WorkerResourceDescription> worker : candidates) {
if (this.getExecutingResources().contains(worker)) {
if (DEBUG) {
LOGGER.debug("Task already ran on worker " + worker.getName());
}
continue;
}
Score resourceScore = worker.generateResourceScore(this, task.getTaskDescription(), actionScore);
++usefulResources;
for (Implementation impl : getCompatibleImplementations(worker)) {
Score implScore = worker.generateImplementationScore(this, task.getTaskDescription(), impl, resourceScore);
if (DEBUG) {
debugString.append(" Resource ").append(worker.getName()).append(" ").append(" Implementation ").append(impl.getImplementationId()).append(" ").append(" Score ").append(implScore).append("\n");
}
if (Score.isBetter(implScore, bestScore)) {
bestWorker = worker;
bestImpl = impl;
bestScore = implScore;
}
}
}
// CHECK SCHEDULING RESULT
if (DEBUG) {
LOGGER.debug(debugString.toString());
}
if (bestWorker == null && usefulResources == 0) {
LOGGER.warn("No worker can run " + this);
throw new BlockedActionException();
}
schedule(bestWorker, bestImpl);
}
use of es.bsc.compss.scheduler.exceptions.BlockedActionException in project compss by bsc-wdc.
the class ReadyScheduler method tryToLaunchFreeActions.
private <T extends WorkerResourceDescription> void tryToLaunchFreeActions(List<AllocatableAction> dataFreeActions, List<AllocatableAction> resourceFreeActions, List<AllocatableAction> blockedCandidates, ResourceScheduler<T> resource) {
// Try to launch all the data free actions and the resource free actions
PriorityQueue<ObjectValue<AllocatableAction>> executableActions = new PriorityQueue<>();
for (AllocatableAction freeAction : dataFreeActions) {
Score actionScore = generateActionScore(freeAction);
Score fullScore = freeAction.schedulingScore(resource, actionScore);
ObjectValue<AllocatableAction> obj = new ObjectValue<>(freeAction, fullScore);
executableActions.add(obj);
}
for (AllocatableAction freeAction : resourceFreeActions) {
Score actionScore = generateActionScore(freeAction);
Score fullScore = freeAction.schedulingScore(resource, actionScore);
ObjectValue<AllocatableAction> obj = new ObjectValue<>(freeAction, fullScore);
if (!executableActions.contains(obj)) {
executableActions.add(obj);
}
}
while (!executableActions.isEmpty()) {
ObjectValue<AllocatableAction> obj = executableActions.poll();
AllocatableAction freeAction = obj.getObject();
// LOGGER.debug("Trying to launch action " + freeAction);
try {
scheduleAction(freeAction, obj.getScore());
tryToLaunch(freeAction);
} catch (BlockedActionException e) {
removeFromReady(freeAction);
addToBlocked(freeAction);
}
}
}
Aggregations