use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CShareableResourceTest method testInitiallyUnsatisfied.
@Test
public void testInitiallyUnsatisfied() throws SchedulerException {
Model mo = new DefaultModel();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
ShareableResource rc = new ShareableResource("cpu", 1, 1);
VM v1 = mo.newVM();
VM v2 = mo.newVM();
mo.getMapping().addOnlineNode(n1);
mo.getMapping().addOnlineNode(n2);
mo.getMapping().addRunningVM(v1, n1);
mo.getMapping().addRunningVM(v2, n1);
mo.attach(rc);
ChocoScheduler s = new DefaultChocoScheduler();
try {
Assert.assertNull(s.solve(mo, new ArrayList<>()));
Assert.fail("Should have thrown an exception");
} catch (@SuppressWarnings("unused") SchedulerException e) {
Assert.assertEquals(s.getStatistics().getMetrics().backtracks(), 0);
}
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CShareableResourceTest method testMisplaced.
@Test
public void testMisplaced() throws SchedulerException {
Model mo = new DefaultModel();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
ShareableResource rc = new ShareableResource("cpu", 10, 1);
VM v1 = mo.newVM();
VM v2 = mo.newVM();
mo.getMapping().addOnlineNode(n1);
mo.getMapping().addOnlineNode(n2);
mo.getMapping().addRunningVM(v1, n1);
mo.getMapping().addRunningVM(v2, n1);
mo.attach(rc);
List<SatConstraint> l = new ArrayList<>();
l.addAll(Preserve.newPreserve(mo.getMapping().getAllVMs(), "cpu", 5));
ChocoScheduler s = new DefaultChocoScheduler();
s.doRepair(true);
ReconfigurationPlan p = s.solve(mo, l);
Assert.assertEquals(s.getStatistics().getNbManagedVMs(), 0);
Assert.assertNotNull(p);
Assert.assertEquals(p.getResult().getMapping(), mo.getMapping());
Assert.assertEquals(p.getSize(), 2);
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class SolverTuning method run.
@Override
@SuppressWarnings("squid:S1166")
public void run() {
// Make a default model with 500 nodes hosting 3,000 VMs
Model model = makeModel();
Set<SatConstraint> constraints = new HashSet<>();
// We allow memory over-commitment with a overbooking ratio of 50%
// i.e. 1MB physical RAM for 1.5MB virtual RAM
constraints.addAll(Overbook.newOverbooks(model.getMapping().getAllNodes(), "mem", 1.5));
/**
* On 10 nodes, 4 of the 6 hosted VMs ask now for a 4GB bandwidth
*/
for (int i = 0; i < 5; i++) {
Node n = nodes.get(i);
Set<VM> vmsOnN = model.getMapping().getRunningVMs(n);
Iterator<VM> ite = vmsOnN.iterator();
for (int j = 0; ite.hasNext() && j < 4; j++) {
VM v = ite.next();
constraints.add(new Preserve(v, "bandwidth", 4));
}
}
ChocoScheduler cra = new DefaultChocoScheduler();
// Customize the estimated duration of actions
cra.getDurationEvaluators().register(MigrateVM.class, new LinearToAResourceActionDuration<VM>("mem", 1, 3));
// We want the best possible solution, computed in up to 5 sec.
cra.doOptimize(true);
cra.setTimeLimit(5);
// We solve without the repair mode
cra.doRepair(false);
try {
solve(cra, model, constraints);
} catch (@SuppressWarnings("unused") SchedulerException ex) {
// Just in case the testing environment is not performant enough
// It does not matter that much if there is no enough time to get a solution here
}
// Re-solve using the repair mode to check for the improvement
cra.doRepair(true);
solve(cra, model, constraints);
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CAmongTest method testContinuousWithAlreadySatisfied.
@Test
public void testContinuousWithAlreadySatisfied() 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();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
Node n4 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2, n3, n4).run(n1, vm1).run(n2, vm2, vm3).ready(vm4, vm5);
Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2, vm5));
Collection<Node> s1 = new HashSet<>(Arrays.asList(n1, n2));
Collection<Node> s2 = new HashSet<>(Arrays.asList(n3, n4));
Collection<Collection<Node>> pGrps = new HashSet<>(Arrays.asList(s1, s2));
Among a = new Among(vms, pGrps);
a.setContinuous(true);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Running.newRunning(map.getAllVMs()));
cstrs.add(a);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CAmongTest method testWithOnGroup.
@Test
public void testWithOnGroup() 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();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
Node n4 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2, n3, n4).run(n1, vm1).run(n2, vm2).run(n3, vm3).ready(vm4, vm5);
Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
Collection<Collection<Node>> pGrps = new HashSet<>();
Set<Node> s = new HashSet<>();
s.add(n1);
s.add(n2);
pGrps.add(s);
Among a = new Among(vms, pGrps);
a.setContinuous(false);
ChocoScheduler cra = new DefaultChocoScheduler();
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Running.newRunning(map.getAllVMs()));
cstrs.add(a);
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
}
Aggregations