Search in sources :

Example 16 with CloudMethodResourceDescription

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

Example 17 with CloudMethodResourceDescription

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

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

the class DefaultNoSSHConnector method waitUntilCreation.

@Override
public CloudMethodResourceDescription waitUntilCreation(Object id, CloudMethodResourceDescription requested) throws ConnectorException {
    LOGGER.debug("Waiting for " + id);
    VirtualResource vr = connector.waitUntilCreation(id);
    CloudMethodResourceDescription cmrd = Converter.toCloudMethodResourceDescription(vr, requested);
    LOGGER.debug("Return cloud method resource description " + cmrd.toString());
    return cmrd;
}
Also used : CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) VirtualResource(es.bsc.conn.types.VirtualResource)

Example 19 with CloudMethodResourceDescription

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

the class DefaultSSHConnector method waitUntilCreation.

@Override
public CloudMethodResourceDescription waitUntilCreation(Object id, CloudMethodResourceDescription requested) throws ConnectorException {
    LOGGER.debug("Waiting for " + id);
    VirtualResource vr = connector.waitUntilCreation(id);
    CloudMethodResourceDescription cmrd = Converter.toCloudMethodResourceDescription(vr, requested);
    LOGGER.debug("Return cloud method resource description " + cmrd.toString());
    return cmrd;
}
Also used : CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) VirtualResource(es.bsc.conn.types.VirtualResource)

Example 20 with CloudMethodResourceDescription

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

the class CreationThread method run.

@Override
public void run() {
    boolean check = operations.getCheck();
    RUNTIME_LOGGER.debug("Operations check = " + check);
    CloudMethodResourceDescription requested = rcr.getRequested();
    VM granted;
    if (reused == null) {
        // If the resources does not exist --> Create
        this.setName("Creation Thread " + name);
        try {
            granted = createResourceOnProvider(requested);
        } catch (Exception e) {
            RUNTIME_LOGGER.error(ERROR_ASKING_NEW_RESOURCE + provider, e);
            notifyFailure();
            return;
        }
        if (DEBUG) {
            RUNTIME_LOGGER.debug("Resource " + granted.getName() + " with id  " + granted.getEnvId() + " has been created ");
        }
        RESOURCE_LOGGER.info("RESOURCE_GRANTED = [\n\tNAME = " + granted.getName() + "\n\tSTATUS = ID " + granted.getEnvId() + " CREATED\n]");
    } else {
        granted = reused;
        if (DEBUG) {
            RUNTIME_LOGGER.debug("Resource " + granted.getName() + " with id  " + granted.getEnvId() + " has been reused ");
        }
        RESOURCE_LOGGER.info("RESOURCE_GRANTED = [\n\tNAME = " + reused.getName() + "\n\tSTATUS = ID " + granted.getEnvId() + " REUSED\n]");
    }
    String grantedName = granted.getName();
    this.setName("Creation Thread " + grantedName);
    CloudMethodWorker r = ResourceManager.getDynamicResource(granted.getName());
    if (r == null) {
        // Resources are provided in a new VM
        if (reused == null) {
            // And are new --> Initiate VM
            try {
                if (DEBUG) {
                    RUNTIME_LOGGER.debug(" Preparing new worker resource " + granted.getName() + ".");
                }
                r = prepareNewResource(granted);
                operations.vmReady(granted);
            } catch (Exception e) {
                RUNTIME_LOGGER.error(ERROR_PREPARING_VM, e);
                powerOff(granted);
                notifyFailure();
                return;
            }
        } else {
            int limitOfTasks = granted.getDescription().getTotalCPUComputingUnits();
            int limitGPUTasks = granted.getDescription().getTotalGPUComputingUnits();
            int limitFPGATasks = granted.getDescription().getTotalFPGAComputingUnits();
            int limitOTHERTasks = granted.getDescription().getTotalOTHERComputingUnits();
            r = new CloudMethodWorker(grantedName, provider, granted.getDescription(), granted.getNode(), limitOfTasks, limitGPUTasks, limitFPGATasks, limitOTHERTasks, rcr.getRequested().getImage().getSharedDisks());
            if (DEBUG) {
                RUNTIME_LOGGER.debug("Worker for new resource " + grantedName + " set.");
            }
        }
        granted.setWorker(r);
        ResourceManager.addCloudWorker(rcr, r, granted.getDescription());
    } else {
        // Resources are provided in an existing VM
        ResourceManager.increasedCloudWorker(rcr, r, granted.getDescription());
    }
    COUNT.decrementAndGet();
}
Also used : VM(es.bsc.compss.connectors.VM) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) ConnectorException(es.bsc.compss.connectors.ConnectorException)

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