Search in sources :

Example 6 with ResourceScheduler

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

the class Action method findAvailableWorkers.

@SuppressWarnings("unchecked")
public Map<Worker<?>, List<Implementation>> findAvailableWorkers() {
    Map<Worker<?>, List<Implementation>> m = new HashMap<>();
    List<ResourceScheduler<? extends WorkerResourceDescription>> compatibleWorkers = getCoreElementExecutors(coreId);
    for (ResourceScheduler<? extends WorkerResourceDescription> ui : compatibleWorkers) {
        Worker<WorkerResourceDescription> r = (Worker<WorkerResourceDescription>) ui.getResource();
        List<Implementation> compatibleImpls = r.getExecutableImpls(coreId);
        List<Implementation> runnableImpls = new LinkedList<>();
        for (Implementation impl : compatibleImpls) {
            if (r.canRunNow(impl.getRequirements())) {
                runnableImpls.add(impl);
            }
        }
        if (runnableImpls.size() > 0) {
            m.put((Worker<?>) r, runnableImpls);
        }
    }
    return m;
}
Also used : HashMap(java.util.HashMap) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) Worker(es.bsc.compss.types.resources.Worker) List(java.util.List) LinkedList(java.util.LinkedList) ResourceScheduler(es.bsc.compss.components.impl.ResourceScheduler) Implementation(es.bsc.compss.types.implementations.Implementation) LinkedList(java.util.LinkedList)

Example 7 with ResourceScheduler

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

the class ResourceSchedulerTest method testAllSetCopy.

@Test
public void testAllSetCopy() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "," + "\"ClassB.methodA\":" + SET_PROFILE + "," + "\"ClassA.methodB\":" + SET_PROFILE + "}}"), null);
    JSONObject jo = rs.toJSONObject();
    rs = new ResourceScheduler<>(worker, jo, null);
    for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
        List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
        for (Implementation impl : impls) {
            Profile p = rs.getProfile(impl);
            try {
                checkSetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on copy 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 8 with ResourceScheduler

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

the class ResourceSchedulerTest method testMethodANullUpdated.

@Test
public void testMethodANullUpdated() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassB.methodA\":" + SET_AND_UPDATED_PROFILE + "}}"), null);
    List<Implementation> impls = CoreManager.getCoreImplementations(0);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        if (impl.getImplementationId() == 0) {
            try {
                checkUnsetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA null-updated test");
            }
        } else {
            try {
                this.checkSetAndIncreasedProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA null-updated 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 null-updated 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 9 with ResourceScheduler

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

the class ResourceSchedulerTest method testMethodANullSet.

@Test
public void testMethodANullSet() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassB.methodA\":" + SET_PROFILE + "}}"), null);
    List<Implementation> impls = CoreManager.getCoreImplementations(0);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        if (impl.getImplementationId() == 0) {
            try {
                checkUnsetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA null-set test");
            }
        } else {
            try {
                checkSetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA null-set 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 null-set 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 10 with ResourceScheduler

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

the class ResourceSchedulerTest method testMethodBUpdated.

@Test
public void testMethodBUpdated() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodB\":" + SET_AND_UPDATED_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 updated test");
        }
    }
    impls = CoreManager.getCoreImplementations(1);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        try {
            checkSetAndIncreasedProfile(p);
        } catch (CheckerException ce) {
            fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodB updated 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)

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