use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class FixedNodeSetsPartitioningTest method makeInstance.
private Instance makeInstance() {
Model mo = new DefaultModel();
for (int i = 0; i < 20; i++) {
Node n = mo.newNode();
mo.getMapping().addOnlineNode(n);
VM v = mo.newVM();
// 1 VM per node is already running
mo.getMapping().addRunningVM(v, n);
}
// 30 VMs to launch
for (int i = 0; i < 30; i++) {
VM v = mo.newVM();
mo.getMapping().addReadyVM(v);
}
return new Instance(mo, Running.newRunning(mo.getMapping().getAllVMs()), new MinMTTR());
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class IssuesTest method testIssue89.
@Test
public static void testIssue89() throws Exception {
final Model model = new DefaultModel();
final Mapping mapping = model.getMapping();
final Node node0 = model.newNode(0);
final int[] ids0 = { 1, 45, 43, 40, 39, 38, 82, 80, 79, 78, 30, 75, 18, 16, 15, 14, 60, 9, 55, 54, 50, 48 };
final Node node1 = model.newNode(1);
final int[] ids1 = { 84, 83, 81, 77, 73, 71, 64, 63, 62, 57, 53, 52, 47, 46, 44, 41, 34, 31, 28, 25, 13, 8, 6, 4, 3, 0 };
final Node node2 = model.newNode(2);
final int[] ids2 = { 21, 67, 42, 36, 35, 33, 76, 74, 23, 69, 68, 20, 61, 12, 11, 10, 5, 51 };
final Node node3 = model.newNode(3);
final int[] ids3 = { 2, 66, 86, 85, 37, 32, 29, 27, 26, 72, 24, 70, 22, 19, 65, 17, 59, 58, 56, 7, 49 };
final ShareableResource cpu = new ShareableResource("cpu", 45, 1);
final ShareableResource mem = new ShareableResource("mem", 90, 2);
populateNodeVm(model, mapping, node0, ids0);
populateNodeVm(model, mapping, node1, ids1);
populateNodeVm(model, mapping, node2, ids2);
populateNodeVm(model, mapping, node3, ids3);
model.attach(cpu);
model.attach(mem);
final Collection<SatConstraint> satConstraints = new ArrayList<>();
// We want to cause Node 3 to go offline to see how the VMs hosted on that
// node will get rebalanced.
satConstraints.add(new Offline(node3));
final OptConstraint optConstraint = new MinMTTR();
DefaultChocoScheduler scheduler = new DefaultChocoScheduler();
scheduler.doOptimize(false);
scheduler.doRepair(true);
scheduler.setTimeLimit(60000);
ReconfigurationPlan plan = scheduler.solve(model, satConstraints, optConstraint);
System.out.println(scheduler.getStatistics());
Assert.assertTrue(plan.isApplyable());
satConstraints.clear();
// This is somewhat similar to making Node 3 going offline by ensuring that
// all VMs can no longer get hosted on that node.
satConstraints.addAll(mapping.getAllVMs().stream().map(vm -> new Ban(vm, Collections.singletonList(node3))).collect(Collectors.toList()));
scheduler = new DefaultChocoScheduler();
scheduler.doOptimize(false);
scheduler.doRepair(true);
plan = scheduler.solve(model, satConstraints, optConstraint);
Assert.assertTrue(plan.isApplyable());
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class COverbookTest method testGetMisplaced.
@Test
public void testGetMisplaced() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
VM vm5 = mo.newVM();
VM vm6 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2, vm3).run(n3, vm4, vm5, vm6);
ShareableResource rcCPU = new ShareableResource("cpu", 1, 1);
mo.attach(rcCPU);
Overbook o1 = new Overbook(n1, "cpu", 1);
Overbook o2 = new Overbook(n2, "cpu", 2);
Overbook o3 = new Overbook(n3, "cpu", 3);
COverbook co1 = new COverbook(o1);
COverbook co2 = new COverbook(o2);
COverbook co3 = new COverbook(o3);
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
Assert.assertTrue(co1.getMisPlacedVMs(i).isEmpty());
Assert.assertTrue(co2.getMisPlacedVMs(i).isEmpty());
Assert.assertEquals(o3.getInvolvedVMs(), co3.getMisPlacedVMs(i));
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class CSleepingTest method testGetMisplaced.
@Test
public void testGetMisplaced() {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
Node n1 = mo.newNode();
mo.getMapping().on(n1).ready(vm1).run(n1, vm2).sleep(n1, vm3);
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
CSleeping k = new CSleeping(new Sleeping(vm3));
Assert.assertEquals(0, k.getMisPlacedVMs(i).size());
k = new CSleeping(new Sleeping(vm1));
Assert.assertEquals(1, k.getMisPlacedVMs(i).size());
Assert.assertTrue(k.getMisPlacedVMs(i).contains(vm1));
k = new CSleeping(new Sleeping(vm3));
Assert.assertEquals(0, k.getMisPlacedVMs(i).size());
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class CSplitAmongTest method testGetMisplaced.
@Test
public void testGetMisplaced() {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
VM vm5 = mo.newVM();
VM vm6 = mo.newVM();
VM vm7 = mo.newVM();
VM vm8 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
Node n4 = mo.newNode();
Node n5 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2, n3, n4, n5).run(n1, vm1, vm3).run(n2, vm2).run(n3, vm4, vm6).run(n4, vm5).run(n5, vm7);
// Isolated VM not considered by the constraint
map.addRunningVM(vm8, n1);
Collection<VM> vg1 = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
Collection<VM> vg2 = new HashSet<>(Arrays.asList(vm4, vm5, vm6));
Collection<VM> vg3 = new HashSet<>(Collections.singletonList(vm7));
Collection<Node> pg1 = new HashSet<>(Arrays.asList(n1, n2));
Collection<Node> pg2 = new HashSet<>(Arrays.asList(n3, n4));
Collection<Node> pg3 = new HashSet<>(Collections.singletonList(n5));
Collection<Collection<VM>> vgs = new HashSet<>(Arrays.asList(vg1, vg2, vg3));
Collection<Collection<Node>> pgs = new HashSet<>(Arrays.asList(pg1, pg2, pg3));
SplitAmong s = new SplitAmong(vgs, pgs);
CSplitAmong cs = new CSplitAmong(s);
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
Assert.assertTrue(cs.getMisPlacedVMs(i).isEmpty());
map.remove(vm7);
map.addRunningVM(vm6, n5);
// vg2 is on 2 group of nodes, the whole group is mis-placed
Assert.assertEquals(cs.getMisPlacedVMs(i), vg2);
map.addRunningVM(vm7, n5);
// vg1 and vg2 overlap on n1. The two groups are mis-placed
map.addRunningVM(vm6, n2);
Assert.assertTrue(cs.getMisPlacedVMs(i).containsAll(vg1));
Assert.assertTrue(cs.getMisPlacedVMs(i).containsAll(vg2));
Assert.assertEquals(cs.getMisPlacedVMs(i).size(), vg1.size() + vg2.size());
}
Aggregations