use of org.btrplace.model.view.ShareableResource 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.model.view.ShareableResource 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.model.view.ShareableResource in project scheduler by btrplace.
the class COverbookTest method testWithScheduling1.
@Test
public void testWithScheduling1() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm3 = mo.newVM();
Node n1 = mo.newNode();
Mapping m = mo.getMapping().on(n1).run(n1, vm1).ready(vm3);
ShareableResource rcCPU = new ShareableResource("cpu", 2, 2);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.add(new Running(vm3));
cstrs.add(new Sleeping(vm1));
cstrs.addAll(Online.newOnline(m.getAllNodes()));
cstrs.add(new Overbook(n1, "cpu", 1));
cstrs.add(new Preserve(vm1, "cpu", 2));
cstrs.add(new Preserve(vm3, "cpu", 2));
mo.attach(rcCPU);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
}
use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.
the class CPreserveTest method testPreserveWithoutOverbook.
/*@Test
public void testGetMisplaced() {
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).get();
ShareableResource rc = new ShareableResource("cpu", 7, 7);
rc.setConsumption(vm1, 3);
rc.setConsumption(vm2, 3);
rc.setConsumption(vm3, 5);
Preserve p = new Preserve(vm1, "cpu", 5);
mo.attach(rc);
//Assert.assertEquals(SatConstraint.Sat.UNSATISFIED, p.isSatisfied(mo));
CPreserve cp = new CPreserve(p);
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
Set<VM> bads = cp.getMisPlacedVMs(i);
Assert.assertEquals(1, bads.size());
Assert.assertEquals(vm1, bads.iterator().next());
}*/
/**
* 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.view.ShareableResource 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));
org.btrplace.model.view.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);
}
Aggregations