use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription 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.resources.description.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class ResourceOptimizer method optionalReduction.
private boolean optionalReduction(float[] destroyRecommendations) {
List<CloudMethodWorker> nonCritical = trimReductionOptions(ResourceManager.getNonCriticalDynamicResources(), destroyRecommendations);
if (DEBUG) {
RUNTIME_LOGGER.debug("[Resource Optimizer] Searching for best destruction");
}
Object[] nonCriticalSolution = getBestDestruction(nonCritical, destroyRecommendations);
CloudMethodWorker res;
float[] record;
CloudInstanceTypeDescription rd;
if (nonCriticalSolution == null || nonCriticalSolution[0] == null || nonCriticalSolution[1] == null || nonCriticalSolution[2] == null) {
if (DEBUG) {
RUNTIME_LOGGER.warn("[Resource Optimizer] No solution found");
}
return false;
}
res = (CloudMethodWorker) nonCriticalSolution[0];
rd = (CloudInstanceTypeDescription) nonCriticalSolution[1];
record = (float[]) nonCriticalSolution[2];
if (DEBUG) {
RUNTIME_LOGGER.debug("[Resource Optimizer] Best resource to remove is " + res.getName() + "and record is [" + record[0] + "," + record[1] + "," + record[2]);
}
if (record[1] > 0 && res.getUsedCPUTaskCount() > 0) {
RUNTIME_LOGGER.debug("[Resource Optimizer] Optional destroy recommendation not applied");
return false;
} else {
RUNTIME_LOGGER.debug("[Resource Optimizer] Optional destroy recommendation applied");
CloudMethodResourceDescription finalDescription = new CloudMethodResourceDescription(rd, res.getDescription().getImage());
finalDescription.setName(res.getName());
ResourceManager.reduceCloudWorker(res, finalDescription);
return true;
}
}
use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription 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.resources.description.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class CloudTypeManager method newCoreElementsDetected.
public void newCoreElementsDetected(List<Integer> newCores) {
int coreCount = CoreManager.getCoreCount();
for (CloudInstanceTypeDescription type : types.values()) {
int[][] slotsI = new int[coreCount][];
// Copy actual values
int[] slotsC = Arrays.copyOf(type.getSlotsCore(), coreCount);
for (int i = 0; i < type.getSlotsImplLength(); ++i) {
int[] slotsImpl = type.getSpecificSlotsImpl(i);
slotsI[i] = slotsImpl.clone();
}
// Get new values
for (int coreId : newCores) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
int implsSize = impls.size();
slotsI[coreId] = new int[implsSize];
for (int implId = 0; implId < implsSize; ++implId) {
Implementation impl = impls.get(implId);
if (impl.getTaskType() == TaskType.METHOD) {
MethodResourceDescription rd = (MethodResourceDescription) impl.getRequirements();
Integer into = type.getResourceDescription().canHostSimultaneously(rd);
slotsC[coreId] = Math.max(slotsC[coreId], into);
slotsI[coreId][implId] = into;
}
}
}
type.setSlotsCore(slotsC);
type.setSlotsImpl(slotsI);
}
}
use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class ResourceLoader method createInstance.
private static CloudInstanceTypeDescription createInstance(es.bsc.compss.types.resources.jaxb.InstanceTypeType instance) {
// Add the name
// String name = instance.getName();
String type = instance.getName();
MethodResourceDescription mrd = new MethodResourceDescription();
List<es.bsc.compss.types.resources.jaxb.ProcessorType> processors = resources.getProcessors(instance);
if (processors != null) {
for (es.bsc.compss.types.resources.jaxb.ProcessorType p : processors) {
String procName = p.getName();
int computingUnits = resources.getProcessorComputingUnits(p);
String architecture = resources.getProcessorArchitecture(p);
float speed = resources.getProcessorSpeed(p);
String procType = resources.getProcessorType(p);
float internalMemory = resources.getProcessorMemorySize(p);
ProcessorPropertyType procProp = resources.getProcessorProperty(p);
String propKey = (procProp != null) ? procProp.getKey() : "";
String propValue = (procProp != null) ? procProp.getValue() : "";
mrd.addProcessor(procName, computingUnits, architecture, speed, procType, internalMemory, propKey, propValue);
}
}
mrd.setMemorySize(resources.getMemorySize(instance));
mrd.setMemoryType(resources.getMemoryType(instance));
mrd.setStorageSize(resources.getStorageSize(instance));
mrd.setStorageType(resources.getStorageType(instance));
es.bsc.compss.types.resources.jaxb.PriceType p = resources.getPrice(instance);
if (p != null) {
mrd.setPriceTimeUnit(p.getTimeUnit());
mrd.setPricePerUnit(p.getPricePerUnit());
}
return new CloudInstanceTypeDescription(type, mrd);
}
Aggregations