use of es.bsc.compss.scheduler.exceptions.BlockedActionException in project compss by bsc-wdc.
the class MOResourceScheduler method tryToLaunch.
private boolean tryToLaunch(AllocatableAction action) {
boolean launched = false;
try {
action.tryToLaunch();
launched = true;
} catch (InvalidSchedulingException ise) {
}
if (!launched) {
long actionScore = MOScore.getActionScore(action);
Score aScore = new MOScore(actionScore, 0, 0, 0, 0, 0);
try {
action.schedule(aScore);
try {
action.tryToLaunch();
} catch (InvalidSchedulingException ise2) {
// Impossible exception.
LOGGER.error(ise2);
}
} catch (BlockedActionException | UnassignedActionException be) {
// Can not happen since there was an original source
LOGGER.error(be);
}
}
return launched;
}
use of es.bsc.compss.scheduler.exceptions.BlockedActionException in project compss by bsc-wdc.
the class FIFODataScheduler method purgeFreeActions.
/*
* *********************************************************************************************************
* *********************************************************************************************************
* ********************************* SCHEDULING OPERATIONS *************************************************
* *********************************************************************************************************
* *********************************************************************************************************
*/
@Override
public <T extends WorkerResourceDescription> void purgeFreeActions(List<AllocatableAction> dataFreeActions, List<AllocatableAction> resourceFreeActions, List<AllocatableAction> blockedCandidates, ResourceScheduler<T> resource) {
LOGGER.debug("[DataScheduler] Treating dependency free actions");
PriorityQueue<ObjectValue<AllocatableAction>> executableActions = new PriorityQueue<>();
for (AllocatableAction action : dataFreeActions) {
Score actionScore = this.generateActionScore(action);
Score fullScore = action.schedulingScore(resource, actionScore);
ObjectValue<AllocatableAction> obj = new ObjectValue<>(action, fullScore);
executableActions.add(obj);
}
dataFreeActions.clear();
while (!executableActions.isEmpty()) {
ObjectValue<AllocatableAction> obj = executableActions.poll();
AllocatableAction freeAction = obj.getObject();
try {
scheduleAction(freeAction, resource, obj.getScore());
tryToLaunch(freeAction);
} catch (BlockedActionException e) {
removeFromReady(freeAction);
addToBlocked(freeAction);
} catch (UnassignedActionException e) {
dataFreeActions.add(freeAction);
}
}
List<AllocatableAction> unassignedReadyActions = this.unassignedReadyActions.getAllActions();
this.unassignedReadyActions.removeAllActions();
dataFreeActions.addAll(unassignedReadyActions);
}
use of es.bsc.compss.scheduler.exceptions.BlockedActionException in project compss by bsc-wdc.
the class ExecutionAction method tryToSchedule.
@SuppressWarnings("unchecked")
@Override
public final void tryToSchedule(Score actionScore) throws BlockedActionException, UnassignedActionException {
// COMPUTE RESOURCE CANDIDATES
List<ResourceScheduler<? extends WorkerResourceDescription>> candidates = new LinkedList<>();
if (this.isTargetResourceEnforced()) {
// The scheduling is forced to a given resource
candidates.add((ResourceScheduler<WorkerResourceDescription>) this.getEnforcedTargetResource());
} else if (isSchedulingConstrained()) {
// The scheduling is constrained by dependencies
for (AllocatableAction a : this.getConstrainingPredecessors()) {
candidates.add((ResourceScheduler<WorkerResourceDescription>) a.getAssignedResource());
}
} else {
// Free scheduling
List<ResourceScheduler<? extends WorkerResourceDescription>> compatibleCandidates = getCompatibleWorkers();
if (compatibleCandidates.size() == 0) {
throw new BlockedActionException();
}
for (ResourceScheduler<? extends WorkerResourceDescription> currentWorker : compatibleCandidates) {
if (currentWorker.getResource().hasAvailableSlots()) {
candidates.add(currentWorker);
}
}
if (candidates.size() == 0) {
throw new UnassignedActionException();
}
}
this.schedule(actionScore, candidates);
}
use of es.bsc.compss.scheduler.exceptions.BlockedActionException in project compss by bsc-wdc.
the class TaskScheduler method workerRemoved.
/**
* One worker has been removed from the pool; the Task Scheduler is notified to modify any internal structure using
* that information.
*
* @param <T>
* @param resource
* removed worker
*/
protected <T extends WorkerResourceDescription> void workerRemoved(ResourceScheduler<T> resource) {
LOGGER.info("[TaskScheduler] Remove worker " + resource.getName());
// There are no internal structures worker-related. No need to do anything.
PriorityQueue<AllocatableAction> blockedOnResource = resource.getBlockedActions();
for (AllocatableAction action : blockedOnResource) {
try {
resource.unscheduleAction(action);
} catch (ActionNotFoundException ex) {
// Task was already moved from the worker. Do nothing!
continue;
}
Score actionScore = generateActionScore(action);
try {
scheduleAction(action, actionScore);
tryToLaunch(action);
} catch (BlockedActionException bae) {
if (!action.hasDataPredecessors()) {
removeFromReady(action);
}
addToBlocked(action);
}
}
}
use of es.bsc.compss.scheduler.exceptions.BlockedActionException in project compss by bsc-wdc.
the class TaskScheduler method errorOnAction.
/**
* Registers an error on the action given as a parameter. The action itself processes the error and triggers with
* any possible solution to re-execute it. This code is executed only on re-schedule (no resubmit)
*
* @param action
* action raising the error
*/
@SuppressWarnings("unchecked")
public final void errorOnAction(AllocatableAction action) {
LOGGER.warn("[TaskScheduler] Error on action " + action);
List<AllocatableAction> resourceFree = new LinkedList<>();
ResourceScheduler<WorkerResourceDescription> resource = (ResourceScheduler<WorkerResourceDescription>) action.getAssignedResource();
boolean failed = false;
// Process the action error (removes the assigned resource)
try {
action.error();
} catch (FailedActionException fae) {
// Action has completely failed
failed = true;
LOGGER.warn("[TaskScheduler] Action completely failed " + action);
removeFromReady(action);
// Free all the dependent tasks
for (AllocatableAction failedAction : action.failed()) {
try {
resourceFree.addAll(resource.unscheduleAction(failedAction));
} catch (ActionNotFoundException anfe) {
// Once the action starts running should cannot be moved from the resource
}
}
}
// We free the current task and get the free actions from the resource
try {
resourceFree.addAll(resource.unscheduleAction(action));
} catch (ActionNotFoundException anfe) {
// Once the action starts running should cannot be moved from the resource
}
workerLoadUpdate(resource);
if (!failed) {
// Try to re-schedule the action
Score actionScore = generateActionScore(action);
try {
scheduleAction(action, actionScore);
tryToLaunch(action);
} catch (BlockedActionException bae) {
removeFromReady(action);
addToBlocked(action);
}
}
List<AllocatableAction> blockedCandidates = new LinkedList<>();
handleDependencyFreeActions(new LinkedList<>(), resourceFree, blockedCandidates, resource);
for (AllocatableAction aa : blockedCandidates) {
removeFromReady(aa);
addToBlocked(aa);
}
}
Aggregations