Search in sources :

Example 1 with FailedActionException

use of es.bsc.compss.scheduler.exceptions.FailedActionException 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)

Example 2 with FailedActionException

use of es.bsc.compss.scheduler.exceptions.FailedActionException 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();
    }
}
Also used : FakeAllocatableAction(es.bsc.compss.types.fake.FakeAllocatableAction) FakeResourceScheduler(es.bsc.compss.types.fake.FakeResourceScheduler) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) FakeAllocatableAction(es.bsc.compss.types.fake.FakeAllocatableAction) FailedActionException(es.bsc.compss.scheduler.exceptions.FailedActionException) LinkedList(java.util.LinkedList)

Aggregations

FailedActionException (es.bsc.compss.scheduler.exceptions.FailedActionException)2 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)2 LinkedList (java.util.LinkedList)2 ActionNotFoundException (es.bsc.compss.scheduler.exceptions.ActionNotFoundException)1 BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)1 Score (es.bsc.compss.scheduler.types.Score)1 FakeAllocatableAction (es.bsc.compss.types.fake.FakeAllocatableAction)1 FakeResourceScheduler (es.bsc.compss.types.fake.FakeResourceScheduler)1 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)1