use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription 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.CloudMethodResourceDescription in project compss by bsc-wdc.
the class ResourceOptimizer method askForResources.
/**
* The CloudManager ask for resources that can execute certain amount of cores at the same time. It checks the best
* resource that each provider can offer to execute that amount of cores and picks one of them. It constructs a
* resourceRequest describing the resource and which cores can be executed on it. This ResourceRequest will be used
* to ask for that resource creation to the Cloud Provider and returned if the application is accepted.
*
* @param amount
* amount of slots
* @param requirements
* features of the resource
* @param contained
* {@literal true} if we want the request to ask for a resource contained in the description; else, the
* result contains the passed in description.
* @return
*/
public static ResourceCreationRequest askForResources(Integer amount, MethodResourceDescription requirements, boolean contained) {
// Search best resource
CloudProvider bestProvider = null;
CloudMethodResourceDescription bestConstraints = null;
Float bestValue = Float.MAX_VALUE;
for (CloudProvider cp : ResourceManager.getAvailableCloudProviders()) {
CloudMethodResourceDescription rc = getBestIncreaseOnProvider(cp, amount, requirements, contained);
if (rc != null && rc.getValue() < bestValue) {
bestProvider = cp;
bestConstraints = rc;
bestValue = rc.getValue();
} else if (rc != null && bestConstraints == null) {
bestProvider = cp;
bestConstraints = rc;
bestValue = rc.getValue();
} else {
RUNTIME_LOGGER.warn(WARN_NO_POSIBLE_INCREASE + " (" + cp.getName() + ")");
}
}
if (bestConstraints == null) {
RUNTIME_LOGGER.warn(WARN_NO_RESOURCE_MATCHES);
return null;
}
return bestProvider.requestResourceCreation(bestConstraints);
}
use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription in project compss by bsc-wdc.
the class MOResourceOptimizer method reduceResourceForComponent.
private Resource<?> reduceResourceForComponent(Resource<?> excludedWorker, CloudMethodResourceDescription reduction) {
Resource<?> clone = new Resource<>(excludedWorker.worker);
clone.idlePower = excludedWorker.idlePower;
clone.idlePrice = excludedWorker.idlePrice;
clone.capacity = new int[excludedWorker.capacity.length];
System.arraycopy(excludedWorker.capacity, 0, clone.capacity, 0, excludedWorker.capacity.length);
clone.startTime = excludedWorker.startTime;
clone.startEnergy = excludedWorker.startEnergy;
clone.startCost = excludedWorker.startCost;
clone.time = excludedWorker.time;
clone.counts = excludedWorker.counts;
Map<CloudInstanceTypeDescription, int[]> composition = reduction.getTypeComposition();
for (Map.Entry<CloudInstanceTypeDescription, int[]> component : composition.entrySet()) {
CloudInstanceTypeDescription type = component.getKey();
int count = component.getValue()[0];
MethodResourceDescription rd = type.getResourceDescription();
MOCloudTypeProfile moCloudTypeProf = (MOCloudTypeProfile) getCloudTypeProfile(type);
clone.idlePower -= moCloudTypeProf.getIdlePower() * count;
clone.idlePrice -= moCloudTypeProf.getIdlePrice() * count;
for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
MOProfile[] profiles = new MOProfile[impls.size()];
for (int i = 0; i < impls.size(); i++) {
profiles[i] = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impls.get(i).getImplementationId());
}
Implementation impl = getBestImplementation(impls, profiles);
clone.capacity[coreId] -= rd.canHostSimultaneously((MethodResourceDescription) impl.getRequirements()) * count;
}
}
return clone;
}
use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription 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);
}
}
}
}
use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription in project compss by bsc-wdc.
the class AbstractConnector method waitCreation.
@Override
public VM waitCreation(Object envId, CloudMethodResourceDescription requested) throws ConnectorException {
CloudMethodResourceDescription granted = waitUntilCreation(envId, requested);
VM vm = new VM(envId, granted);
vm.setRequestTime(powerOnVMTimestamp.remove(envId));
LOGGER.info("[Abstract Connector] Virtual machine created: " + vm);
float oneHourCost = getMachineCostPerHour(granted);
currentCostPerHour += oneHourCost;
addMachine(vm);
return vm;
}
Aggregations