use of es.bsc.compss.connectors.ConnectorException 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;
}
use of es.bsc.compss.connectors.ConnectorException in project compss by bsc-wdc.
the class CreationThread method prepareNewResource.
private CloudMethodWorker prepareNewResource(VM vm) throws ConnectorException {
CloudMethodResourceDescription granted = vm.getDescription();
CloudImageDescription cid = granted.getImage();
Map<String, String> workerProperties = cid.getProperties();
String user = cid.getConfig().getUser();
String password = workerProperties.get(AbstractConnector.PROPERTY_PASSW_NAME);
try {
operations.configureAccess(granted.getName(), user, password);
} catch (ConnectorException e) {
RUNTIME_LOGGER.error(ERROR_CONFIGURE_ACCESS_VM + granted.getName(), e);
RESOURCE_LOGGER.error("ERROR_MSG = [\n\t" + ERROR_CONFIGURE_ACCESS_VM + "\n\tNAME = " + granted.getName() + "\n\tPROVIDER = " + provider + "\n]", e);
throw e;
}
try {
operations.prepareMachine(granted.getName(), cid);
} catch (ConnectorException e) {
RUNTIME_LOGGER.error(ERROR_PREPARING_VM + granted.getName(), e);
RESOURCE_LOGGER.error("ERROR_MSG = [\n\t" + ERROR_PREPARING_VM + granted.getName() + "]", e);
throw e;
}
CloudMethodWorker worker;
MethodConfiguration mc = cid.getConfig();
int limitOfTasks = mc.getLimitOfTasks();
int computingUnits = granted.getTotalCPUComputingUnits();
if (limitOfTasks < 0 && computingUnits < 0) {
mc.setLimitOfTasks(0);
mc.setTotalComputingUnits(0);
} else {
mc.setLimitOfTasks(Math.max(limitOfTasks, computingUnits));
mc.setTotalComputingUnits(Math.max(limitOfTasks, computingUnits));
}
mc.setHost(granted.getName());
mc.setLimitOfGPUTasks(granted.getTotalGPUComputingUnits());
mc.setTotalGPUComputingUnits(granted.getTotalGPUComputingUnits());
mc.setLimitOfFPGATasks(granted.getTotalFPGAComputingUnits());
mc.setTotalFPGAComputingUnits(granted.getTotalFPGAComputingUnits());
mc.setLimitOfOTHERSTasks(granted.getTotalOTHERComputingUnits());
mc.setTotalOTHERComputingUnits(granted.getTotalOTHERComputingUnits());
worker = new CloudMethodWorker(granted.getName(), provider, granted, mc, cid.getSharedDisks());
try {
worker.announceCreation();
} catch (Exception e) {
RUNTIME_LOGGER.error("Machine " + granted.getName() + " shut down because an error announcing creation");
RESOURCE_LOGGER.error("ERROR_MSG = [\n\t" + ERROR_ANNOUNCE_VM + "\n\tNAME = " + granted.getName() + "\n\tPROVIDER = " + provider + "\n]", e);
throw new ConnectorException(e);
}
// Add the new machine to ResourceManager
if (operations.getTerminate()) {
RESOURCE_LOGGER.info("INFO_MSG = [\n\t" + WARN_VM_REFUSED + "\n\tRESOURCE_NAME = " + granted.getName() + "\n]");
try {
worker.announceDestruction();
} catch (Exception e) {
RESOURCE_LOGGER.error("ERROR_MSG = [\n\t" + ERROR_ANNOUNCE_VM_DESTROY + "\n\tVM_NAME = " + granted.getName() + "\n]", e);
}
Semaphore sem = new Semaphore(0);
ShutdownListener sl = new ShutdownListener(sem);
worker.stop(sl);
sl.enable();
try {
sem.acquire();
} catch (Exception e) {
RESOURCE_LOGGER.error(ERROR_WORKER_SHUTDOWN);
}
throw new ConnectorException(ERROR_USELESS_VM);
}
return worker;
}
Aggregations