Search in sources :

Example 1 with ResourceScheduler

use of es.bsc.compss.components.impl.ResourceScheduler in project compss by bsc-wdc.

the class ResourceSchedulerTest method testMethodB.

@Test
public void testMethodB() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodB\":" + SET_PROFILE + "}}"), null);
    List<Implementation> impls = CoreManager.getCoreImplementations(0);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        try {
            checkUnsetProfile(p);
        } catch (CheckerException ce) {
            fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodB test");
        }
    }
    impls = CoreManager.getCoreImplementations(1);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        try {
            checkSetProfile(p);
        } catch (CheckerException ce) {
            fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodB test");
        }
    }
}
Also used : JSONObject(org.json.JSONObject) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) ResourceScheduler(es.bsc.compss.components.impl.ResourceScheduler) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Test(org.junit.Test)

Example 2 with ResourceScheduler

use of es.bsc.compss.components.impl.ResourceScheduler in project compss by bsc-wdc.

the class ResourceSchedulerTest method testMethodASetNull.

@Test
public void testMethodASetNull() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "}}"), null);
    List<Implementation> impls = CoreManager.getCoreImplementations(0);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        if (impl.getImplementationId() == 1) {
            try {
                checkUnsetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-null test");
            }
        } else {
            try {
                checkSetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-null test");
            }
        }
    }
    impls = CoreManager.getCoreImplementations(1);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        try {
            checkUnsetProfile(p);
        } catch (CheckerException ce) {
            fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-null test");
        }
    }
}
Also used : JSONObject(org.json.JSONObject) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) ResourceScheduler(es.bsc.compss.components.impl.ResourceScheduler) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Test(org.junit.Test)

Example 3 with ResourceScheduler

use of es.bsc.compss.components.impl.ResourceScheduler in project compss by bsc-wdc.

the class ResourceSchedulerTest method testMethodAUpdatedNull.

@Test
public void testMethodAUpdatedNull() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_AND_UPDATED_PROFILE + "}}"), null);
    List<Implementation> impls = CoreManager.getCoreImplementations(0);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        if (impl.getImplementationId() == 1) {
            try {
                checkUnsetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-null test");
            }
        } else {
            try {
                this.checkSetAndIncreasedProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-null test");
            }
        }
    }
    impls = CoreManager.getCoreImplementations(1);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        try {
            checkUnsetProfile(p);
        } catch (CheckerException ce) {
            fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-null test");
        }
    }
}
Also used : JSONObject(org.json.JSONObject) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) ResourceScheduler(es.bsc.compss.components.impl.ResourceScheduler) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Test(org.junit.Test)

Example 4 with ResourceScheduler

use of es.bsc.compss.components.impl.ResourceScheduler in project compss by bsc-wdc.

the class OptimizationTest method globalOptimization.

// @Test
public void globalOptimization() {
    ScheduleOptimizer<FakeProfile, FakeResourceDescription, FakeImplementation> so = new ScheduleOptimizer<>(ds);
    long updateId = System.currentTimeMillis();
    Collection<ResourceScheduler<FakeProfile, FakeResourceDescription, FakeImplementation>> workers = new ArrayList<>();
    drs1.clear();
    drs2.clear();
    workers.add(drs1);
    FakeAllocatableAction action1 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(4));
    action1.selectExecution(drs1, (FakeImplementation) action1.getImplementations()[0]);
    drs1.scheduleAction(action1);
    try {
        action1.tryToLaunch();
    } catch (Exception e) {
    }
    FakeAllocatableAction action2 = new FakeAllocatableAction(fao, 2, 0, CoreManager.getCoreImplementations(4));
    action2.selectExecution(drs1, (FakeImplementation) action2.getImplementations()[0]);
    drs1.scheduleAction(action2);
    try {
        action2.tryToLaunch();
    } catch (Exception e) {
    }
    FakeAllocatableAction action3 = new FakeAllocatableAction(fao, 3, 1, CoreManager.getCoreImplementations(4));
    action3.selectExecution(drs1, (FakeImplementation) action3.getImplementations()[0]);
    drs1.scheduleAction(action3);
    FakeAllocatableAction action4 = new FakeAllocatableAction(fao, 4, 0, CoreManager.getCoreImplementations(5));
    action4.selectExecution(drs1, (FakeImplementation) action4.getImplementations()[0]);
    drs1.scheduleAction(action4);
    FakeAllocatableAction action5 = new FakeAllocatableAction(fao, 5, 1, CoreManager.getCoreImplementations(4));
    action5.selectExecution(drs1, (FakeImplementation) action5.getImplementations()[0]);
    drs1.scheduleAction(action5);
    FakeAllocatableAction action6 = new FakeAllocatableAction(fao, 6, 1, CoreManager.getCoreImplementations(6));
    action6.selectExecution(drs1, (FakeImplementation) action6.getImplementations()[0]);
    drs1.scheduleAction(action6);
    workers.add(drs2);
    so.globalOptimization(updateId, workers);
}
Also used : FakeProfile(es.bsc.es.bsc.compss.scheduler.types.fake.FakeProfile) FakeImplementation(es.bsc.es.bsc.compss.scheduler.types.fake.FakeImplementation) FakeResourceDescription(es.bsc.es.bsc.compss.scheduler.types.fake.FakeResourceDescription) ScheduleOptimizer(es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.ScheduleOptimizer) ArrayList(java.util.ArrayList) FakeAllocatableAction(es.bsc.es.bsc.compss.scheduler.types.fake.FakeAllocatableAction) FakeResourceScheduler(es.bsc.es.bsc.compss.scheduler.types.fake.FakeResourceScheduler) ResourceScheduler(es.bsc.compss.components.impl.ResourceScheduler) FullGraphResourceScheduler(es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.FullGraphResourceScheduler) BlockedActionException(es.bsc.es.bsc.compss.scheduler.exceptions.BlockedActionException) InvalidSchedulingException(es.bsc.es.bsc.compss.scheduler.exceptions.InvalidSchedulingException) UnassignedActionException(es.bsc.es.bsc.compss.scheduler.exceptions.UnassignedActionException)

Example 5 with ResourceScheduler

use of es.bsc.compss.components.impl.ResourceScheduler 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)

Aggregations

ResourceScheduler (es.bsc.compss.components.impl.ResourceScheduler)12 Implementation (es.bsc.compss.types.implementations.Implementation)10 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)9 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)9 JSONObject (org.json.JSONObject)9 Test (org.junit.Test)9 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)1 UnassignedActionException (es.bsc.compss.scheduler.exceptions.UnassignedActionException)1 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)1 Worker (es.bsc.compss.types.resources.Worker)1 BlockedActionException (es.bsc.es.bsc.compss.scheduler.exceptions.BlockedActionException)1 InvalidSchedulingException (es.bsc.es.bsc.compss.scheduler.exceptions.InvalidSchedulingException)1 UnassignedActionException (es.bsc.es.bsc.compss.scheduler.exceptions.UnassignedActionException)1 FullGraphResourceScheduler (es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.FullGraphResourceScheduler)1 ScheduleOptimizer (es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.ScheduleOptimizer)1 FakeAllocatableAction (es.bsc.es.bsc.compss.scheduler.types.fake.FakeAllocatableAction)1