use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class TaskScheduler method increasedWorkerResources.
private <T extends WorkerResourceDescription> void increasedWorkerResources(ResourceScheduler<T> worker, ResourceUpdate<T> modification) {
if (worker.getExecutableCores().isEmpty()) {
// We no longer remove workers with empty executable cores since new core elements
// can be registered on execution time
} else {
// Inspect blocked actions to be freed
List<AllocatableAction> compatibleActions = this.blockedActions.removeAllCompatibleActions(worker.getResource());
// Prioritize them
PriorityQueue<ObjectValue<AllocatableAction>> sortedCompatibleActions = new PriorityQueue<>();
for (AllocatableAction action : compatibleActions) {
ObjectValue<AllocatableAction> obj = new ObjectValue<>(action, generateActionScore(action));
sortedCompatibleActions.add(obj);
}
// Schedule them
while (!sortedCompatibleActions.isEmpty()) {
ObjectValue<AllocatableAction> obj = sortedCompatibleActions.poll();
Score actionScore = obj.getScore();
AllocatableAction action = obj.getObject();
if (!action.hasDataPredecessors()) {
addToReady(action);
}
try {
scheduleAction(action, actionScore);
tryToLaunch(action);
} catch (BlockedActionException bae) {
removeFromReady(action);
addToBlocked(action);
}
}
// Update worker load
this.workerLoadUpdate(worker);
}
}
use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class TaskScheduler method getRunningActionMonitorData.
/**
* Returns the running actions on a given @worker pre-pending the @prefix
*
* @param <T>
* @param worker
* @param prefix
* @return
*/
public final <T extends WorkerResourceDescription> String getRunningActionMonitorData(Worker<T> worker, String prefix) {
LOGGER.info("[TaskScheduler] Get running actions monitoring data");
StringBuilder runningActions = new StringBuilder();
ResourceScheduler<T> ui = workers.get(worker);
if (ui != null) {
AllocatableAction[] hostedActions = ui.getHostedActions();
for (AllocatableAction action : hostedActions) {
runningActions.append(prefix);
runningActions.append("<Action>").append(action.toString()).append("</Action>");
runningActions.append("\n");
}
} else {
LOGGER.info("[TaskScheduler] Worker is not in the list");
}
return runningActions.toString();
}
use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class TaskScheduler method handleDependencyFreeActions.
/**
* Notifies to the scheduler that some actions have become free of data dependencies or resource dependencies.
*
* @param <T>
* @param dataFreeActions
* IN, list of actions free of data dependencies
* @param resourceFreeActions
* IN, list of actions free of resource dependencies
* @param blockedCandidates
* OUT, list of blocked candidates
* @param resource
* Resource where the previous task was executed
*/
public <T extends WorkerResourceDescription> void handleDependencyFreeActions(List<AllocatableAction> dataFreeActions, List<AllocatableAction> resourceFreeActions, List<AllocatableAction> blockedCandidates, ResourceScheduler<T> resource) {
LOGGER.debug("[TaskScheduler] Treating dependency free actions");
// All actions should have already been assigned to a resource, no need
// to change the assignation once they become free of dependencies
// 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();
tryToLaunch(freeAction);
}
}
use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class TaskScheduler method actionCompleted.
/**
* Registers an action as completed and releases all the resource and data dependencies.
*
* @param action
* action that has finished
*/
@SuppressWarnings("unchecked")
public final void actionCompleted(AllocatableAction action) {
LOGGER.info("[TaskScheduler] Action completed " + action);
// Mark action as finished
removeFromReady(action);
ResourceScheduler<WorkerResourceDescription> resource = (ResourceScheduler<WorkerResourceDescription>) action.getAssignedResource();
List<AllocatableAction> resourceFree;
try {
resourceFree = resource.unscheduleAction(action);
} catch (ActionNotFoundException ex) {
// Once the action starts running should cannot be moved from the resource
resourceFree = new LinkedList<>();
}
// Get the data free actions and mark them as ready
List<AllocatableAction> dataFreeActions = action.completed();
Iterator<AllocatableAction> dataFreeIter = dataFreeActions.iterator();
while (dataFreeIter.hasNext()) {
AllocatableAction dataFreeAction = dataFreeIter.next();
addToReady(dataFreeAction);
}
// We update the worker load
workerLoadUpdate(resource);
// Schedule data free actions
List<AllocatableAction> blockedCandidates = new LinkedList<>();
// Actions can only be scheduled and those that remain blocked must be added to the blockedCandidates list
// and those that remain unassigned must be added to the unassigned list
handleDependencyFreeActions(dataFreeActions, resourceFree, blockedCandidates, resource);
for (AllocatableAction aa : blockedCandidates) {
removeFromReady(aa);
addToBlocked(aa);
}
}
use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class AllocatableActionTest method error.
public void error(FakeAllocatableAction action) throws BlockedActionException, UnassignedActionException, InvalidSchedulingException {
FakeResourceScheduler resource = (FakeResourceScheduler) action.getAssignedResource();
List<AllocatableAction> resourceFree;
try {
action.error();
resourceFree = resource.unscheduleAction(action);
} catch (FailedActionException fae) {
resourceFree = new LinkedList<>();
for (AllocatableAction failed : action.failed()) {
resourceFree.addAll(resource.unscheduleAction(failed));
}
}
for (AllocatableAction a : resourceFree) {
FakeAllocatableAction fa = (FakeAllocatableAction) a;
fa.tryToLaunch();
}
}
Aggregations