use of org.btrplace.scheduler.choco.ChocoScheduler 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);
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CSplitTest method testContinuous.
// @Test
@Test(enabled = false)
public void testContinuous() 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, vm2).run(n3, vm3, vm4, vm5).run(n5, vm6, 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);
s.setContinuous(true);
ChocoScheduler cra = new DefaultChocoScheduler();
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.add(s);
// go away before the other arrive.
for (VM v : map.getRunningVMs(n1)) {
cstrs.add(new Fence(v, Collections.singleton(n3)));
}
// cra.setTimeLimit(2);
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
Assert.assertTrue(p.getSize() > 0);
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CSpreadTest method testSeparateWithContinuous.
/**
* 2 VMs are already hosted on a same node, check
* if separation is working in continuous mode
*/
@Test
public void testSeparateWithContinuous() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
mo.getMapping().on(n1, n2).run(n1, vm1, vm2);
List<SatConstraint> cstr = new ArrayList<>();
ChocoScheduler cra = new DefaultChocoScheduler();
Spread s = new Spread(mo.getMapping().getAllVMs());
s.setContinuous(true);
cstr.add(s);
cstr.addAll(Online.newOnline(mo.getMapping().getAllNodes()));
cstr.add(new Fence(vm1, Collections.singleton(n2)));
ReconfigurationPlan p = cra.solve(mo, cstr);
Assert.assertNull(p);
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CSpreadTest method testContinuous.
@Test
public void testContinuous() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = 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);
List<SatConstraint> cstr = new ArrayList<>();
ChocoScheduler cra = new DefaultChocoScheduler();
cstr.add(new Spread(mo.getMapping().getAllVMs(), true));
cstr.addAll(Online.newOnline(mo.getMapping().getAllNodes()));
cstr.add(new Fence(vm1, Collections.singleton(n2)));
ReconfigurationPlan p = cra.solve(mo, cstr);
Assert.assertNotNull(p);
System.err.println(p);
Mapping res = p.getResult().getMapping();
Assert.assertEquals(2, p.getSize());
Assert.assertNotSame(res.getVMLocation(vm1), res.getVMLocation(vm2));
}
use of org.btrplace.scheduler.choco.ChocoScheduler in project scheduler by btrplace.
the class CMinMigrationsTest method testNtnx.
@Test
public void testNtnx() {
String root = "src/test/resources/min-migrations.json";
Instance i = JSON.readInstance(new File(root));
i = new Instance(i.getModel(), i.getSatConstraints(), new MinMigrations());
ChocoScheduler s = new DefaultChocoScheduler();
s.doOptimize(true);
ReconfigurationPlan p = s.solve(i);
Assert.assertNotNull(p);
System.out.println(s.getStatistics());
System.out.println(p);
Assert.assertEquals(p.getActions().stream().filter(x -> x instanceof MigrateVM).count(), 1);
Assert.assertEquals(3, p.getDuration());
}
Aggregations