Search in sources :

Example 36 with MethodResourceDescription

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

the class ResourceSchedulerTest method testMethodASetUpdated.

@Test
public void testMethodASetUpdated() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "," + "\"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 {
                checkSetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-updated test");
            }
        } else {
            try {
                this.checkSetAndIncreasedProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-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 set-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 37 with MethodResourceDescription

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

the class ResourceSchedulerTest method testMethodASetSet.

@Test
public void testMethodASetSet() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "," + "\"ClassB.methodA\":" + SET_PROFILE + "}}"), null);
    List<Implementation> impls = CoreManager.getCoreImplementations(0);
    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 MethodA set-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 set-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 38 with MethodResourceDescription

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

the class MOResourceOptimizer method createResourceForComponent.

private Resource<?> createResourceForComponent(CloudInstanceTypeDescription citd, CloudImageDescription cid) {
    Resource<?> r = new Resource<>(null);
    MOCloudTypeProfile moCloudTypeProf = (MOCloudTypeProfile) getCloudTypeProfile(citd);
    r.idlePower = moCloudTypeProf.getIdlePower();
    r.idlePrice = moCloudTypeProf.getIdlePrice();
    MethodResourceDescription rd = citd.getResourceDescription();
    r.capacity = new int[CoreManager.getCoreCount()];
    r.profiles = new MOProfile[CoreManager.getCoreCount()];
    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());
        r.profiles[coreId] = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impl.getImplementationId());
    }
    r.startTime = cid.getCreationTime() * 1000;
    r.clear();
    return r;
}
Also used : MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) Implementation(es.bsc.compss.types.implementations.Implementation) MOProfile(es.bsc.compss.scheduler.multiobjective.types.MOProfile)

Example 39 with MethodResourceDescription

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

the class MOResourceOptimizer method reduceResourceForComponent.

private Resource<?> reduceResourceForComponent(Resource<?> excludedWorker, CloudMethodResourceDescription reduction) {
    Resource<?> clone = new Resource<>(excludedWorker.worker);
    clone.idlePower = excludedWorker.idlePower;
    clone.idlePrice = excludedWorker.idlePrice;
    clone.capacity = new int[excludedWorker.capacity.length];
    System.arraycopy(excludedWorker.capacity, 0, clone.capacity, 0, excludedWorker.capacity.length);
    clone.startTime = excludedWorker.startTime;
    clone.startEnergy = excludedWorker.startEnergy;
    clone.startCost = excludedWorker.startCost;
    clone.time = excludedWorker.time;
    clone.counts = excludedWorker.counts;
    Map<CloudInstanceTypeDescription, int[]> composition = reduction.getTypeComposition();
    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);
        clone.idlePower -= moCloudTypeProf.getIdlePower() * count;
        clone.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);
            clone.capacity[coreId] -= rd.canHostSimultaneously((MethodResourceDescription) impl.getRequirements()) * count;
        }
    }
    return clone;
}
Also used : 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 40 with MethodResourceDescription

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

the class CloudTypeManager method getCompatibleTypes.

/**
 * Finds all the types provided by the Cloud Provider which fulfill the resource description.
 *
 * @param requested
 *            description of the features that the image must provide
 * @return The best instance type provided by the Cloud Provider which fulfills the resource description
 */
public List<CloudInstanceTypeDescription> getCompatibleTypes(MethodResourceDescription requested) {
    List<CloudInstanceTypeDescription> compatiblesList = new LinkedList<>();
    if (!this.types.isEmpty()) {
        for (CloudInstanceTypeDescription type : this.types.values()) {
            MethodResourceDescription resources = type.getResourceDescription();
            if (resources.contains(requested)) {
                // Satisfies the constraints, add compatible
                compatiblesList.add(type);
            }
        }
    } else {
        CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription("NO TYPE", requested);
        compatiblesList.add(citd);
    }
    return compatiblesList;
}
Also used : CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) LinkedList(java.util.LinkedList)

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