use of es.bsc.compss.types.CloudProvider in project compss by bsc-wdc.
the class ResourceOptimizer method getBestDestruction.
/**
* Given a set of resources, it checks every possible modification of the resource and returns the one that better
* fits with the destruction recommendations.
*
* The decision-making algorithm tries to minimize the number of affected CE that weren't recommended to be
* modified, minimize the number of slots that weren't requested to be destroyed and maximize the number of slots
* that can be removed and they were requested for.
*
* @param resourceSet
* set of resources
* @param destroyRecommendations
* number of slots to be removed for each CE
* @return an object array defining the best solution.
*
* 0-> (Resource) selected Resource.
*
* 1->(CloudTypeInstanceDescription) Type to be destroyed to be destroyed.
*
* 2-> (int[]) record of the #CE with removed slots and that they shouldn't be modified, #slots that will be
* destroyed and they weren't recommended, #slots that will be removed and they were asked to be.
*/
private Object[] getBestDestruction(Collection<CloudMethodWorker> resourceSet, float[] destroyRecommendations) {
CloudProvider cp;
float[] bestRecord = new float[3];
bestRecord[0] = Float.MAX_VALUE;
bestRecord[1] = Float.MAX_VALUE;
bestRecord[2] = Float.MIN_VALUE;
Resource bestResource = null;
CloudInstanceTypeDescription bestType = null;
for (CloudMethodWorker res : resourceSet) {
cp = res.getProvider();
if (cp == null) {
// it's not a cloud machine
if (DEBUG) {
RUNTIME_LOGGER.debug("Resource " + res.getName() + " is not cloud. Skipping...");
}
continue;
}
Map<CloudInstanceTypeDescription, float[]> typeToPoints = getPossibleReductions(res, destroyRecommendations);
for (Map.Entry<CloudInstanceTypeDescription, float[]> destruction : typeToPoints.entrySet()) {
CloudInstanceTypeDescription type = destruction.getKey();
float[] values = destruction.getValue();
if (DEBUG) {
RUNTIME_LOGGER.debug("Type: " + type.getName() + " value 0: " + values[0] + " (" + bestRecord[0] + ") " + " value 1: " + values[1] + " (" + bestRecord[1] + ") " + " value 2: " + values[2] + " (" + bestRecord[2] + ")");
}
if (bestRecord[0] == values[0]) {
if (bestRecord[1] == values[1]) {
if (bestRecord[2] < values[2]) {
bestRecord = values;
bestResource = res;
bestType = type;
}
} else if (bestRecord[1] > values[1]) {
bestRecord = values;
bestResource = res;
bestType = type;
}
} else if (bestRecord[0] > values[0]) {
bestRecord = values;
bestResource = res;
bestType = type;
}
}
}
if (bestResource != null) {
Object[] ret = new Object[3];
ret[0] = bestResource;
ret[1] = bestType;
ret[2] = bestRecord;
return ret;
} else {
RUNTIME_LOGGER.warn("Best resource to remove not found");
return null;
}
}
use of es.bsc.compss.types.CloudProvider in project compss by bsc-wdc.
the class Test method cloudManagerTest.
/*
* *********************************** CLOUD MANAGER TEST IMPLEMENTATION ***********************************
*/
private static void cloudManagerTest() {
// Print Out CloudManager static structures
System.out.println("[LOG] CloudManager Static Structures definition");
// Check for each implementation the correctness of its resources
coreCount = CoreManager.getCoreCount();
CloudProvider cp = ResourceManager.getCloudProvider("BSC");
for (int coreId = 0; coreId < coreCount; coreId++) {
System.out.println("[LOG] Checking Core" + coreId);
for (Implementation impl : CoreManager.getCoreImplementations(coreId)) {
if (impl.getTaskType().equals(TaskType.METHOD)) {
System.out.println("[LOG]\t Checking Implementation: " + impl.getImplementationId());
System.out.println("\t\t Checking obtained compatible cloud images");
MethodImplementation mImpl = (MethodImplementation) impl;
for (CloudImageDescription cid_gci : cp.getCompatibleImages(mImpl.getRequirements())) {
System.out.println("\t\t\t Checking compatible Image: " + cid_gci.getImageName());
String res = checkImplementationAssignedToCloudImage(mImpl.getRequirements(), cid_gci);
if (res != null) {
String error = "[ERROR] Implementation: Core = " + coreId + " Impl = " + impl.getImplementationId() + ". ";
error = error.concat("Implementation and cloud image not matching on: " + res);
System.out.println(error);
System.exit(-1);
}
}
System.out.println("\t\t Checking obtained compatible cloud types");
for (CloudInstanceTypeDescription type : cp.getCompatibleTypes(new CloudMethodResourceDescription(mImpl.getRequirements()))) {
if (type.getResourceDescription().canHostSimultaneously(mImpl.getRequirements()) < 1) {
continue;
}
System.out.println("\t\t\t Checking compatible Type: " + type.getName());
String res = checkImplementationAssignedToType(mImpl.getRequirements(), type.getResourceDescription());
if (res != null) {
String error = "[ERROR] Implementation: Core = " + coreId + " Impl = " + impl.getImplementationId() + ". ";
error = error.concat("Implementation and type not matching on: " + res);
System.out.println(error);
System.exit(-1);
}
}
}
}
}
// Return success value
System.out.println("[LOG] * CloudManager test passed");
}
use of es.bsc.compss.types.CloudProvider in project compss by bsc-wdc.
the class CloudManager method terminateALL.
/**
* CloudManager terminates all the resources obtained from any provider
*
* @throws ConnectorException
*/
public void terminateALL() throws ConnectorException {
RUNTIME_LOGGER.debug("[Cloud Manager] Terminate ALL resources");
if (providers != null) {
for (Entry<String, CloudProvider> vm : providers.entrySet()) {
CloudProvider cp = vm.getValue();
cp.terminateAll();
}
}
}
use of es.bsc.compss.types.CloudProvider in project compss by bsc-wdc.
the class ExternalAdaptationManager method cloudRemove.
private void cloudRemove(String providerName, String name) {
if (providerName != null && name != null) {
CloudProvider cp = ResourceManager.getCloudProvider(providerName);
if (cp != null) {
CloudMethodWorker cmw = cp.getHostedWorker(name);
if (cmw != null) {
ResourceManager.reduceCloudWorker(cmw, cmw.getDescription());
RUNTIME_LOGGER.info(LOG_PREFIX + "Submited external request for removing " + name + " in " + providerName);
writePipe(resultPipe, ACK);
} else {
RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: resource " + name + " not found in " + providerName);
writePipe(resultPipe, "ERROR: Error creating resource " + name + " not found 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 (" + name + "," + providerName + ")");
writePipe(resultPipe, "ERROR: One of the parameters is incorrect (" + name + "," + providerName + ")");
}
}
use of es.bsc.compss.types.CloudProvider in project compss by bsc-wdc.
the class ResourceManager method addCloudWorker.
/**
* Adds a cloud worker
*
* @param origin
* @param worker
* @param granted
*/
public static void addCloudWorker(ResourceCreationRequest origin, CloudMethodWorker worker, CloudMethodResourceDescription granted) {
synchronized (pool) {
CloudProvider cloudProvider = origin.getProvider();
cloudProvider.confirmedCreation(origin, worker, granted);
worker.updatedFeatures();
pool.addDynamicResource(worker);
pool.defineCriticalSet();
int[] maxTaskCount = worker.getSimultaneousTasks();
for (int coreId = 0; coreId < maxTaskCount.length; coreId++) {
poolCoreMaxConcurrentTasks[coreId] += maxTaskCount[coreId];
}
}
ResourceUpdate<MethodResourceDescription> ru = new PerformedIncrease<>(worker.getDescription());
resourceUser.updatedResource(worker, ru);
// Log new resource
RESOURCES_LOGGER.info("TIMESTAMP = " + String.valueOf(System.currentTimeMillis()));
RESOURCES_LOGGER.info("INFO_MSG = [New resource available in the pool. Name = " + worker.getName() + "]");
RUNTIME_LOGGER.info("New resource available in the pool. Name = " + worker.getName());
}
Aggregations