use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CPreserveTest method testPreserveWithoutOverbook.
/**
* A preserve constraint asks for a minimum amount of resources but
* their is no overbook ratio so, the default value of 1 is used
* and vm1 or vm2 is moved to n2
*
* @throws org.btrplace.scheduler.SchedulerException
*/
@Test
public void testPreserveWithoutOverbook() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2).run(n1, vm1, vm2).run(n2, vm3);
ShareableResource rc = new ShareableResource("cpu", 10, 10);
rc.setCapacity(n1, 7);
rc.setConsumption(vm1, 3);
rc.setConsumption(vm2, 3);
rc.setConsumption(vm3, 5);
Preserve pr = new Preserve(vm2, "cpu", 5);
ChocoScheduler cra = new DefaultChocoScheduler();
mo.attach(rc);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Online.newOnline(map.getAllNodes()));
cstrs.add(pr);
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CResourceCapacityTest method testSingleContinuousSolvable.
@Test
public void testSingleContinuousSolvable() 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).run(n1, vm1, vm2).ready(vm4);
ShareableResource rc = new ShareableResource("cpu", 5, 5);
rc.setConsumption(vm1, 3);
rc.setConsumption(vm2, 1);
rc.setConsumption(vm3, 1);
rc.setConsumption(vm4, 3);
mo.attach(rc);
List<SatConstraint> cstrs = new ArrayList<>();
ResourceCapacity s = new ResourceCapacity(n1, "cpu", 4);
s.setContinuous(true);
cstrs.add(s);
cstrs.add(new Fence(vm4, Collections.singleton(n1)));
cstrs.add(new Running(vm4));
cstrs.addAll(Overbook.newOverbooks(map.getAllNodes(), "cpu", 1));
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
Assert.assertEquals(p.getSize(), 2);
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CResourceCapacityTest 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);
ShareableResource rc = new ShareableResource("cpu", 5, 5);
rc.setConsumption(vm1, 2);
rc.setConsumption(vm2, 3);
rc.setConsumption(vm3, 3);
rc.setConsumption(vm4, 1);
rc.setConsumption(vm5, 5);
mo.attach(rc);
List<SatConstraint> l = new ArrayList<>();
ResourceCapacity x = new ResourceCapacity(map.getAllNodes(), "cpu", 10);
x.setContinuous(false);
l.add(x);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan plan = cra.solve(mo, l);
Assert.assertNotNull(plan);
Assert.assertEquals(plan.getSize(), 0);
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CResourceCapacityTest method testFeasibleContinuousResolution.
@Test
public void testFeasibleContinuousResolution() 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();
mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm2).run(n2, vm3, vm4).ready(vm5);
Set<Node> on = new HashSet<>(Arrays.asList(n1, n2));
ShareableResource rc = new ShareableResource("cpu", 5, 5);
rc.setConsumption(vm1, 2);
rc.setConsumption(vm2, 3);
rc.setConsumption(vm3, 3);
rc.setConsumption(vm4, 1);
rc.setConsumption(vm5, 5);
mo.attach(rc);
List<SatConstraint> l = new ArrayList<>();
l.add(new Running(vm5));
l.add(new Fence(vm5, Collections.singleton(n1)));
ResourceCapacity x = new ResourceCapacity(on, "cpu", 10);
x.setContinuous(true);
l.add(x);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan plan = cra.solve(mo, l);
Assert.assertNotNull(plan);
// System.out.println(plan);
Assert.assertTrue(plan.getSize() > 0);
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CAmongTest method testContinuousWithAlreadySatisfied.
@Test
public void testContinuousWithAlreadySatisfied() 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();
Node n4 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2, n3, n4).run(n1, vm1).run(n2, vm2, vm3).ready(vm4, vm5);
Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2, vm5));
Collection<Node> s1 = new HashSet<>(Arrays.asList(n1, n2));
Collection<Node> s2 = new HashSet<>(Arrays.asList(n3, n4));
Collection<Collection<Node>> pGrps = new HashSet<>(Arrays.asList(s1, s2));
Among a = new Among(vms, pGrps);
a.setContinuous(true);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Running.newRunning(map.getAllVMs()));
cstrs.add(a);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
}
Aggregations