use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription 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.CloudInstanceTypeDescription 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.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class MOResourceOptimizer method generatePossibleResourceAcquisitions.
private void generatePossibleResourceAcquisitions(LinkedList<Action> actions, Resource<?>[] allResources, int[] load) {
for (CloudProvider cp : ResourceManager.getAvailableCloudProviders()) {
if (!cp.canHostMoreInstances()) {
continue;
}
for (CloudInstanceTypeDescription citd : cp.getAllTypes()) {
for (CloudImageDescription cid : cp.getAllImages()) {
Resource<?>[] resources = new Resource[allResources.length + 1];
System.arraycopy(allResources, 0, resources, 0, allResources.length);
resources[allResources.length] = createResourceForComponent(citd, cid);
ConfigurationCost cc = simulate(load, resources, 0, 0, 0);
Action a = new ActionAdd(cp, citd, cid, cc);
addToLog(a.toString());
actions.add(a);
}
}
}
}
use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class CloudTypeManager method getCompatibleTypes.
/**
* Finds all the types provided by the Cloud Provider which fulfill the resource description.
*
* @param requested
* description of the features that the image must provide
* @return The best instance type provided by the Cloud Provider which fulfills the resource description
*/
public List<CloudInstanceTypeDescription> getCompatibleTypes(MethodResourceDescription requested) {
List<CloudInstanceTypeDescription> compatiblesList = new LinkedList<>();
if (!this.types.isEmpty()) {
for (CloudInstanceTypeDescription type : this.types.values()) {
MethodResourceDescription resources = type.getResourceDescription();
if (resources.contains(requested)) {
// Satisfies the constraints, add compatible
compatiblesList.add(type);
}
}
} else {
CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription("NO TYPE", requested);
compatiblesList.add(citd);
}
return compatiblesList;
}
use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class ExternalAdaptationManager method cloudCreation.
private void cloudCreation(String providerName, String typeName, String imageName) {
if (providerName != null && typeName != null && imageName != null) {
CloudProvider cp = ResourceManager.getCloudProvider(providerName);
if (cp != null) {
CloudImageDescription imageDescription = cp.getImage(imageName);
CloudInstanceTypeDescription typeDescription = cp.getInstanceType(typeName);
CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription(typeDescription, imageDescription);
ResourceCreationRequest rcr = cp.requestResourceCreation(cmrd);
if (rcr != null) {
RUNTIME_LOGGER.info(LOG_PREFIX + "Submited external request for creating (" + typeName + ", " + imageName + ") in " + providerName);
rcr.print(RESOURCES_LOGGER, DEBUG);
writePipe(resultPipe, ACK);
} else {
RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: Creating resource (" + typeName + ", " + imageName + ") in " + providerName);
writePipe(resultPipe, "ERROR: Error creating resource(" + typeName + ", " + imageName + ") 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 (" + typeName + ", " + imageName + "," + providerName + ")");
writePipe(resultPipe, "ERROR: One of the parameters is incorrect (" + typeName + ", " + imageName + "," + providerName + ")");
}
}
Aggregations