use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class CRunningCapacity method getMisPlacedVMs.
@Override
public Set<VM> getMisPlacedVMs(Instance i) {
Mapping map = i.getModel().getMapping();
Set<VM> bad = new HashSet<>();
int remainder = cstr.getAmount();
for (Node n : cstr.getInvolvedNodes()) {
remainder -= map.getRunningVMs(n).size();
if (remainder < 0) {
for (Node n2 : cstr.getInvolvedNodes()) {
bad.addAll(map.getRunningVMs(n2));
}
return bad;
}
}
return bad;
}
use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class CSplit method getMisPlacedVMs.
@Override
public Set<VM> getMisPlacedVMs(Instance i) {
Mapping map = i.getModel().getMapping();
List<Collection<VM>> groups = new ArrayList<>(cstr.getSets());
// Bad contains the VMs on nodes that host VMs from different groups.
Set<VM> bad = new HashSet<>();
for (Collection<VM> grp : groups) {
for (VM vm : grp) {
if (map.isRunning(vm)) {
Node n = map.getVMLocation(vm);
Set<VM> allOnN = map.getRunningVMs(n);
for (VM vmOnN : allOnN) {
if (inOtherGroup(groups, grp, vmOnN)) {
// The VM belong to another group
bad.add(vm);
bad.add(vmOnN);
}
}
}
}
}
return bad;
}
use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class MaxOnlineTest method isSatisfiedModel.
@Test
public void isSatisfiedModel() {
Model model = new DefaultModel();
Mapping map = model.getMapping();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
map.addOnlineNode(n1);
map.addOnlineNode(n2);
map.addOfflineNode(n3);
Set<Node> s = new HashSet<>(Arrays.asList(n1, n2, n3));
MaxOnline mo = new MaxOnline(s, 2);
Assert.assertTrue(mo.isSatisfied(model));
model.getMapping().addOnlineNode(n3);
Assert.assertFalse(mo.isSatisfied(model));
}
use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class MaxOnlineTest method isSatisfiedReconfigurationPlan.
@Test
public void isSatisfiedReconfigurationPlan() {
Model model = new DefaultModel();
Mapping map = model.getMapping();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
map.addOnlineNode(n1);
map.addOnlineNode(n2);
map.addOfflineNode(n3);
Set<Node> s = new HashSet<>(Arrays.asList(n1, n2, n3));
MaxOnline mo = new MaxOnline(s, 2);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(model);
Assert.assertTrue(mo.isSatisfied(plan));
plan.add(new BootNode(n3, 3, 9));
Assert.assertFalse(mo.isSatisfied(plan));
plan.add(new ShutdownNode(n2, 0, 5));
Assert.assertTrue(mo.isSatisfied(plan));
}
use of org.btrplace.model.Mapping in project scheduler by btrplace.
the class AmongChecker method endsWith.
@Override
public boolean endsWith(Model i) {
Mapping map = i.getMapping();
Collection<Node> grp = null;
for (VM vm : getVMs()) {
if (map.isRunning(vm)) {
Collection<Node> nodes = getConstraint().getAssociatedPGroup(map.getVMLocation(vm));
if (nodes.isEmpty()) {
return false;
} else if (grp == null) {
grp = nodes;
} else if (!grp.equals(nodes)) {
return false;
}
}
}
return true;
}
Aggregations