Search in sources :

Example 1 with VM

use of es.bsc.compss.connectors.VM 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)

Example 2 with VM

use of es.bsc.compss.connectors.VM in project compss by bsc-wdc.

the class CreationThread method createResourceOnProvider.

private VM createResourceOnProvider(CloudMethodResourceDescription requested) throws ConnectorException {
    VM granted;
    Object envID;
    // ASK FOR THE VIRTUAL RESOURCE
    try {
        // Turn on the VM and expects the new mr description
        envID = operations.poweron(name, requested);
    } catch (ConnectorException e) {
        RUNTIME_LOGGER.error(ERROR_ASKING_NEW_RESOURCE + provider + "\n", e);
        RESOURCE_LOGGER.error("ERROR_MSG = [\n\t" + ERROR_ASKING_NEW_RESOURCE + provider + "\n]", e);
        throw e;
    }
    if (envID == null) {
        RUNTIME_LOGGER.info(WARN_CANNOT_PROVIDE_VM);
        RESOURCE_LOGGER.info("INFO_MSG = [\n\t" + provider + WARN_CANNOT_PROVIDE_VM + "\n]");
        throw new ConnectorException(WARN_CANNOT_PROVIDE_VM);
    }
    // WAITING FOR THE RESOURCES TO BE RUNNING
    try {
        // Wait until the VM has been created
        granted = operations.waitCreation(envID, requested);
    } catch (ConnectorException e) {
        RUNTIME_LOGGER.error(ERROR_WAITING_VM + provider + "\n", e);
        RESOURCE_LOGGER.error("ERROR_MSG = [\n\t" + ERROR_WAITING_VM + provider + "\n]", e);
        try {
            operations.destroy(envID);
        } catch (ConnectorException ex) {
            RUNTIME_LOGGER.error(ERROR_POWEROFF_VM);
            RESOURCE_LOGGER.error("ERROR_MSG = [\n\t" + ERROR_POWEROFF_VM + "\n]");
        }
        throw new ConnectorException("Error waiting for the vm");
    }
    if (granted != null) {
        RESOURCE_LOGGER.debug("CONNECTOR_REQUEST = [");
        RESOURCE_LOGGER.debug("\tPROC_CPU_CU = " + requested.getTotalCPUComputingUnits());
        RESOURCE_LOGGER.debug("\tPROC_GPU_CU = " + requested.getTotalGPUComputingUnits());
        RESOURCE_LOGGER.debug("\tPROC_FPGA_CU = " + requested.getTotalFPGAComputingUnits());
        RESOURCE_LOGGER.debug("\tPROC_OTHER_CU = " + requested.getTotalOTHERComputingUnits());
        RESOURCE_LOGGER.debug("\tOS = " + requested.getOperatingSystemType());
        RESOURCE_LOGGER.debug("\tMEM = " + requested.getMemorySize());
        RESOURCE_LOGGER.debug("]");
        CloudMethodResourceDescription desc = granted.getDescription();
        RESOURCE_LOGGER.debug("CONNECTOR_GRANTED = [");
        RESOURCE_LOGGER.debug("\tPROC_CPU_CU = " + desc.getTotalCPUComputingUnits());
        RESOURCE_LOGGER.debug("\tPROC_GPU_CU = " + desc.getTotalGPUComputingUnits());
        RESOURCE_LOGGER.debug("\tPROC_FPGA_CU = " + desc.getTotalFPGAComputingUnits());
        RESOURCE_LOGGER.debug("\tPROC_OTHER_CU = " + desc.getTotalOTHERComputingUnits());
        RESOURCE_LOGGER.debug("\tOS = " + desc.getOperatingSystemType());
        RESOURCE_LOGGER.debug("\tMEM = " + desc.getMemorySize());
        RESOURCE_LOGGER.debug("]");
    } else {
        throw new ConnectorException(ERROR_GRANTED_NULL);
    }
    return granted;
}
Also used : VM(es.bsc.compss.connectors.VM) ConnectorException(es.bsc.compss.connectors.ConnectorException) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Aggregations

ConnectorException (es.bsc.compss.connectors.ConnectorException)2 VM (es.bsc.compss.connectors.VM)2 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)2 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)1