use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceOptimizer method selectContainedInstance.
private static CloudInstanceTypeDescription selectContainedInstance(List<CloudInstanceTypeDescription> instances, MethodResourceDescription constraints, int amount) {
CloudInstanceTypeDescription bestType = null;
MethodResourceDescription bestDescription = null;
float bestDistance = Integer.MAX_VALUE;
for (CloudInstanceTypeDescription type : instances) {
MethodResourceDescription rd = type.getResourceDescription();
int slots = rd.canHostSimultaneously(constraints);
float distance = slots - amount;
RUNTIME_LOGGER.debug("[Resource Optimizer] Can host: slots = " + slots + " amount = " + amount + " distance = " + distance + " bestDistance = " + bestDistance);
if (distance < 0.0) {
continue;
}
if (distance < bestDistance) {
bestType = type;
bestDescription = type.getResourceDescription();
bestDistance = distance;
} else if (distance == bestDistance && bestDescription != null) {
if (bestDescription.getValue() != null && rd.getValue() != null && bestDescription.getValue() > rd.getValue()) {
// Evaluate optimal candidate
bestType = type;
bestDescription = type.getResourceDescription();
bestDistance = distance;
}
}
}
if (bestType == null) {
return null;
}
return bestType;
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceSchedulerTest method testAllSetCopy.
@Test
public void testAllSetCopy() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "," + "\"ClassB.methodA\":" + SET_PROFILE + "," + "\"ClassA.methodB\":" + SET_PROFILE + "}}"), null);
JSONObject jo = rs.toJSONObject();
rs = new ResourceScheduler<>(worker, jo, null);
for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
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 copy test");
}
}
}
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodANullUpdated.
@Test
public void testMethodANullUpdated() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"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 {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA null-updated test");
}
} else {
try {
this.checkSetAndIncreasedProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA null-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 null-updated test");
}
}
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodANullSet.
@Test
public void testMethodANullSet() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassB.methodA\":" + SET_PROFILE + "}}"), null);
List<Implementation> impls = CoreManager.getCoreImplementations(0);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
if (impl.getImplementationId() == 0) {
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA null-set test");
}
} else {
try {
checkSetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA null-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 null-set test");
}
}
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodBUpdated.
@Test
public void testMethodBUpdated() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodB\":" + SET_AND_UPDATED_PROFILE + "}}"), null);
List<Implementation> impls = CoreManager.getCoreImplementations(0);
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 MethodB updated test");
}
}
impls = CoreManager.getCoreImplementations(1);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkSetAndIncreasedProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodB updated test");
}
}
}
Aggregations