Search in sources :

Example 31 with CloudMethodResourceDescription

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

the class ResourceOptimizer method mandatoryReduction.

private void mandatoryReduction(float[] destroyRecommendations) {
    List<CloudMethodWorker> critical = trimReductionOptions(ResourceManager.getCriticalDynamicResources(), destroyRecommendations);
    // LinkedList<CloudMethodWorker> critical = checkCriticalSafeness
    // (critical);
    List<CloudMethodWorker> nonCritical = trimReductionOptions(ResourceManager.getNonCriticalDynamicResources(), destroyRecommendations);
    Object[] criticalSolution = getBestDestruction(critical, destroyRecommendations);
    Object[] nonCriticalSolution = getBestDestruction(nonCritical, destroyRecommendations);
    boolean criticalIsBetter;
    if (criticalSolution == null) {
        if (nonCriticalSolution == null) {
            return;
        } else {
            criticalIsBetter = false;
        }
    } else if (nonCriticalSolution == null) {
        criticalIsBetter = true;
    } else {
        criticalIsBetter = false;
        float[] noncriticalValues = (float[]) nonCriticalSolution[2];
        float[] criticalValues = (float[]) criticalSolution[2];
        if (noncriticalValues[0] == criticalValues[0]) {
            if (noncriticalValues[1] == criticalValues[1]) {
                if (noncriticalValues[2] < criticalValues[2]) {
                    criticalIsBetter = true;
                }
            } else if (noncriticalValues[1] > criticalValues[1]) {
                criticalIsBetter = true;
            }
        } else if (noncriticalValues[0] > criticalValues[0]) {
            criticalIsBetter = true;
        }
    }
    CloudMethodWorker res;
    CloudMethodResourceDescription cmrd;
    // float[] record;
    // int[][] slotsRemovingCount;
    CloudInstanceTypeDescription citd;
    if (criticalIsBetter) {
        res = (CloudMethodWorker) criticalSolution[0];
        citd = (CloudInstanceTypeDescription) criticalSolution[1];
    } else {
        if (nonCriticalSolution == null) {
            return;
        }
        res = (CloudMethodWorker) nonCriticalSolution[0];
        citd = (CloudInstanceTypeDescription) nonCriticalSolution[1];
    }
    cmrd = (CloudMethodResourceDescription) res.getDescription();
    CloudImageDescription cid = cmrd.getImage();
    CloudMethodResourceDescription finalDescription = new CloudMethodResourceDescription(citd, cid);
    finalDescription.setName(res.getName());
    ResourceManager.reduceCloudWorker(res, finalDescription);
}
Also used : CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) JSONObject(org.json.JSONObject)

Example 32 with CloudMethodResourceDescription

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

the class ResourceOptimizer method askForResources.

/**
 * The CloudManager ask for resources that can execute certain amount of cores at the same time. It checks the best
 * resource that each provider can offer to execute that amount of cores and picks one of them. It constructs a
 * resourceRequest describing the resource and which cores can be executed on it. This ResourceRequest will be used
 * to ask for that resource creation to the Cloud Provider and returned if the application is accepted.
 *
 * @param amount
 *            amount of slots
 * @param requirements
 *            features of the resource
 * @param contained
 *            {@literal true} if we want the request to ask for a resource contained in the description; else, the
 *            result contains the passed in description.
 * @return
 */
public static ResourceCreationRequest askForResources(Integer amount, MethodResourceDescription requirements, boolean contained) {
    // Search best resource
    CloudProvider bestProvider = null;
    CloudMethodResourceDescription bestConstraints = null;
    Float bestValue = Float.MAX_VALUE;
    for (CloudProvider cp : ResourceManager.getAvailableCloudProviders()) {
        CloudMethodResourceDescription rc = getBestIncreaseOnProvider(cp, amount, requirements, contained);
        if (rc != null && rc.getValue() < bestValue) {
            bestProvider = cp;
            bestConstraints = rc;
            bestValue = rc.getValue();
        } else if (rc != null && bestConstraints == null) {
            bestProvider = cp;
            bestConstraints = rc;
            bestValue = rc.getValue();
        } else {
            RUNTIME_LOGGER.warn(WARN_NO_POSIBLE_INCREASE + " (" + cp.getName() + ")");
        }
    }
    if (bestConstraints == null) {
        RUNTIME_LOGGER.warn(WARN_NO_RESOURCE_MATCHES);
        return null;
    }
    return bestProvider.requestResourceCreation(bestConstraints);
}
Also used : CloudProvider(es.bsc.compss.types.CloudProvider) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Example 33 with CloudMethodResourceDescription

use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription 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 34 with CloudMethodResourceDescription

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

the class MOResourceOptimizer method generatePossibleResourceReleases.

private void generatePossibleResourceReleases(LinkedList<Action> actions, Resource<?>[] allResources, int[] load) {
    for (int i = 0; i < allResources.length; i++) {
        Resource<?> excludedWorker = allResources[i];
        Worker<?> w = excludedWorker.getResource();
        // If worker is null, worker is being created. It cannot be destroyed yet.
        if (w == null || !(w.getDescription() instanceof CloudMethodResourceDescription)) {
            continue;
        }
        CloudMethodResourceDescription description = (CloudMethodResourceDescription) w.getDescription();
        if (!(excludedWorker.hasPendingModifications())) {
            CloudImageDescription image = description.getImage();
            for (CloudInstanceTypeDescription typeReduction : description.getPossibleReductions()) {
                CloudMethodResourceDescription reductionDescription = new CloudMethodResourceDescription(typeReduction, image);
                CloudMethodResourceDescription reducedDescription = new CloudMethodResourceDescription(description);
                reducedDescription.reduce(reductionDescription);
                ConfigurationCost cc;
                if (reducedDescription.getTypeComposition().isEmpty()) {
                    Resource<?>[] resources = new Resource[allResources.length - 1];
                    System.arraycopy(allResources, 0, resources, 0, i);
                    System.arraycopy(allResources, i + 1, resources, i, resources.length - i);
                    long time = excludedWorker.startTime;
                    double energy = excludedWorker.idlePower * time + excludedWorker.startEnergy;
                    double cost = excludedWorker.startCost;
                    cc = simulate(load, resources, time, energy, cost);
                } else {
                    allResources[i] = reduceResourceForComponent(excludedWorker, reducedDescription);
                    long time = excludedWorker.startTime;
                    double energy = excludedWorker.idlePower * time + excludedWorker.startEnergy;
                    double cost = excludedWorker.startCost;
                    cc = simulate(load, allResources, time, energy, cost);
                    allResources[i] = excludedWorker;
                }
                Action a = new ActionRemove(excludedWorker, typeReduction, cc);
                addToLog(a.toString());
                actions.add(a);
            }
        }
    }
}
Also used : CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)

Example 35 with CloudMethodResourceDescription

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

the class AbstractConnector method waitCreation.

@Override
public VM waitCreation(Object envId, CloudMethodResourceDescription requested) throws ConnectorException {
    CloudMethodResourceDescription granted = waitUntilCreation(envId, requested);
    VM vm = new VM(envId, granted);
    vm.setRequestTime(powerOnVMTimestamp.remove(envId));
    LOGGER.info("[Abstract Connector] Virtual machine created: " + vm);
    float oneHourCost = getMachineCostPerHour(granted);
    currentCostPerHour += oneHourCost;
    addMachine(vm);
    return vm;
}
Also used : CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Aggregations

CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)45 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)23 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)21 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)16 HashMap (java.util.HashMap)14 Test (org.junit.Test)14 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)12 FakeNode (es.bsc.compss.types.fake.FakeNode)11 CloudProvider (es.bsc.compss.types.CloudProvider)9 ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)7 Implementation (es.bsc.compss.types.implementations.Implementation)5 ConnectorException (es.bsc.compss.connectors.ConnectorException)4 ExtendedCloudMethodWorker (es.bsc.compss.types.ExtendedCloudMethodWorker)4 Map (java.util.Map)4 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)3 VM (es.bsc.compss.connectors.VM)2 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)2 PerformedIncrease (es.bsc.compss.types.resources.updates.PerformedIncrease)2 VirtualResource (es.bsc.conn.types.VirtualResource)2 LinkedList (java.util.LinkedList)2