Search in sources :

Example 6 with ResourceCreationRequest

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

the class ResourceManagerTest method testOneCloudWorkersOperations.

@Test
public void testOneCloudWorkersOperations() {
    ResourceManager.setCloudVMsBoundaries(3, 5, 8);
    CloudProvider cp1 = addProvider();
    CloudMethodResourceDescription cmrd1 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr1 = cp1.requestResourceCreation(cmrd1);
    if (ResourceManager.getPendingCreationRequests().size() != 1 || !ResourceManager.getPendingCreationRequests().contains(rcr1)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    String vmName1 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw1 = new ExtendedCloudMethodWorker(vmName1, cp1, cmrd1, new FakeNode(vmName1), 0, new HashMap<>());
    ResourceManager.addCloudWorker(rcr1, cmw1, cmrd1);
    if (!ResourceManager.getPendingCreationRequests().isEmpty() || ResourceManager.getPendingCreationRequests().contains(rcr1)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName1) != cmw1 || ResourceManager.getWorker(vmName1) != cmw1) {
        fail("ResourceManager is not properly adding the new cloud resources");
    }
    CloudMethodResourceDescription reduction1 = new CloudMethodResourceDescription(cmrd1);
    ResourceManager.reduceResource(cmw1, new PendingReduction<>(reduction1));
    ResourceManager.terminateCloudResource(cmw1, reduction1);
    if (!ResourceManager.getDynamicResources().isEmpty() || !ResourceManager.getAllWorkers().isEmpty() || ResourceManager.getDynamicResource(vmName1) != null || ResourceManager.getWorker(vmName1) != null) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (!cmw1.isTerminated()) {
        fail("ResourceManager is not properly requesting the resource shutdown");
    }
}
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 7 with ResourceCreationRequest

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

the class ResourceManagerTest method testMultipleCloudWorkersOperations.

@Test
public void testMultipleCloudWorkersOperations() {
    ResourceManager.setCloudVMsBoundaries(3, 5, 8);
    CloudProvider cp1 = addProvider();
    CloudProvider cp2 = addProvider();
    CloudMethodResourceDescription cmrd1 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr1 = cp1.requestResourceCreation(cmrd1);
    CloudMethodResourceDescription cmrd2 = createResourceDescriptionFromProvider(cp2);
    ResourceCreationRequest rcr2 = cp2.requestResourceCreation(cmrd1);
    CloudMethodResourceDescription cmrd3 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr3 = cp1.requestResourceCreation(cmrd3);
    if (ResourceManager.getPendingCreationRequests().size() != 3 || !ResourceManager.getPendingCreationRequests().contains(rcr1) || !ResourceManager.getPendingCreationRequests().contains(rcr2) || !ResourceManager.getPendingCreationRequests().contains(rcr3)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    String vmName1 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw1 = new ExtendedCloudMethodWorker(vmName1, cp1, cmrd1, new FakeNode(vmName1), 0, new HashMap<>());
    ResourceManager.addCloudWorker(rcr1, cmw1, cmrd1);
    if (ResourceManager.getPendingCreationRequests().size() != 2 || ResourceManager.getPendingCreationRequests().contains(rcr1)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName1) != cmw1 || ResourceManager.getWorker(vmName1) != cmw1) {
        fail("ResourceManager is not properly adding the new cloud resources");
    }
    String vmName2 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw2 = new ExtendedCloudMethodWorker(vmName2, cp2, cmrd2, new FakeNode(vmName2), 0, new HashMap<>());
    ResourceManager.addCloudWorker(rcr2, cmw2, cmrd2);
    if (ResourceManager.getPendingCreationRequests().size() != 1 || ResourceManager.getPendingCreationRequests().contains(rcr2)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 2 || ResourceManager.getAllWorkers().size() != 2 || ResourceManager.getDynamicResource(vmName2) != cmw2 || ResourceManager.getWorker(vmName2) != cmw2) {
        fail("ResourceManager is not properly adding the new cloud resources");
    }
    CloudMethodResourceDescription reduction1 = new CloudMethodResourceDescription(cmrd1);
    ResourceManager.reduceResource(cmw1, new PendingReduction<>(reduction1));
    ResourceManager.terminateCloudResource(cmw1, reduction1);
    if (ResourceManager.getPendingCreationRequests().size() != 1) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getCurrentVMCount() != 2) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName1) != null || ResourceManager.getWorker(vmName1) != null) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (!cmw1.isTerminated()) {
        fail("ResourceManager is not properly requesting the resource shutdown");
    }
    String vmName3 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw3 = new ExtendedCloudMethodWorker(vmName3, cp1, cmrd3, new FakeNode(vmName3), 0, new HashMap<>());
    ResourceManager.addCloudWorker(rcr3, cmw3, cmrd3);
    if (!ResourceManager.getPendingCreationRequests().isEmpty()) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 2 || ResourceManager.getAllWorkers().size() != 2 || ResourceManager.getDynamicResource(vmName3) != cmw3 || ResourceManager.getWorker(vmName3) != cmw3) {
        fail("ResourceManager is not properly adding the new cloud resources");
    }
    CloudMethodResourceDescription reduction2 = new CloudMethodResourceDescription(cmrd2);
    ResourceManager.reduceResource(cmw2, new PendingReduction<>(reduction2));
    ResourceManager.terminateCloudResource(cmw2, reduction2);
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName2) != null || ResourceManager.getWorker(vmName2) != null) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (!cmw2.isTerminated()) {
        fail("ResourceManager is not properly requesting the resource shutdown");
    }
    if (ResourceManager.getCurrentVMCount() != 1) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    CloudMethodResourceDescription cmrd4 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr4 = cp1.requestResourceCreation(cmrd4);
    if (ResourceManager.getPendingCreationRequests().size() != 1 || !ResourceManager.getPendingCreationRequests().contains(rcr4)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getCurrentVMCount() != 2) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
        if (entry.getValue()[0] != 1) {
            fail("ResourceManager is not properly keeping track of the amount of instances of each type");
        }
    }
    ResourceManager.increasedCloudWorker(rcr4, cmw3, cmrd4);
    if (!ResourceManager.getPendingCreationRequests().isEmpty()) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName3) != cmw3 || ResourceManager.getWorker(vmName3) != cmw3) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (ResourceManager.getCurrentVMCount() != 2) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
        if (entry.getValue()[0] != 2) {
            fail("ResourceManager is not properly keeping track of the amount of instances of each type");
        }
    }
    CloudMethodResourceDescription reduction4 = new CloudMethodResourceDescription(cmrd4);
    ResourceManager.reduceResource(cmw3, new PendingReduction<>(reduction4));
    ResourceManager.terminateCloudResource(cmw3, reduction4);
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName3) != cmw3 || ResourceManager.getWorker(vmName3) != cmw3) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (ResourceManager.getCurrentVMCount() != 1) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
        if (entry.getValue()[0] != 1) {
            fail("ResourceManager is not properly keeping track of the amount of instances of each type");
        }
    }
    CloudMethodResourceDescription reduction3 = new CloudMethodResourceDescription(cmrd3);
    ResourceManager.reduceResource(cmw3, new PendingReduction<>(reduction3));
    ResourceManager.terminateCloudResource(cmw3, reduction3);
    if (!ResourceManager.getDynamicResources().isEmpty() || !ResourceManager.getAllWorkers().isEmpty() || ResourceManager.getDynamicResource(vmName3) != null || ResourceManager.getWorker(vmName3) != null) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (ResourceManager.getCurrentVMCount() != 0) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
        if (entry.getValue()[0] != 0) {
            fail("ResourceManager is not properly keeping track of the amount of instances of each type");
        }
    }
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) CloudProvider(es.bsc.compss.types.CloudProvider) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) HashMap(java.util.HashMap) Map(java.util.Map) ExtendedCloudMethodWorker(es.bsc.compss.types.ExtendedCloudMethodWorker) FakeNode(es.bsc.compss.types.fake.FakeNode) Test(org.junit.Test)

Example 8 with ResourceCreationRequest

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

the class ResourceOptimizer method addBasicNodes.

/**
 * Asks for the VM needed for the runtime to be able to execute all method cores.
 *
 * First it groups the constraints of all the methods per Architecture and tries to merge included resource
 * descriptions in order to reduce the amount of required VMs. It also tries to join the unassigned architecture
 * methods with the closer constraints of a defined one. After that it distributes the Initial VM Count among the
 * architectures taking into account the number of methods that can be run in each architecture.
 *
 * If the amount of different constraints is higher than the Initial VM count it applies an agressive merge method
 * to each architecture in order to fulfill the initial Constraint. It creates a single VM for each final method
 * constraint.
 *
 * Although these aggressive merges, the amount of different constraints can be higher than the initial VM Count
 * constraint. In this case, it violates the initial VM constraint and asks for more resources.
 *
 * @return the amount of requested VM
 */
public static int addBasicNodes() {
    int coreCount = CoreManager.getCoreCount();
    List<ConstraintsCore>[] unfulfilledConstraints = getUnfulfilledConstraints();
    int unfulfilledConstraintsCores = 0;
    for (int coreId = 0; coreId < coreCount; coreId++) {
        if (unfulfilledConstraints[coreId].size() > 0) {
            unfulfilledConstraintsCores += unfulfilledConstraints[coreId].size();
            break;
        }
    }
    if (unfulfilledConstraintsCores == 0) {
        return 0;
    }
    /*
         * constraintsPerArquitecture has loaded all constraint for each task. architectures has a list of all the
         * architecture names.
         * 
         * e.g. architectures constraintsPerArquitecture Intel = |MR1|--|MR2| AMD = |MR3| [unassigned] = |MR4|--|MR5|
         */
    Map<String, List<ConstraintsCore>> arch2Constraints = classifyArchitectures(unfulfilledConstraints);
    /*
         * Tries to reduce the number of machines per architecture by entering constraints in another core's constraints
         */
    reduceArchitecturesConstraints(arch2Constraints);
    /*
         * Checks if there are enough Vm for a Unassigned Arquitecture If not it set each unassigned task into the
         * architecture with the most similar task e.g. constraintsPerArquitecture Intel --> |MR1|--|MR2|--|MR5| AMD -->
         * |MR3|--|MR4|
         */
    reassignUnassignedConstraints(arch2Constraints);
    /*
         * Tries to reduce the number of machines per architecture by entering constraints in another core's constraints
         */
    reduceArchitecturesConstraints(arch2Constraints);
    int createdCount = 0;
    for (int coreId = 0; coreId < coreCount; coreId++) {
        while (!unfulfilledConstraints[coreId].isEmpty()) {
            ConstraintsCore cc = unfulfilledConstraints[coreId].remove(0);
            cc.confirmed();
            ResourceCreationRequest rcr = askForResources(cc.desc, false);
            if (rcr != null) {
                rcr.print(RESOURCES_LOGGER, DEBUG);
                createdCount++;
            }
        }
    }
    if (DEBUG) {
        RESOURCES_LOGGER.debug("DEBUG_MSG = [\n" + "\tIn order to be able to execute all cores, Resource Manager has asked for " + createdCount + " Cloud resources\n" + "]");
    }
    return createdCount;
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) LinkedList(java.util.LinkedList) List(java.util.List)

Example 9 with ResourceCreationRequest

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

the class ExternalAdaptationManager method cloudCreation.

private void cloudCreation(String providerName, String typeName, String imageName) {
    if (providerName != null && typeName != null && imageName != null) {
        CloudProvider cp = ResourceManager.getCloudProvider(providerName);
        if (cp != null) {
            CloudImageDescription imageDescription = cp.getImage(imageName);
            CloudInstanceTypeDescription typeDescription = cp.getInstanceType(typeName);
            CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription(typeDescription, imageDescription);
            ResourceCreationRequest rcr = cp.requestResourceCreation(cmrd);
            if (rcr != null) {
                RUNTIME_LOGGER.info(LOG_PREFIX + "Submited external request for creating (" + typeName + ", " + imageName + ") in " + providerName);
                rcr.print(RESOURCES_LOGGER, DEBUG);
                writePipe(resultPipe, ACK);
            } else {
                RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: Creating resource (" + typeName + ", " + imageName + ") in " + providerName);
                writePipe(resultPipe, "ERROR: Error creating resource(" + typeName + ", " + imageName + ") 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 (" + typeName + ", " + imageName + "," + providerName + ")");
        writePipe(resultPipe, "ERROR: One of the parameters is incorrect (" + typeName + ", " + imageName + "," + providerName + ")");
    }
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) 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)

Example 10 with ResourceCreationRequest

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

the class ResourceManager method getPendingRequestsMonitorData.

/*
     * ************************************************************************************************************
     * LOGGER METHODS
     **********************************************************************************************************
     */
/**
 * Prints out the information about the pending requests
 *
 * @param prefix
 * @return
 */
public static String getPendingRequestsMonitorData(String prefix) {
    StringBuilder sb = new StringBuilder();
    for (ResourceCreationRequest r : cloudManager.getPendingRequests()) {
        // TODO: Add more information (i.e. information per processor, memory type, etc.)
        sb.append(prefix).append("<Resource id=\"requested new VM\">").append("\n");
        sb.append(prefix).append("\t").append("<CPUComputingUnits>").append(0).append("</CPUComputingUnits>").append("\n");
        sb.append(prefix).append("\t").append("<GPUComputingUnits>").append(0).append("</GPUComputingUnits>").append("\n");
        sb.append(prefix).append("\t").append("<FPGAComputingUnits>").append(0).append("</FPGAComputingUnits>").append("\n");
        sb.append(prefix).append("\t").append("<OTHERComputingUnits>").append(0).append("</OTHERComputingUnits>").append("\n");
        sb.append(prefix).append("\t").append("<Memory>").append(0).append("</Memory>").append("\n");
        sb.append(prefix).append("\t").append("<Disk>").append(0).append("</Disk>").append("\n");
        sb.append(prefix).append("\t").append("<Provider>").append(r.getProvider()).append("</Provider>").append("\n");
        sb.append(prefix).append("\t").append("<Image>").append(r.getRequested().getImage().getImageName()).append("</Image>").append("\n");
        sb.append(prefix).append("\t").append("<Status>").append("Creating").append("</Status>").append("\n");
        sb.append(prefix).append("\t").append("<Tasks>").append("</Tasks>").append("\n");
        sb.append(prefix).append("</Resource>").append("\n");
    }
    return sb.toString();
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest)

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