use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodASetUpdated.
@Test
public void testMethodASetUpdated() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "," + "\"ClassB.methodA\":" + SET_AND_UPDATED_PROFILE + "}}"), null);
List<Implementation> impls = CoreManager.getCoreImplementations(0);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
if (impl.getImplementationId() == 0) {
try {
checkSetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-updated test");
}
} else {
try {
this.checkSetAndIncreasedProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-updated test");
}
}
}
impls = CoreManager.getCoreImplementations(1);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-updated test");
}
}
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodASetSet.
@Test
public void testMethodASetSet() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "," + "\"ClassB.methodA\":" + SET_PROFILE + "}}"), null);
List<Implementation> impls = CoreManager.getCoreImplementations(0);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkSetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-set test");
}
}
impls = CoreManager.getCoreImplementations(1);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-set test");
}
}
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class MOResourceOptimizer method createResourceForComponent.
private Resource<?> createResourceForComponent(CloudInstanceTypeDescription citd, CloudImageDescription cid) {
Resource<?> r = new Resource<>(null);
MOCloudTypeProfile moCloudTypeProf = (MOCloudTypeProfile) getCloudTypeProfile(citd);
r.idlePower = moCloudTypeProf.getIdlePower();
r.idlePrice = moCloudTypeProf.getIdlePrice();
MethodResourceDescription rd = citd.getResourceDescription();
r.capacity = new int[CoreManager.getCoreCount()];
r.profiles = new MOProfile[CoreManager.getCoreCount()];
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);
r.capacity[coreId] = rd.canHostSimultaneously((MethodResourceDescription) impl.getRequirements());
r.profiles[coreId] = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impl.getImplementationId());
}
r.startTime = cid.getCreationTime() * 1000;
r.clear();
return r;
}
use of es.bsc.compss.types.resources.MethodResourceDescription 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.MethodResourceDescription 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;
}
Aggregations