use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription in project compss by bsc-wdc.
the class CloudProvider method getCurrentState.
/*
* ----------------------------------------- ------------- Debug Queries -------------
* ----------------------------------------
*/
public String getCurrentState(String prefix) {
StringBuilder sb = new StringBuilder();
sb.append(prefix).append("PROVIDER = [").append("\n");
sb.append(prefix).append("\t").append("NAME = ").append(name).append("\n");
sb.append(prefix).append("\t").append("CURRENT_VM = ").append(currentVMCount).append("\n");
sb.append(prefix).append("\t").append("LIMIT_VM = ").append(limitOfVMs).append("\n");
sb.append(imgManager.getCurrentState(prefix + "\t"));
sb.append(typeManager.getCurrentState(prefix + "\t"));
// Virtual Instances
sb.append(prefix).append("\t").append("VIRTUAL_INSTANCES = [").append("\n");
for (CloudMethodWorker vm : hostedWorkers) {
CloudMethodResourceDescription cmrd = vm.getDescription();
sb.append(cmrd.getCurrentState(prefix + "\t")).append("\n");
}
sb.append(prefix).append("\t").append("]").append("\n");
sb.append(prefix).append("]").append("\n");
return sb.toString();
}
use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription in project compss by bsc-wdc.
the class CloudProvider method refusedCreation.
public void refusedCreation(ResourceCreationRequest rcr) {
CloudMethodResourceDescription cmrd = rcr.getRequested();
for (int[] typeCount : cmrd.getTypeComposition().values()) {
currentVMCount -= typeCount[0];
}
pendingRequests.remove(rcr);
int[][] simultaneousCounts = rcr.requestedSimultaneousTaskCount();
for (int coreId = 0; coreId < simultaneousCounts.length; coreId++) {
int coreSlots = 0;
for (int implId = 0; implId < simultaneousCounts[coreId].length; implId++) {
coreSlots = Math.max(coreSlots, simultaneousCounts[coreId][implId]);
}
this.pendingCoreCount[coreId] -= coreSlots;
}
}
use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription in project compss by bsc-wdc.
the class CloudProvider method requestResourceCreation.
public ResourceCreationRequest requestResourceCreation(CloudMethodResourceDescription instanceDescription) {
int[][] simultaneousCounts = computeSimultaneousCounts(instanceDescription);
ResourceCreationRequest rcr = new ResourceCreationRequest(instanceDescription, simultaneousCounts, this);
LOGGER.debug("[Cloud Manager] Asking for resource creation " + instanceDescription.getName() + " with image " + instanceDescription.getImage().getImageName());
boolean isRequestAccepted = connector.turnON("compss" + UUID.randomUUID().toString(), rcr);
if (isRequestAccepted) {
CloudMethodResourceDescription cmrd = rcr.getRequested();
for (int[] typeCount : cmrd.getTypeComposition().values()) {
currentVMCount += typeCount[0];
}
pendingRequests.add(rcr);
for (int coreId = 0; coreId < simultaneousCounts.length; coreId++) {
int coreSlots = 0;
for (int implId = 0; implId < simultaneousCounts[coreId].length; implId++) {
coreSlots = Math.max(coreSlots, simultaneousCounts[coreId][implId]);
}
this.pendingCoreCount[coreId] += coreSlots;
}
return rcr;
} else {
LOGGER.warn(WARN_CANNOT_TURN_ON);
return null;
}
}
use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription in project compss by bsc-wdc.
the class CloudProvider method getResourceDescription.
public CloudMethodResourceDescription getResourceDescription(String instanceTypeName, String imageName) {
CloudMethodResourceDescription result = null;
CloudInstanceTypeDescription type = typeManager.getType(instanceTypeName);
if (type != null) {
CloudImageDescription image = imgManager.getImage(imageName);
if (image != null) {
result = new CloudMethodResourceDescription(type, image);
result.setValue(cost.getMachineCostPerHour(result));
} else {
LOGGER.warn(WARN_NO_VALID_IMAGE);
}
} else {
LOGGER.warn(WARN_NO_VALID_INSTANCE);
}
return result;
}
use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription in project compss by bsc-wdc.
the class CloudProvider method confirmedCreation.
public void confirmedCreation(ResourceCreationRequest rcr, CloudMethodWorker worker, CloudMethodResourceDescription granted) {
CloudMethodResourceDescription cmrd = rcr.getRequested();
for (int[] typeCount : cmrd.getTypeComposition().values()) {
currentVMCount -= typeCount[0];
}
for (int[] typeCount : granted.getTypeComposition().values()) {
currentVMCount += typeCount[0];
}
pendingRequests.remove(rcr);
int[][] simultaneousCounts = rcr.requestedSimultaneousTaskCount();
for (int coreId = 0; coreId < simultaneousCounts.length; coreId++) {
int coreSlots = 0;
for (int implId = 0; implId < simultaneousCounts[coreId].length; implId++) {
coreSlots = Math.max(coreSlots, simultaneousCounts[coreId][implId]);
}
this.pendingCoreCount[coreId] -= coreSlots;
}
hostedWorkers.add(worker);
}
Aggregations