use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CRunningCapacityTest method testWithSatisfiedConstraint.
@Test
public void testWithSatisfiedConstraint() 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();
Mapping map = mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm2).run(n3, vm3, vm4).sleep(n2, vm5);
List<SatConstraint> l = new ArrayList<>();
org.btrplace.model.constraint.RunningCapacity x = new org.btrplace.model.constraint.RunningCapacity(map.getAllNodes(), 4);
x.setContinuous(false);
l.add(x);
ChocoScheduler cra = new DefaultChocoScheduler();
cra.getDurationEvaluators().register(ShutdownVM.class, new ConstantActionDuration<>(10));
ReconfigurationPlan plan = cra.solve(mo, l);
Assert.assertEquals(plan.getSize(), 0);
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CRunningCapacityTest method testSingleContinuousResolution.
@Test
public void testSingleContinuousResolution() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
Node n1 = mo.newNode();
mo.getMapping().on(n1).run(n1, vm1, vm2).ready(vm3);
List<SatConstraint> l = new ArrayList<>();
l.add(new Running(vm1));
l.add(new Ready(vm2));
l.add(new Running(vm3));
RunningCapacity sc = new RunningCapacity(Collections.singleton(n1), 2, true);
sc.setContinuous(true);
l.add(sc);
ChocoScheduler cra = new DefaultChocoScheduler();
cra.setTimeLimit(3);
cra.getDurationEvaluators().register(ShutdownVM.class, new ConstantActionDuration<>(10));
ReconfigurationPlan plan = cra.solve(mo, l);
Assert.assertNotNull(plan);
Iterator<Action> ite = plan.iterator();
Assert.assertEquals(2, plan.getSize());
Action a1 = ite.next();
Action a2 = ite.next();
Assert.assertTrue(a1 instanceof ShutdownVM);
Assert.assertTrue(a2 instanceof BootVM);
Assert.assertTrue(a1.getEnd() <= a2.getStart());
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CSeqTest method testWithOnlyTransitions.
@Test
public void testWithOnlyTransitions() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2).ready(vm1).run(n1, vm2, vm4).sleep(n2, vm3);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.add(new Running(vm1));
cstrs.add(new Sleeping(vm2));
cstrs.add(new Running(vm3));
cstrs.add(new Ready(vm4));
cstrs.addAll(Online.newOnline(map.getAllNodes()));
ChocoScheduler cra = new DefaultChocoScheduler();
List<VM> seq = Arrays.asList(vm1, vm2, vm3, vm4);
cstrs.add(new Seq(seq));
ReconfigurationPlan plan = cra.solve(mo, cstrs);
Assert.assertNotNull(plan);
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CSplitAmongTest method testContinuousWithAllDiffViolated.
@Test
public void testContinuousWithAllDiffViolated() 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();
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);
s.setContinuous(true);
// vg1 and vg2 overlap on n2.
map.addRunningVM(vm6, n2);
ChocoScheduler cra = new DefaultChocoScheduler();
Assert.assertNull(cra.solve(mo, Collections.singleton(s)));
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CSplitAmongTest method testDiscreteWithGroupChange.
@Test
public void testDiscreteWithGroupChange() 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();
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<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));
Collection<Collection<Node>> pgs = new HashSet<>(Arrays.asList(pg1, pg2, pg3));
List<SatConstraint> cstrs = new ArrayList<>();
SplitAmong s = new SplitAmong(vgs, pgs);
s.setContinuous(false);
// Move group of VMs 1 to the group of nodes 2. This is allowed
// group of VMs 2 will move to another group of node so at the end, the constraint should be satisfied
cstrs.add(s);
for (VM v : vg1) {
cstrs.add(new Fence(v, pg2));
}
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan plan = cra.solve(mo, cstrs);
Assert.assertNotNull(plan);
}
Aggregations