use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class IssuesTest method testIssue176.
/**
* Boot plenty of VMs.
*/
@Test
public void testIssue176() {
Model mo = new DefaultModel();
ShareableResource slots = new ShareableResource("slots");
for (int i = 0; i < 4; i++) {
final Node no = mo.newNode();
mo.getMapping().on(no);
slots.setCapacity(no, 100);
for (int j = 0; j < 5; j++) {
mo.getMapping().addRunningVM(mo.newVM(), no);
}
}
// 95 VMs * nbNodes can be hosted.
for (int i = 0; i < 95 * mo.getMapping().getNbNodes(); i++) {
mo.getMapping().addReadyVM(mo.newVM());
}
final List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Running.newRunning(mo.getMapping().getReadyVMs()));
final Instance ii = new Instance(mo, cstrs, new MinMigrations());
ChocoScheduler sched = new DefaultChocoScheduler();
Assert.assertNotNull(sched.solve(ii));
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CMaxOnlineTest method testSimpleContinuousCase.
@Test
public void testSimpleContinuousCase() throws SchedulerException {
Model model = new DefaultModel();
Node n1 = model.newNode();
Node n2 = model.newNode();
model.getMapping().addOnlineNode(n1);
model.getMapping().addOfflineNode(n2);
MaxOnline maxOnline = new MaxOnline(model.getMapping().getAllNodes(), 1, true);
List<SatConstraint> constraints = new ArrayList<>();
constraints.add(maxOnline);
constraints.add(new Online(n2));
ChocoScheduler cra = new DefaultChocoScheduler();
// cra.setTimeLimit(5);
cra.setMaxEnd(4);
cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
ReconfigurationPlan plan = cra.solve(model, constraints);
Assert.assertNotNull(plan);
Assert.assertTrue(maxOnline.isSatisfied(plan));
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CMaxOnlineTest method testContinuousRestrictionSimpleCase.
@Test
public void testContinuousRestrictionSimpleCase() throws SchedulerException {
Model model = new DefaultModel();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
VM vm1 = model.newVM();
VM vm3 = model.newVM();
VM vm4 = model.newVM();
ShareableResource resources = new ShareableResource("cpu", 4, 1);
resources.setCapacity(n1, 8);
resources.setConsumption(vm4, 2);
Mapping map = model.getMapping().on(n1, n3).off(n2).run(n1, vm1, vm4).run(n3, vm3);
MappingUtils.fill(map, model.getMapping());
model.attach(resources);
MaxOnline maxon = new MaxOnline(map.getAllNodes(), 2, true);
List<SatConstraint> constraints = new ArrayList<>();
constraints.add(maxon);
constraints.add(new Online(n2));
ChocoScheduler cra = new DefaultChocoScheduler();
// cra.setTimeLimit(3);
cra.setMaxEnd(3);
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.model.constraint.SatConstraint in project scheduler by btrplace.
the class CMaxOnlineTest method discreteMaxOnlineTest2.
@Test
public void discreteMaxOnlineTest2() 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("vcpu", 1, 1);
resources.setCapacity(n1, 4);
resources.setCapacity(n2, 8);
resources.setCapacity(n3, 2);
resources.setConsumption(vm4, 2);
Mapping map = model.getMapping().on(n1, n2, n3).run(n1, vm1, vm4).run(n2, vm2).run(n3, vm3);
model.attach(resources);
MappingUtils.fill(map, model.getMapping());
Set<Node> nodes = map.getAllNodes();
MaxOnline maxon = new MaxOnline(nodes, 2);
Set<Node> nodes2 = new HashSet<>(Arrays.asList(n1, n2));
MaxOnline maxon2 = new MaxOnline(nodes2, 1);
List<SatConstraint> constraints = new ArrayList<>();
constraints.add(maxon);
constraints.add(maxon2);
ChocoScheduler cra = new DefaultChocoScheduler();
cra.setMaxEnd(4);
cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
ReconfigurationPlan plan = cra.solve(model, constraints);
Assert.assertNotNull(plan);
Assert.assertTrue(maxon.isSatisfied(plan.getResult()));
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class COverbookTest method testBasic.
@Test
public void testBasic() throws SchedulerException {
Node[] nodes = new Node[2];
VM[] vms = new VM[3];
Model mo = new DefaultModel();
Mapping m = mo.getMapping();
ShareableResource rcCPU = new ShareableResource("cpu");
for (int i = 0; i < vms.length; i++) {
if (i < nodes.length) {
nodes[i] = mo.newNode();
rcCPU.setCapacity(nodes[i], 2);
m.addOnlineNode(nodes[i]);
}
vms[i] = mo.newVM();
rcCPU.setConsumption(vms[i], 1);
m.addReadyVM(vms[i]);
}
mo.attach(rcCPU);
Overbook o = new Overbook(nodes[0], "cpu", 2);
Overbook o2 = new Overbook(nodes[1], "cpu", 2);
Collection<SatConstraint> c = new HashSet<>();
c.add(o);
c.add(o2);
c.addAll(Running.newRunning(m.getAllVMs()));
c.add(new Preserve(vms[0], "cpu", 1));
c.addAll(Online.newOnline(m.getAllNodes()));
DefaultChocoScheduler cra = new DefaultChocoScheduler();
cra.getMapper().mapConstraint(Overbook.class, COverbook.class);
ReconfigurationPlan p = cra.solve(mo, c);
Assert.assertNotNull(p);
}
Aggregations