use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class IssuesTest method issue72b.
@Test
public void issue72b() throws SchedulerException {
Model mo = new DefaultModel();
Mapping ma = mo.getMapping();
ShareableResource rcCPU = new ShareableResource("cpu", 2, 0);
mo.attach(rcCPU);
List<Node> nodes = new ArrayList<>();
for (int i = 0; i < 2; i++) {
nodes.add(mo.newNode());
ma.addOnlineNode(nodes.get(i));
}
for (int i = 0; i < 1; i++) {
VM v = mo.newVM();
ma.addRunningVM(v, nodes.get(0));
}
for (int i = 0; i < 2; i++) {
VM v = mo.newVM();
ma.addRunningVM(v, nodes.get(1));
}
DefaultParameters ps = new DefaultParameters();
ReconfigurationPlan p = new DefaultChocoScheduler(ps).solve(mo, new ArrayList<>());
Assert.assertNotNull(p);
}
use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class MaxOnlineChecker method startsWith.
@Override
public boolean startsWith(Model mo) {
if (getConstraint().isContinuous()) {
Mapping map = mo.getMapping();
currentOnline = 0;
for (Node n : getConstraint().getInvolvedNodes()) {
if (map.isOnline(n)) {
currentOnline++;
}
}
return currentOnline <= getConstraint().getAmount();
}
return true;
}
use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class QuarantineChecker method startsWith.
@Override
public boolean startsWith(Model mo) {
Mapping map = mo.getMapping();
getVMs().clear();
return getVMs().addAll(map.getRunningVMs(getNodes()));
}
use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class ResourceCapacityChecker method startsWith.
@Override
public boolean startsWith(Model mo) {
if (getConstraint().isContinuous()) {
rc = ShareableResource.get(mo, getConstraint().getResource());
free = getConstraint().getAmount();
Mapping map = mo.getMapping();
for (Node n : getNodes()) {
free -= rc.sumConsumptions(map.getRunningVMs(n), true);
if (free < 0) {
return false;
}
}
}
return true;
}
use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class RunningCapacityChecker method endsWith.
@Override
public boolean endsWith(Model mo) {
int nb = 0;
Mapping map = mo.getMapping();
for (Node n : getNodes()) {
nb += map.getRunningVMs(n).size();
if (nb > qty) {
return false;
}
}
return true;
}
Aggregations