Search in sources :

Example 11 with BlockedActionException

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);
}
Also used : Score(es.bsc.compss.scheduler.types.Score) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 12 with BlockedActionException

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);
        }
    }
}
Also used : Score(es.bsc.compss.scheduler.types.Score) ObjectValue(es.bsc.compss.scheduler.types.ObjectValue) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) PriorityQueue(java.util.PriorityQueue)

Aggregations

BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)12 Score (es.bsc.compss.scheduler.types.Score)9 UnassignedActionException (es.bsc.compss.scheduler.exceptions.UnassignedActionException)6 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)6 InvalidSchedulingException (es.bsc.compss.scheduler.exceptions.InvalidSchedulingException)4 ObjectValue (es.bsc.compss.scheduler.types.ObjectValue)3 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)3 LinkedList (java.util.LinkedList)3 PriorityQueue (java.util.PriorityQueue)3 ActionNotFoundException (es.bsc.compss.scheduler.exceptions.ActionNotFoundException)2 MOScore (es.bsc.compss.scheduler.multiobjective.types.MOScore)2 Implementation (es.bsc.compss.types.implementations.Implementation)2 List (java.util.List)2 ResourceScheduler (es.bsc.compss.components.impl.ResourceScheduler)1 FailedActionException (es.bsc.compss.scheduler.exceptions.FailedActionException)1 Profile (es.bsc.compss.scheduler.types.Profile)1 SchedulingInformation (es.bsc.compss.scheduler.types.SchedulingInformation)1 ReduceWorkerAction (es.bsc.compss.scheduler.types.allocatableactions.ReduceWorkerAction)1 StopWorkerAction (es.bsc.compss.scheduler.types.allocatableactions.StopWorkerAction)1 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)1