Search in sources :

Example 1 with CloudProvider

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

the class ResourceOptimizer method getBestDestruction.

/**
 * Given a set of resources, it checks every possible modification of the resource and returns the one that better
 * fits with the destruction recommendations.
 *
 * The decision-making algorithm tries to minimize the number of affected CE that weren't recommended to be
 * modified, minimize the number of slots that weren't requested to be destroyed and maximize the number of slots
 * that can be removed and they were requested for.
 *
 * @param resourceSet
 *            set of resources
 * @param destroyRecommendations
 *            number of slots to be removed for each CE
 * @return an object array defining the best solution.
 *
 *         0-> (Resource) selected Resource.
 *
 *         1->(CloudTypeInstanceDescription) Type to be destroyed to be destroyed.
 *
 *         2-> (int[]) record of the #CE with removed slots and that they shouldn't be modified, #slots that will be
 *         destroyed and they weren't recommended, #slots that will be removed and they were asked to be.
 */
private Object[] getBestDestruction(Collection<CloudMethodWorker> resourceSet, float[] destroyRecommendations) {
    CloudProvider cp;
    float[] bestRecord = new float[3];
    bestRecord[0] = Float.MAX_VALUE;
    bestRecord[1] = Float.MAX_VALUE;
    bestRecord[2] = Float.MIN_VALUE;
    Resource bestResource = null;
    CloudInstanceTypeDescription bestType = null;
    for (CloudMethodWorker res : resourceSet) {
        cp = res.getProvider();
        if (cp == null) {
            // it's not a cloud machine
            if (DEBUG) {
                RUNTIME_LOGGER.debug("Resource " + res.getName() + " is not cloud. Skipping...");
            }
            continue;
        }
        Map<CloudInstanceTypeDescription, float[]> typeToPoints = getPossibleReductions(res, destroyRecommendations);
        for (Map.Entry<CloudInstanceTypeDescription, float[]> destruction : typeToPoints.entrySet()) {
            CloudInstanceTypeDescription type = destruction.getKey();
            float[] values = destruction.getValue();
            if (DEBUG) {
                RUNTIME_LOGGER.debug("Type: " + type.getName() + " value 0: " + values[0] + " (" + bestRecord[0] + ") " + " value 1: " + values[1] + " (" + bestRecord[1] + ") " + " value 2: " + values[2] + " (" + bestRecord[2] + ")");
            }
            if (bestRecord[0] == values[0]) {
                if (bestRecord[1] == values[1]) {
                    if (bestRecord[2] < values[2]) {
                        bestRecord = values;
                        bestResource = res;
                        bestType = type;
                    }
                } else if (bestRecord[1] > values[1]) {
                    bestRecord = values;
                    bestResource = res;
                    bestType = type;
                }
            } else if (bestRecord[0] > values[0]) {
                bestRecord = values;
                bestResource = res;
                bestType = type;
            }
        }
    }
    if (bestResource != null) {
        Object[] ret = new Object[3];
        ret[0] = bestResource;
        ret[1] = bestType;
        ret[2] = bestRecord;
        return ret;
    } else {
        RUNTIME_LOGGER.warn("Best resource to remove not found");
        return null;
    }
}
Also used : CloudProvider(es.bsc.compss.types.CloudProvider) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker) Resource(es.bsc.compss.types.resources.Resource) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with CloudProvider

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

the class Test method cloudManagerTest.

/*
     * *********************************** CLOUD MANAGER TEST IMPLEMENTATION ***********************************
     */
private static void cloudManagerTest() {
    // Print Out CloudManager static structures
    System.out.println("[LOG] CloudManager Static Structures definition");
    // Check for each implementation the correctness of its resources
    coreCount = CoreManager.getCoreCount();
    CloudProvider cp = ResourceManager.getCloudProvider("BSC");
    for (int coreId = 0; coreId < coreCount; coreId++) {
        System.out.println("[LOG] Checking Core" + coreId);
        for (Implementation impl : CoreManager.getCoreImplementations(coreId)) {
            if (impl.getTaskType().equals(TaskType.METHOD)) {
                System.out.println("[LOG]\t Checking Implementation: " + impl.getImplementationId());
                System.out.println("\t\t Checking obtained compatible cloud images");
                MethodImplementation mImpl = (MethodImplementation) impl;
                for (CloudImageDescription cid_gci : cp.getCompatibleImages(mImpl.getRequirements())) {
                    System.out.println("\t\t\t Checking compatible Image: " + cid_gci.getImageName());
                    String res = checkImplementationAssignedToCloudImage(mImpl.getRequirements(), cid_gci);
                    if (res != null) {
                        String error = "[ERROR] Implementation: Core = " + coreId + " Impl = " + impl.getImplementationId() + ". ";
                        error = error.concat("Implementation and cloud image not matching on: " + res);
                        System.out.println(error);
                        System.exit(-1);
                    }
                }
                System.out.println("\t\t Checking obtained compatible cloud types");
                for (CloudInstanceTypeDescription type : cp.getCompatibleTypes(new CloudMethodResourceDescription(mImpl.getRequirements()))) {
                    if (type.getResourceDescription().canHostSimultaneously(mImpl.getRequirements()) < 1) {
                        continue;
                    }
                    System.out.println("\t\t\t Checking compatible Type: " + type.getName());
                    String res = checkImplementationAssignedToType(mImpl.getRequirements(), type.getResourceDescription());
                    if (res != null) {
                        String error = "[ERROR] Implementation: Core = " + coreId + " Impl = " + impl.getImplementationId() + ". ";
                        error = error.concat("Implementation and type not matching on: " + res);
                        System.out.println(error);
                        System.exit(-1);
                    }
                }
            }
        }
    }
    // Return success value
    System.out.println("[LOG] * CloudManager test passed");
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) CloudProvider(es.bsc.compss.types.CloudProvider) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 3 with CloudProvider

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

the class CloudManager method terminateALL.

/**
 * CloudManager terminates all the resources obtained from any provider
 *
 * @throws ConnectorException
 */
public void terminateALL() throws ConnectorException {
    RUNTIME_LOGGER.debug("[Cloud Manager] Terminate ALL resources");
    if (providers != null) {
        for (Entry<String, CloudProvider> vm : providers.entrySet()) {
            CloudProvider cp = vm.getValue();
            cp.terminateAll();
        }
    }
}
Also used : CloudProvider(es.bsc.compss.types.CloudProvider)

Example 4 with CloudProvider

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

the class ExternalAdaptationManager method cloudRemove.

private void cloudRemove(String providerName, String name) {
    if (providerName != null && name != null) {
        CloudProvider cp = ResourceManager.getCloudProvider(providerName);
        if (cp != null) {
            CloudMethodWorker cmw = cp.getHostedWorker(name);
            if (cmw != null) {
                ResourceManager.reduceCloudWorker(cmw, cmw.getDescription());
                RUNTIME_LOGGER.info(LOG_PREFIX + "Submited external request for removing " + name + " in " + providerName);
                writePipe(resultPipe, ACK);
            } else {
                RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: resource " + name + " not found in " + providerName);
                writePipe(resultPipe, "ERROR: Error creating resource " + name + " not found in " + providerName);
            }
        } else {
            RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: Provider " + providerName + " not found.");
            writePipe(resultPipe, "ERROR: Provider " + providerName + " not found");
        }
    } else {
        RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: One of the parameters is incorrect (" + name + "," + providerName + ")");
        writePipe(resultPipe, "ERROR: One of the parameters is incorrect (" + name + "," + providerName + ")");
    }
}
Also used : CloudProvider(es.bsc.compss.types.CloudProvider) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker)

Example 5 with CloudProvider

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

the class ResourceManager method addCloudWorker.

/**
 * Adds a cloud worker
 *
 * @param origin
 * @param worker
 * @param granted
 */
public static void addCloudWorker(ResourceCreationRequest origin, CloudMethodWorker worker, CloudMethodResourceDescription granted) {
    synchronized (pool) {
        CloudProvider cloudProvider = origin.getProvider();
        cloudProvider.confirmedCreation(origin, worker, granted);
        worker.updatedFeatures();
        pool.addDynamicResource(worker);
        pool.defineCriticalSet();
        int[] maxTaskCount = worker.getSimultaneousTasks();
        for (int coreId = 0; coreId < maxTaskCount.length; coreId++) {
            poolCoreMaxConcurrentTasks[coreId] += maxTaskCount[coreId];
        }
    }
    ResourceUpdate<MethodResourceDescription> ru = new PerformedIncrease<>(worker.getDescription());
    resourceUser.updatedResource(worker, ru);
    // Log new resource
    RESOURCES_LOGGER.info("TIMESTAMP = " + String.valueOf(System.currentTimeMillis()));
    RESOURCES_LOGGER.info("INFO_MSG = [New resource available in the pool. Name = " + worker.getName() + "]");
    RUNTIME_LOGGER.info("New resource available in the pool. Name = " + worker.getName());
}
Also used : CloudProvider(es.bsc.compss.types.CloudProvider) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) PerformedIncrease(es.bsc.compss.types.resources.updates.PerformedIncrease)

Aggregations

CloudProvider (es.bsc.compss.types.CloudProvider)22 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)11 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)9 ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)6 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 ExtendedCloudMethodWorker (es.bsc.compss.types.ExtendedCloudMethodWorker)4 FakeNode (es.bsc.compss.types.fake.FakeNode)4 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)4 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)2 PerformedIncrease (es.bsc.compss.types.resources.updates.PerformedIncrease)2 Map (java.util.Map)2 ConstructConfigurationException (es.bsc.compss.exceptions.ConstructConfigurationException)1 NoResourceAvailableException (es.bsc.compss.exceptions.NoResourceAvailableException)1 Implementation (es.bsc.compss.types.implementations.Implementation)1 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)1 ProjectFileValidationException (es.bsc.compss.types.project.exceptions.ProjectFileValidationException)1 es.bsc.compss.types.project.jaxb (es.bsc.compss.types.project.jaxb)1 Resource (es.bsc.compss.types.resources.Resource)1