Search in sources :

Example 6 with Implementation

use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.

the class ResourceOptimizer method optionalIncrease.

private boolean optionalIncrease(float[] creationRecommendations) {
    PriorityQueue<ValueResourceDescription> pq = new PriorityQueue<>();
    for (int coreId = 0; coreId < creationRecommendations.length; coreId++) {
        if (creationRecommendations[coreId] > 1) {
            List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
            for (Implementation impl : impls) {
                if (impl.getTaskType() == TaskType.SERVICE) {
                    continue;
                }
                MethodResourceDescription constraints = ((MethodImplementation) impl).getRequirements();
                ValueResourceDescription v = new ValueResourceDescription(constraints, creationRecommendations[coreId], false);
                pq.add(v);
            }
        }
    }
    ResourceCreationRequest rcr = requestOneCreation(pq, false);
    return (rcr != null);
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) PriorityQueue(java.util.PriorityQueue) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation)

Example 7 with Implementation

use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.

the class ResourceOptimizer method mandatoryIncrease.

private void mandatoryIncrease(float[] creationRecommendations, List<Integer> requiredVMs) {
    PriorityQueue<ValueResourceDescription> pq = new PriorityQueue<>();
    boolean[] required = new boolean[creationRecommendations.length];
    for (int coreId : requiredVMs) {
        required[coreId] = true;
    }
    for (int coreId = 0; coreId < creationRecommendations.length; coreId++) {
        List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
        for (Implementation impl : impls) {
            if (impl.getTaskType() == TaskType.SERVICE) {
                continue;
            }
            MethodResourceDescription constraints = ((MethodImplementation) impl).getRequirements();
            ValueResourceDescription v = new ValueResourceDescription(constraints, creationRecommendations[coreId], false);
            pq.add(v);
        }
    }
    requestOneCreation(pq, true);
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) PriorityQueue(java.util.PriorityQueue) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation)

Example 8 with Implementation

use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.

the class ResourceSchedulerTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    // Method resource description and its slots
    Processor p = new Processor();
    p.setComputingUnits(4);
    MethodResourceDescription description = new MethodResourceDescription();
    description.addProcessor(p);
    worker = new FakeWorker(description, 4);
    int coreId = CoreManager.registerNewCoreElement("methodA");
    LinkedList<Implementation> impls = new LinkedList<>();
    LinkedList<String> signs = new LinkedList<>();
    Implementation impl = new MethodImplementation("ClassA", "methodA", coreId, 0, new MethodResourceDescription());
    impls.add(impl);
    signs.add("ClassA.methodA");
    impl = new MethodImplementation("ClassB", "methodA", coreId, 1, new MethodResourceDescription());
    impls.add(impl);
    signs.add("ClassB.methodA");
    CoreManager.registerNewImplementations(coreId, impls, signs);
    coreId = CoreManager.registerNewCoreElement("methodB");
    impls = new LinkedList<>();
    signs = new LinkedList<>();
    impl = new MethodImplementation("ClassA", "methodB", coreId, 0, new MethodResourceDescription());
    impls.add(impl);
    signs.add("ClassA.methodB");
    CoreManager.registerNewImplementations(coreId, impls, signs);
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Processor(es.bsc.compss.types.resources.components.Processor) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) FakeWorker(es.bsc.compss.types.fake.FakeWorker) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) LinkedList(java.util.LinkedList) BeforeClass(org.junit.BeforeClass)

Example 9 with Implementation

use of es.bsc.compss.types.implementations.Implementation 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 10 with Implementation

use of es.bsc.compss.types.implementations.Implementation 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)

Aggregations

Implementation (es.bsc.compss.types.implementations.Implementation)54 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)24 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)20 LinkedList (java.util.LinkedList)19 JSONObject (org.json.JSONObject)13 Test (org.junit.Test)12 ResourceScheduler (es.bsc.compss.components.impl.ResourceScheduler)10 List (java.util.List)9 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)8 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)8 HashMap (java.util.HashMap)7 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)6 Profile (es.bsc.compss.scheduler.types.Profile)6 BeforeClass (org.junit.BeforeClass)6 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)5 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)4 Score (es.bsc.compss.scheduler.types.Score)3 ServiceImplementation (es.bsc.compss.types.implementations.ServiceImplementation)3 Worker (es.bsc.compss.types.resources.Worker)3 Processor (es.bsc.compss.types.resources.components.Processor)3