Search in sources :

Example 1 with BlockedActionException

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

Example 2 with BlockedActionException

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

Example 3 with BlockedActionException

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);
}
Also used : UnassignedActionException(es.bsc.compss.scheduler.exceptions.UnassignedActionException) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) ResourceScheduler(es.bsc.compss.components.impl.ResourceScheduler) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList)

Example 4 with BlockedActionException

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

Example 5 with BlockedActionException

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);
    }
}
Also used : ActionNotFoundException(es.bsc.compss.scheduler.exceptions.ActionNotFoundException) Score(es.bsc.compss.scheduler.types.Score) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) LinkedList(java.util.LinkedList) FailedActionException(es.bsc.compss.scheduler.exceptions.FailedActionException)

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