Search in sources :

Example 1 with MethodResourceDescription

use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.

the class MOResourceOptimizer method createResourceForCreationRequest.

private Resource<?> createResourceForCreationRequest(ResourceCreationRequest rcr) {
    CloudMethodResourceDescription cmrd = rcr.getRequested();
    Resource<?> r = new Resource<>(null);
    Map<CloudInstanceTypeDescription, int[]> composition = cmrd.getTypeComposition();
    r.capacity = new int[CoreManager.getCoreCount()];
    r.profiles = new MOProfile[CoreManager.getCoreCount()];
    for (Map.Entry<CloudInstanceTypeDescription, int[]> component : composition.entrySet()) {
        CloudInstanceTypeDescription type = component.getKey();
        int count = component.getValue()[0];
        MethodResourceDescription rd = type.getResourceDescription();
        MOCloudTypeProfile moCloudTypeProf = (MOCloudTypeProfile) getCloudTypeProfile(type);
        r.idlePower += moCloudTypeProf.getIdlePower() * count;
        r.idlePrice += moCloudTypeProf.getIdlePrice() * count;
        for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
            List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
            MOProfile[] profiles = new MOProfile[impls.size()];
            for (int i = 0; i < impls.size(); i++) {
                profiles[i] = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impls.get(i).getImplementationId());
            }
            Implementation impl = getBestImplementation(impls, profiles);
            r.capacity[coreId] += rd.canHostSimultaneously((MethodResourceDescription) impl.getRequirements()) * count;
            MOProfile bestImplProf = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impl.getImplementationId());
            if (r.profiles[coreId] == null) {
                r.profiles[coreId] = bestImplProf;
            } else {
                r.profiles[coreId].accumulate(bestImplProf);
            }
        }
    }
    r.startTime = (cmrd.getImage().getCreationTime() * 1000) - (System.currentTimeMillis() - rcr.getRequestedTime());
    if (r.startTime < 0) {
        r.startTime = 0;
    }
    r.clear();
    return r;
}
Also used : CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) Implementation(es.bsc.compss.types.implementations.Implementation) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) HashMap(java.util.HashMap) Map(java.util.Map) MOProfile(es.bsc.compss.scheduler.multiobjective.types.MOProfile)

Example 2 with MethodResourceDescription

use of es.bsc.compss.types.resources.MethodResourceDescription 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 3 with MethodResourceDescription

use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.

the class ResourceOptimizer method selectContainingInstance.

private static CloudInstanceTypeDescription selectContainingInstance(List<CloudInstanceTypeDescription> instances, MethodResourceDescription constraints, int amount) {
    CloudInstanceTypeDescription result = null;
    MethodResourceDescription bestDescription = null;
    float bestDistance = Integer.MIN_VALUE;
    for (CloudInstanceTypeDescription type : instances) {
        MethodResourceDescription rd = type.getResourceDescription();
        int slots = rd.canHostSimultaneously(constraints);
        float distance = slots - amount;
        RUNTIME_LOGGER.debug("[Resource Optimizer] Can host: slots = " + slots + " amount = " + amount + " distance = " + distance + " bestDistance = " + bestDistance);
        if (distance > 0.0) {
            continue;
        }
        if (distance > bestDistance) {
            result = type;
            bestDescription = type.getResourceDescription();
            bestDistance = distance;
        } else if (distance == bestDistance && bestDescription != null) {
            if (bestDescription.getValue() != null && rd.getValue() != null && bestDescription.getValue() > rd.getValue()) {
                // Evaluate optimal candidate
                result = type;
                bestDescription = type.getResourceDescription();
                bestDistance = distance;
            }
        }
    }
    if (result == null) {
        return null;
    }
    return result;
}
Also used : CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Example 4 with MethodResourceDescription

use of es.bsc.compss.types.resources.MethodResourceDescription 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 5 with MethodResourceDescription

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

Aggregations

MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)51 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)26 Test (org.junit.Test)23 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)21 Implementation (es.bsc.compss.types.implementations.Implementation)20 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)19 HashMap (java.util.HashMap)17 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)12 JSONObject (org.json.JSONObject)10 ResourceScheduler (es.bsc.compss.components.impl.ResourceScheduler)9 FakeNode (es.bsc.compss.types.fake.FakeNode)7 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)7 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)4 CloudProvider (es.bsc.compss.types.CloudProvider)4 Processor (es.bsc.compss.types.resources.components.Processor)4 MethodWorker (es.bsc.compss.types.resources.MethodWorker)3 LinkedList (java.util.LinkedList)3 ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)2 FakeWorker (es.bsc.compss.types.fake.FakeWorker)2 AbstractMethodImplementation (es.bsc.compss.types.implementations.AbstractMethodImplementation)2