use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class ResourceManagerTest method createResourceDescriptionFromProvider.
private CloudMethodResourceDescription createResourceDescriptionFromProvider(CloudProvider cp1) {
CloudImageDescription cid = null;
CloudInstanceTypeDescription citd = null;
for (String imageName : cp1.getAllImageNames()) {
cid = cp1.getImage(imageName);
break;
}
for (String instanceType : cp1.getAllInstanceTypeNames()) {
citd = cp1.getInstanceType(instanceType);
break;
}
return new CloudMethodResourceDescription(citd, cid);
}
use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class Converter method toCloudMethodResourceDescription.
/**
*********************************************************************
************************ CONN TO COMPSs *****************************
* *********************************************************************
*/
/**
* @param vr
* @param requested
* @return
*/
public static CloudMethodResourceDescription toCloudMethodResourceDescription(VirtualResource vr, CloudMethodResourceDescription requested) {
CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription();
cmrd.setName(vr.getIp());
setHardwareInResourceDescription(cmrd, vr.getHd(), requested);
setSoftwareInResourceDescription(cmrd, vr.getSd(), requested);
CloudImageDescription cid = getCloudImageDescription(vr.getHd(), vr.getSd(), requested);
cmrd.setImage(cid);
return cmrd;
}
use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class Converter method getCloudImageDescription.
/**
* Returns the cloud image description
*
* @param hd
* @param sd
* @param requested
* @return
*/
private static CloudImageDescription getCloudImageDescription(HardwareDescription hd, SoftwareDescription sd, CloudMethodResourceDescription requested) {
CloudImageDescription from = requested.getImage();
CloudImageDescription cid = new CloudImageDescription(hd.getImageName(), hd.getImageProperties());
cid.setOperatingSystemType(sd.getOperatingSystemType());
cid.setOperatingSystemDistribution(sd.getOperatingSystemDistribution());
cid.setOperatingSystemVersion(sd.getOperatingSystemVersion());
cid.setAppSoftware(sd.getAppSoftware());
cid.setPricePerUnit(hd.getPricePerUnit());
cid.setPriceTimeUnit(hd.getPriceTimeUnit());
cid.setConfig(from.getConfig());
cid.setQueues(from.getQueues());
cid.setSharedDisks(from.getSharedDisks());
cid.setPackages(from.getPackages());
return cid;
}
use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class ResourceOptimizer method mandatoryReduction.
private void mandatoryReduction(float[] destroyRecommendations) {
List<CloudMethodWorker> critical = trimReductionOptions(ResourceManager.getCriticalDynamicResources(), destroyRecommendations);
// LinkedList<CloudMethodWorker> critical = checkCriticalSafeness
// (critical);
List<CloudMethodWorker> nonCritical = trimReductionOptions(ResourceManager.getNonCriticalDynamicResources(), destroyRecommendations);
Object[] criticalSolution = getBestDestruction(critical, destroyRecommendations);
Object[] nonCriticalSolution = getBestDestruction(nonCritical, destroyRecommendations);
boolean criticalIsBetter;
if (criticalSolution == null) {
if (nonCriticalSolution == null) {
return;
} else {
criticalIsBetter = false;
}
} else if (nonCriticalSolution == null) {
criticalIsBetter = true;
} else {
criticalIsBetter = false;
float[] noncriticalValues = (float[]) nonCriticalSolution[2];
float[] criticalValues = (float[]) criticalSolution[2];
if (noncriticalValues[0] == criticalValues[0]) {
if (noncriticalValues[1] == criticalValues[1]) {
if (noncriticalValues[2] < criticalValues[2]) {
criticalIsBetter = true;
}
} else if (noncriticalValues[1] > criticalValues[1]) {
criticalIsBetter = true;
}
} else if (noncriticalValues[0] > criticalValues[0]) {
criticalIsBetter = true;
}
}
CloudMethodWorker res;
CloudMethodResourceDescription cmrd;
// float[] record;
// int[][] slotsRemovingCount;
CloudInstanceTypeDescription citd;
if (criticalIsBetter) {
res = (CloudMethodWorker) criticalSolution[0];
citd = (CloudInstanceTypeDescription) criticalSolution[1];
} else {
if (nonCriticalSolution == null) {
return;
}
res = (CloudMethodWorker) nonCriticalSolution[0];
citd = (CloudInstanceTypeDescription) nonCriticalSolution[1];
}
cmrd = (CloudMethodResourceDescription) res.getDescription();
CloudImageDescription cid = cmrd.getImage();
CloudMethodResourceDescription finalDescription = new CloudMethodResourceDescription(citd, cid);
finalDescription.setName(res.getName());
ResourceManager.reduceCloudWorker(res, finalDescription);
}
use of es.bsc.compss.types.resources.description.CloudImageDescription in project compss by bsc-wdc.
the class MOResourceOptimizer method generatePossibleResourceReleases.
private void generatePossibleResourceReleases(LinkedList<Action> actions, Resource<?>[] allResources, int[] load) {
for (int i = 0; i < allResources.length; i++) {
Resource<?> excludedWorker = allResources[i];
Worker<?> w = excludedWorker.getResource();
// If worker is null, worker is being created. It cannot be destroyed yet.
if (w == null || !(w.getDescription() instanceof CloudMethodResourceDescription)) {
continue;
}
CloudMethodResourceDescription description = (CloudMethodResourceDescription) w.getDescription();
if (!(excludedWorker.hasPendingModifications())) {
CloudImageDescription image = description.getImage();
for (CloudInstanceTypeDescription typeReduction : description.getPossibleReductions()) {
CloudMethodResourceDescription reductionDescription = new CloudMethodResourceDescription(typeReduction, image);
CloudMethodResourceDescription reducedDescription = new CloudMethodResourceDescription(description);
reducedDescription.reduce(reductionDescription);
ConfigurationCost cc;
if (reducedDescription.getTypeComposition().isEmpty()) {
Resource<?>[] resources = new Resource[allResources.length - 1];
System.arraycopy(allResources, 0, resources, 0, i);
System.arraycopy(allResources, i + 1, resources, i, resources.length - i);
long time = excludedWorker.startTime;
double energy = excludedWorker.idlePower * time + excludedWorker.startEnergy;
double cost = excludedWorker.startCost;
cc = simulate(load, resources, time, energy, cost);
} else {
allResources[i] = reduceResourceForComponent(excludedWorker, reducedDescription);
long time = excludedWorker.startTime;
double energy = excludedWorker.idlePower * time + excludedWorker.startEnergy;
double cost = excludedWorker.startCost;
cc = simulate(load, allResources, time, energy, cost);
allResources[i] = excludedWorker;
}
Action a = new ActionRemove(excludedWorker, typeReduction, cc);
addToLog(a.toString());
actions.add(a);
}
}
}
}
Aggregations