use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CRunningCapacityTest method testIssue112.
@Test
public void testIssue112() throws Exception {
String buf = "{\"model\":{\"mapping\":{\"readyVMs\":[],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[0]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[2,1]},\"2\":{\"sleepingVMs\":[],\"runningVMs\":[]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{}},\"views\":[]},\"constraints\":[{\"vm\":0,\"continuous\":false,\"id\":\"running\"},{\"vm\":1,\"continuous\":false,\"id\":\"running\"},{\"vm\":2,\"continuous\":false,\"id\":\"running\"},{\"amount\":2,\"nodes\":[0],\"continuous\":false,\"id\":\"runningCapacity\"},{\"amount\":1,\"nodes\":[1],\"continuous\":false,\"id\":\"runningCapacity\"},{\"amount\":0,\"nodes\":[2],\"continuous\":false,\"id\":\"runningCapacity\"},{\"continuous\":false,\"parts\":[[0,1,2]],\"id\":\"among\",\"vms\":[0]},{\"continuous\":false,\"parts\":[[0,1,2]],\"id\":\"among\",\"vms\":[1]},{\"continuous\":false,\"parts\":[[0,1,2]],\"id\":\"among\",\"vms\":[2]}],\"objective\":{\"id\":\"minimizeMTTR\"}}";
Instance i = JSON.readInstance(new StringReader(buf));
List<SatConstraint> l = i.getSatConstraints().stream().filter(s -> !(s instanceof Among)).collect(Collectors.toList());
ChocoScheduler s = new DefaultChocoScheduler();
i = new Instance(i.getModel(), l, new MinMTTR());
ReconfigurationPlan p = s.solve(i);
Assert.assertNotNull(p);
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CSeqTest method testWithVMsWithNoTransitions.
@Test
public void testWithVMsWithNoTransitions() 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();
mo.getMapping().on(n1, n2).ready(vm1).run(n1, vm2, vm4).run(n2, vm3);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.add(new Running(vm1));
cstrs.add(new Running(vm2));
cstrs.add(new Running(vm3));
cstrs.add(new Ready(vm4));
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);
// System.out.println(plan);
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CSplitAmongTest method testContinuousWithGroupChange.
@Test
public void testContinuousWithGroupChange() 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(true);
// Move group of VMs 1 to the group of nodes 2. Cannot work as
// the among part of the constraint will be violated
cstrs.add(s);
for (VM v : vg1) {
cstrs.add(new Fence(v, pg2));
}
ChocoScheduler cra = new DefaultChocoScheduler();
Assert.assertNull(cra.solve(mo, cstrs));
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CSplitAmongTest method testDiscrete.
@Test
public void testDiscrete() 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(false);
// vg1 and vg2 overlap on n2. The two groups are mis-placed
map.addRunningVM(vm6, n2);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan p = cra.solve(mo, Collections.singleton(s));
Assert.assertNotNull(p);
Assert.assertTrue(p.getSize() > 0);
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CSplitTest method testSimpleDiscrete.
@Test
public void testSimpleDiscrete() 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();
mo.getMapping().on(n1, n2, n3, n4, n5).run(n1, vm1, vm2, vm3).run(n3, vm4, vm5, vm6).run(n5, vm7, vm8);
Collection<VM> g1 = Arrays.asList(vm1, vm2);
Collection<VM> g2 = Arrays.asList(vm3, vm4, vm5);
Collection<VM> g3 = Arrays.asList(vm6, vm7);
Collection<Collection<VM>> grps = Arrays.asList(g1, g2, g3);
Split s = new Split(grps);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan p = cra.solve(mo, Collections.singleton(s));
Assert.assertNotNull(p);
Assert.assertTrue(p.getSize() > 0);
}
Aggregations