Search in sources :

Example 1 with ResourceCreationRequest

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

the class MOResourceOptimizer method getContext.

// Get estimated cost (energy, price, time) of the current scheduling
private <T extends WorkerResourceDescription> ConfigurationCost getContext(Resource<?>[] allResources, int[] load, Collection<ResourceScheduler<? extends WorkerResourceDescription>> workers, List<ResourceCreationRequest> creations, HashMap<CloudInstanceTypeDescription, Integer> pendingCreations, HashMap<CloudInstanceTypeDescription, Integer> pendingDestructions, double[] elapsedTime, double[] elapsedEnergy, double[] elapsedCost, double[] elapsedPower, double[] elapsedPrice) {
    elapsedTime[0] = 0;
    elapsedEnergy[0] = 0;
    elapsedCost[0] = 0;
    elapsedPower[0] = 0;
    elapsedPrice[0] = 0;
    double time = 0;
    double actionsCost = 0;
    double idlePrice = 0;
    double actionsEnergy = 0;
    double idlePower = 0;
    int resourceId = 0;
    for (ResourceScheduler<?> w : workers) {
        MOResourceScheduler<T> aw = (MOResourceScheduler<T>) w;
        Resource<T> r = new Resource<>(aw);
        allResources[resourceId] = r;
        addToLog("\tName:" + aw.getName() + (r.hasPendingModifications() ? " (IS TO BE DELETED)" : "") + "\n");
        time = Math.max(time, aw.getLastGapExpectedStart());
        addToLog("\t\tTime:" + aw.getLastGapExpectedStart() + " ms -> total " + time + "\n");
        elapsedCost[0] += aw.getRunActionsCost();
        addToLog("\t\tExecuted Actions Cost:" + aw.getRunActionsCost() + " €.ms/h -> total " + elapsedCost[0] + "€.ms/h\n");
        actionsCost += aw.getScheduledActionsCost();
        addToLog("\t\tScheduled Actions Cost:" + aw.getScheduledActionsCost() + " €.ms/h -> total " + actionsCost + "€.ms/h\n");
        r.idlePrice = aw.getIdlePrice();
        idlePrice += r.idlePrice;
        addToLog("\t\tIdle Price:" + r.idlePrice + " €/h -> total " + idlePrice + "€/h\n");
        elapsedEnergy[0] += aw.getRunActionsEnergy();
        addToLog("\t\tExecuted Actions Energy:" + aw.getRunActionsEnergy() + " mJ -> total " + elapsedEnergy[0] + "mJ\n");
        actionsEnergy += aw.getScheduledActionsEnergy();
        addToLog("\t\tScheduled Actions Energy:" + aw.getScheduledActionsEnergy() + " mJ -> total " + actionsEnergy + "mJ\n");
        r.idlePower = aw.getIdlePower();
        idlePower += r.idlePower;
        addToLog("\t\tIdle Power:" + r.idlePower + " W -> total " + idlePower + "W\n");
        r.startTime = aw.getExpectedEndTimeRunning();
        r.startCost = aw.getRunningActionsCost();
        r.startEnergy = aw.getRunningActionsEnergy();
        int[][] implsCount = aw.getImplementationCounts();
        int[][] runningCounts = aw.getRunningImplementationCounts();
        addToLog("\t\tCore Information:\n");
        StringBuilder[] coreInfo = new StringBuilder[CoreManager.getCoreCount()];
        Implementation[] impls = new Implementation[CoreManager.getCoreCount()];
        for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
            coreInfo[coreId] = new StringBuilder("\t\t\tCore " + coreId + "\n");
            int favId = 0;
            int favCount = implsCount[coreId][0];
            load[coreId] += implsCount[coreId][0] - runningCounts[coreId][0];
            coreInfo[coreId].append("\t\t\t\tImplementation 0: " + implsCount[coreId][0] + ", " + runningCounts[coreId][0] + " of'em already running\n");
            for (int implId = 1; implId < CoreManager.getCoreImplementations(coreId).size(); implId++) {
                coreInfo[coreId].append("\t\t\t\tImplementation " + implId + ": " + implsCount[coreId][implId] + ", " + runningCounts[coreId][implId] + " of'em already running\n");
                load[coreId] += implsCount[coreId][implId] - runningCounts[coreId][implId];
                if (implsCount[coreId][implId] > favCount) {
                    favId = implId;
                }
            }
            if (favCount > 0) {
                impls[coreId] = CoreManager.getCoreImplementations(coreId).get(favId);
            } else {
                List<Implementation> coreImpls = CoreManager.getCoreImplementations(coreId);
                MOProfile[] profiles = new MOProfile[coreImpls.size()];
                for (int i = 0; i < profiles.length; i++) {
                    profiles[i] = (MOProfile) aw.getProfile(coreImpls.get(i));
                }
                impls[coreId] = getBestImplementation(coreImpls, profiles);
            }
            coreInfo[coreId].append("\t\t\t\tFavorite Implementation " + favId + "\n");
        }
        r.profiles = new MOProfile[implsCount.length];
        r.capacity = new int[implsCount.length];
        for (int coreId = 0; coreId < implsCount.length; coreId++) {
            r.profiles[coreId] = (MOProfile) aw.getProfile(impls[coreId]);
            coreInfo[coreId].append("\t\t\t\tProfile " + r.profiles[coreId] + "\n");
            r.capacity[coreId] = aw.getSimultaneousCapacity(impls[coreId]);
            coreInfo[coreId].append("\t\t\t\tCapacity " + r.capacity[coreId] + "\n");
            addToLog(coreInfo[coreId].toString());
        }
        if (r.hasPendingModifications()) {
            for (ResourceUpdate<T> ru : r.getPendingModifications()) {
                Map<CloudInstanceTypeDescription, int[]> modificationComposition = ((CloudMethodResourceDescription) ru.getModification()).getTypeComposition();
                for (Map.Entry<CloudInstanceTypeDescription, int[]> entry : modificationComposition.entrySet()) {
                    CloudInstanceTypeDescription componentType = entry.getKey();
                    int count = entry.getValue()[0];
                    Integer pendingDestruction = pendingDestructions.get(componentType);
                    if (pendingDestruction == null) {
                        pendingDestruction = 0;
                    }
                    pendingDestruction += count;
                    pendingDestructions.put(componentType, pendingDestruction);
                }
            }
        }
        resourceId++;
    }
    // Convert time to secs
    elapsedTime[0] = (double) (System.currentTimeMillis() - initialTimeStamp) / 1000;
    // Convert energy from mJ to Wh
    elapsedEnergy[0] = elapsedEnergy[0] / 3_600_000;
    // Convert energy from €ms/h to €
    elapsedCost[0] = elapsedCost[0] / 3_600_000;
    for (ResourceCreationRequest rcr : creations) {
        for (Map.Entry<CloudInstanceTypeDescription, int[]> entry : rcr.getRequested().getTypeComposition().entrySet()) {
            CloudInstanceTypeDescription componentType = entry.getKey();
            int count = entry.getValue()[0];
            addToLog("\tName: REQUESTED " + componentType.getName() + "\n");
            Integer pendingCreation = pendingCreations.get(componentType);
            if (pendingCreation == null) {
                pendingCreation = 0;
            }
            pendingCreation += count;
            pendingCreations.put(componentType, pendingCreation);
        }
        Resource<?> r = createResourceForCreationRequest(rcr);
        allResources[resourceId] = r;
        addToLog("\t\tTime: 0 ms -> total " + time + "\n");
        addToLog("\t\tactions Cost: 0 € -> total " + actionsCost + "€\n");
        idlePrice += r.idlePrice;
        addToLog("\t\tIdle Price:" + r.idlePrice + " € -> total " + idlePrice + "€\n");
        addToLog("\t\tactions Energy:0 mJ -> total " + actionsEnergy + "mJ\n");
        idlePower += r.idlePower;
        addToLog("\t\tIdle Power:" + r.idlePower + " W -> total " + idlePower + "W\n");
        // r.startTime = 0;
        r.startCost = 0;
        r.startEnergy = 0;
        addToLog("\t\tCore Information:\n");
        StringBuilder[] coreInfo = new StringBuilder[CoreManager.getCoreCount()];
        for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
            coreInfo[coreId] = new StringBuilder("\t\t\tCore " + coreId + "\n");
            load[coreId] += 0;
            coreInfo[coreId].append("\t\t\t\tImplementation 0: 0, 0 of'em already running\n");
            for (int implId = 1; implId < CoreManager.getCoreImplementations(coreId).size(); implId++) {
                coreInfo[coreId].append("\t\t\t\tImplementation " + implId + ": 0, 0 of'em already running\n");
            }
            coreInfo[coreId].append("\t\t\t\tFavorite Implementation 0\n");
        }
        for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
            coreInfo[coreId].append("\t\t\t\tProfile " + r.profiles[coreId] + "\n");
            coreInfo[coreId].append("\t\t\t\tCapacity " + r.capacity[coreId] + "\n");
            addToLog(coreInfo[coreId].toString());
        }
        resourceId++;
    }
    return new ConfigurationCost(time, idlePower, actionsEnergy, idlePrice, actionsCost);
}
Also used : CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) Implementation(es.bsc.compss.types.implementations.Implementation) ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) HashMap(java.util.HashMap) Map(java.util.Map) MOProfile(es.bsc.compss.scheduler.multiobjective.types.MOProfile)

Example 2 with ResourceCreationRequest

use of es.bsc.compss.types.ResourceCreationRequest 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 ResourceCreationRequest

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

the class ResourceManager method printResourcesState.

/**
 * Prints out the resources state
 */
public static void printResourcesState() {
    RESOURCES_LOGGER.info("TIMESTAMP = " + String.valueOf(System.currentTimeMillis()));
    StringBuilder resourceState = new StringBuilder();
    resourceState.append("RESOURCES_INFO = [").append("\n");
    synchronized (pool) {
        for (Worker<? extends WorkerResourceDescription> resource : pool.findAllResources()) {
            resourceState.append("\t").append("RESOURCE = [").append("\n");
            resourceState.append("\t\t").append("NAME = ").append(resource.getName()).append("\n");
            resourceState.append("\t\t").append("TYPE = ").append(resource.getType().toString()).append("\n");
            if (resource.getType() == Type.SERVICE) {
                resourceState.append("\t\t").append("CPUS = 0\n");
                resourceState.append("\t\t").append("MEMORY = 0\n");
            } else {
                MethodResourceDescription mrd = (MethodResourceDescription) resource.getDescription();
                resourceState.append("\t\t").append("CPUS = ").append(mrd.getTotalCPUComputingUnits()).append("\n");
                resourceState.append("\t\t").append("MEMORY = ").append(mrd.getMemorySize()).append("\n");
            }
            int[] coreSlots = resource.getSimultaneousTasks();
            resourceState.append("\t\t").append("CAN_RUN = [").append("\n");
            for (int i = 0; i < coreSlots.length; i++) {
                resourceState.append("\t\t\t").append("CORE = [").append("\n");
                resourceState.append("\t\t\t").append("\t").append("COREID = ").append(i).append("\n");
                resourceState.append("\t\t\t").append("\t").append("NUM_SLOTS = ").append(coreSlots[i]).append("\n");
                resourceState.append("\t\t\t").append("]").append("\n");
            }
            // End CAN_RUN
            resourceState.append("\t\t").append("]").append("\n");
            // End RESOURCE
            resourceState.append("\t").append("]\n");
        }
    }
    // END RESOURCES_INFO
    resourceState.append("]").append("\n");
    resourceState.append("CLOUD_INFO = [").append("\n");
    if (cloudManager.isUseCloud()) {
        resourceState.append("\t").append("CURRENT_CLOUD_VM_COUNT = ").append(cloudManager.getCurrentVMCount()).append("\n");
        try {
            resourceState.append("\t").append("CREATION_TIME = ").append(Long.toString(cloudManager.getNextCreationTime())).append("\n");
        } catch (Exception ex) {
            resourceState.append("\t").append("CREATION_TIME = ").append(120000l).append("\n");
        }
        resourceState.append("\t").append("PENDING_RESOURCES = [").append("\n");
        for (ResourceCreationRequest rcr : cloudManager.getPendingRequests()) {
            resourceState.append("\t\t").append("RESOURCE = [").append("\n");
            CloudMethodResourceDescription cmrd = rcr.getRequested();
            resourceState.append("\t\t\t").append("NAME = ").append(cmrd.getName()).append("\n");
            resourceState.append("\t\t\t").append("TYPE = ").append(Type.WORKER.toString()).append("\n");
            resourceState.append("\t\t\t").append("CPUS = ").append(cmrd.getTotalCPUComputingUnits()).append("\n");
            resourceState.append("\t\t\t").append("MEMORY = ").append(cmrd.getMemorySize()).append("\n");
            resourceState.append("\t\t\t").append("CAN_RUN = [").append("\n");
            int[][] simTasks = rcr.requestedSimultaneousTaskCount();
            for (int coreId = 0; coreId < simTasks.length; coreId++) {
                int coreSlots = 0;
                for (int implId = 0; implId < simTasks[coreId].length; implId++) {
                    coreSlots = Math.max(coreSlots, simTasks[coreId][implId]);
                }
                resourceState.append("\t\t\t\t").append("CORE = [").append("\n");
                resourceState.append("\t\t\t\t\t").append("COREID = ").append(coreId).append("\n");
                resourceState.append("\t\t\t\t\t").append("NUM_SLOTS = ").append(coreSlots).append("\n");
                resourceState.append("\t\t\t\t").append("]").append("\n");
            }
            // End CAN_RUN
            resourceState.append("\t\t\t").append("]").append("\n");
            // End RESOURCE
            resourceState.append("\t\t").append("]").append("\n");
        }
        // End PENDING_RESOURCES
        resourceState.append("\t").append("]").append("\n");
    }
    // END CLOUD_INFO
    resourceState.append("]");
    RESOURCES_LOGGER.info(resourceState.toString());
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) NoResourceAvailableException(es.bsc.compss.exceptions.NoResourceAvailableException) ProjectFileValidationException(es.bsc.compss.types.project.exceptions.ProjectFileValidationException) InitNodeException(es.bsc.compss.exceptions.InitNodeException) ConnectorException(es.bsc.compss.connectors.ConnectorException) ResourcesFileValidationException(es.bsc.compss.types.resources.exceptions.ResourcesFileValidationException)

Example 4 with ResourceCreationRequest

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

the class CloudManagerTest method testTermianteAll.

@Test
public void testTermianteAll() throws Exception {
    CloudManager cm = new CloudManager();
    CloudProvider cp1 = createProvider(cm);
    CloudProvider cp2 = createProvider(cm);
    CloudMethodResourceDescription cmrd1 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr1 = cp1.requestResourceCreation(cmrd1);
    String vmName1 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw1 = new ExtendedCloudMethodWorker(vmName1, cp1, cmrd1, new FakeNode(vmName1), 0, new HashMap<>());
    cp1.confirmedCreation(rcr1, cmw1, cmrd1);
    CloudMethodResourceDescription cmrd2 = createResourceDescriptionFromProvider(cp2);
    ResourceCreationRequest rcr2 = cp2.requestResourceCreation(cmrd2);
    String vmName2 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw2 = new ExtendedCloudMethodWorker(vmName2, cp2, cmrd2, new FakeNode(vmName2), 0, new HashMap<>());
    cp2.confirmedCreation(rcr2, cmw2, cmrd2);
    if (cm.getCurrentVMCount() != 2) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (!cp2.getHostedWorkers().contains(cmw2)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    if (!cp1.getHostedWorkers().contains(cmw1)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    cm.terminateALL();
    if (cm.getCurrentVMCount() != 0) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (cp2.getHostedWorkers().contains(cmw2)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    if (cp1.getHostedWorkers().contains(cmw1)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) CloudProvider(es.bsc.compss.types.CloudProvider) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) ExtendedCloudMethodWorker(es.bsc.compss.types.ExtendedCloudMethodWorker) FakeNode(es.bsc.compss.types.fake.FakeNode) Test(org.junit.Test)

Example 5 with ResourceCreationRequest

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

the class CloudManagerTest method testVMsManagement.

@Test
public void testVMsManagement() {
    CloudManager cm = new CloudManager();
    CloudProvider cp1 = createProvider(cm);
    CloudProvider cp2 = createProvider(cm);
    CloudMethodResourceDescription cmrd1 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr1 = cp1.requestResourceCreation(cmrd1);
    if (rcr1 == null) {
        fail("Cloud Manager could not create the requested resource.");
    }
    if (cm.getCurrentVMCount() != 1) {
        fail("Cloud Manager is not properly counting the number of requested VMs");
    }
    if (cm.getPendingRequests().size() != 1) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    CloudMethodResourceDescription cmrd2 = createResourceDescriptionFromProvider(cp2);
    ResourceCreationRequest rcr2 = cp2.requestResourceCreation(cmrd2);
    if (rcr2 == null) {
        fail("Cloud Manager could not create the requested resource.");
    }
    if (cm.getCurrentVMCount() != 2) {
        fail("Cloud Manager is not properly counting the number of requested VMs");
    }
    if (cm.getPendingRequests().size() != 2) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    CloudMethodResourceDescription cmrd3 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr3 = cp1.requestResourceCreation(cmrd3);
    if (rcr3 == null) {
        fail("Cloud Manager could not create the requested resource.");
    }
    if (cm.getCurrentVMCount() != 3) {
        fail("Cloud Manager is not properly counting the number of requested VMs");
    }
    if (cm.getPendingRequests().size() != 3) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    if (!cm.getPendingRequests().contains(rcr3)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs");
    }
    cp1.refusedCreation(rcr3);
    if (cm.getCurrentVMCount() != 2) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().size() != 2) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (!cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (!cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().contains(rcr3)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    String vmName1 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw1 = new ExtendedCloudMethodWorker(vmName1, cp1, cmrd1, new FakeNode(vmName1), 0, new HashMap<>());
    cp1.confirmedCreation(rcr1, cmw1, cmrd1);
    if (cm.getCurrentVMCount() != 2) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().size() != 1) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().contains(rcr1)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (!cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (!cp1.getHostedWorkers().contains(cmw1)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    String vmName2 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw2 = new ExtendedCloudMethodWorker(vmName2, cp2, cmrd2, new FakeNode(vmName2), 0, new HashMap<>());
    cp2.confirmedCreation(rcr2, cmw2, cmrd2);
    if (cm.getCurrentVMCount() != 2) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (!cm.getPendingRequests().isEmpty()) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (cm.getPendingRequests().contains(rcr2)) {
        fail("Cloud Manager is not properly keeping track of the requested VMs when refusing creation requests");
    }
    if (!cp2.getHostedWorkers().contains(cmw2)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    CloudMethodResourceDescription reduction2 = new CloudMethodResourceDescription(cmrd2);
    cmw2.getDescription().reduce(reduction2);
    cp2.requestResourceReduction(cmw2, reduction2);
    if (cm.getCurrentVMCount() != 1) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (cp2.getHostedWorkers().contains(cmw2)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    if (!cp1.getHostedWorkers().contains(cmw1)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    if (!cmw2.isTerminated()) {
        fail("Cloud Manager did not called the connector to terminate the resource");
    }
    CloudMethodResourceDescription reduction1 = new CloudMethodResourceDescription(cmrd1);
    cmw1.getDescription().reduce(reduction1);
    cp1.requestResourceReduction(cmw1, reduction1);
    if (cm.getCurrentVMCount() != 0) {
        fail("Cloud Manager is not properly counting the number of requested VMs when refusing creation requests");
    }
    if (cp1.getHostedWorkers().contains(cmw1)) {
        fail("Cloud Manager is not properly keeping track of the VMs hosted in a cloud provider");
    }
    if (!cmw1.isTerminated()) {
        fail("Cloud Manager did not called the connector to terminate the resource");
    }
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) CloudProvider(es.bsc.compss.types.CloudProvider) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) ExtendedCloudMethodWorker(es.bsc.compss.types.ExtendedCloudMethodWorker) FakeNode(es.bsc.compss.types.fake.FakeNode) Test(org.junit.Test)

Aggregations

ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)11 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)8 CloudProvider (es.bsc.compss.types.CloudProvider)6 ExtendedCloudMethodWorker (es.bsc.compss.types.ExtendedCloudMethodWorker)4 FakeNode (es.bsc.compss.types.fake.FakeNode)4 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)4 Test (org.junit.Test)4 Implementation (es.bsc.compss.types.implementations.Implementation)2 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConnectorException (es.bsc.compss.connectors.ConnectorException)1 InitNodeException (es.bsc.compss.exceptions.InitNodeException)1 NoResourceAvailableException (es.bsc.compss.exceptions.NoResourceAvailableException)1 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)1 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)1 ProjectFileValidationException (es.bsc.compss.types.project.exceptions.ProjectFileValidationException)1 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)1 ResourcesFileValidationException (es.bsc.compss.types.resources.exceptions.ResourcesFileValidationException)1 LinkedList (java.util.LinkedList)1