use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CMaxOnlineTest method complexContinuousTest2.
@Test
public void complexContinuousTest2() throws SchedulerException {
Model model = new DefaultModel();
Node n1 = model.newNode(1);
Node n2 = model.newNode(2);
Node n3 = model.newNode(3);
Node n4 = model.newNode(4);
Node n5 = model.newNode(5);
VM vm1 = model.newVM();
VM vm2 = model.newVM();
VM vm3 = model.newVM();
VM vm4 = model.newVM();
ShareableResource resources = new ShareableResource("cpu", 2, 1);
resources.setCapacity(n1, 4);
resources.setCapacity(n2, 8);
resources.setConsumption(vm4, 2);
Mapping map = model.getMapping().on(n1, n2, n3).off(n4, n5).run(n1, vm1, vm4).run(n2, vm2).run(n3, vm3);
MappingUtils.fill(map, model.getMapping());
model.attach(resources);
MaxOnline maxOn = new MaxOnline(map.getAllNodes(), 4, true);
MaxOnline maxOn2 = new MaxOnline(new HashSet<>(Arrays.asList(n2, n3, n4)), 2, true);
List<SatConstraint> constraints = new ArrayList<>();
constraints.add(maxOn);
constraints.add(maxOn2);
constraints.addAll(Online.newOnline(Arrays.asList(n4, n5)));
ChocoScheduler cra = new DefaultChocoScheduler();
cra.setTimeLimit(3);
cra.setMaxEnd(10);
cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
ReconfigurationPlan plan = cra.solve(model, constraints);
Assert.assertNotNull(plan);
Assert.assertTrue(maxOn.isSatisfied(plan));
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CNoDelayTest method testOk1.
@Test
public void testOk1() throws SchedulerException {
Model model = new DefaultModel();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
VM vm1 = model.newVM();
VM vm2 = model.newVM();
VM vm3 = model.newVM();
VM vm4 = model.newVM();
ShareableResource resources = new ShareableResource("cpu", 4, 1);
resources.setCapacity(n2, 3);
resources.setConsumption(vm1, 4);
Mapping map = model.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2).run(n3, vm3).run(n3, vm4);
MappingUtils.fill(map, model.getMapping());
model.attach(resources);
Ban b = new Ban(vm1, Collections.singleton(n1));
NoDelay nd = new NoDelay(vm3);
// 1 solution (priority to vm3): vm3 to n2 ; vm4 to n2 ; vm1 to n3
List<SatConstraint> constraints = new ArrayList<>();
constraints.add(nd);
constraints.add(b);
ChocoScheduler cra = new DefaultChocoScheduler();
cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
ReconfigurationPlan plan = cra.solve(model, constraints);
Assert.assertNotNull(plan);
Assert.assertTrue(nd.isSatisfied(plan));
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CNoDelayTest method testKo.
@Test
public void testKo() throws SchedulerException {
Model model = new DefaultModel();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
VM vm1 = model.newVM();
VM vm2 = model.newVM();
VM vm3 = model.newVM();
VM vm4 = model.newVM();
ShareableResource resources = new ShareableResource("cpu", 4, 1);
resources.setCapacity(n2, 3);
resources.setConsumption(vm1, 4);
Mapping map = model.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2).run(n3, vm3).run(n3, vm4);
MappingUtils.fill(map, model.getMapping());
model.attach(resources);
Ban b = new Ban(vm1, Collections.singleton(n1));
NoDelay nd = new NoDelay(vm1);
// No solution: unable to migrate vm1 at t=0
List<SatConstraint> constraints = new ArrayList<>();
constraints.add(nd);
constraints.add(b);
ChocoScheduler cra = new DefaultChocoScheduler();
cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
ReconfigurationPlan plan = cra.solve(model, constraints);
Assert.assertNull(plan);
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class COfflineTest method testSolvableProblem.
@Test
public void testSolvableProblem() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
mo.getMapping().on(n1, n2).run(n1, vm1);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan plan = cra.solve(mo, Collections.singleton(new Offline(n1)));
Assert.assertNotNull(plan);
Model res = plan.getResult();
Assert.assertTrue(res.getMapping().getOfflineNodes().contains(n1));
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class COnlineTest method testSolvableProblem.
@Test
public void testSolvableProblem() throws SchedulerException {
Model mo = new DefaultModel();
Node n1 = mo.newNode();
mo.getMapping().off(n1);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan plan = cra.solve(mo, Collections.singleton(new Online(n1)));
Assert.assertNotNull(plan);
Model res = plan.getResult();
Assert.assertTrue(res.getMapping().isOnline(n1));
}
Aggregations