use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class IssuesTest method testIssue86.
@Test
public void testIssue86() throws Exception {
Model mo = new DefaultModel();
mo.getMapping().addReadyVM(mo.newVM());
mo.getMapping().addReadyVM(mo.newVM());
mo.getMapping().addReadyVM(mo.newVM());
mo.getMapping().addOnlineNode(mo.newNode());
mo.getMapping().addOnlineNode(mo.newNode());
mo.getMapping().addOnlineNode(mo.newNode());
List<SatConstraint> cstrs = mo.getMapping().getAllVMs().stream().map(Running::new).collect(Collectors.toList());
cstrs.add(new Spread(mo.getMapping().getAllVMs(), false));
cstrs.addAll(mo.getMapping().getOnlineNodes().stream().map(n -> new RunningCapacity(n, 1)).collect(Collectors.toList()));
Instance i = new Instance(mo, cstrs, new MinMTTR());
ChocoScheduler s = new DefaultChocoScheduler();
s.doOptimize(false);
s.doRepair(false);
ReconfigurationPlan p = s.solve(i.getModel(), i.getSatConstraints(), i.getOptConstraint());
Assert.assertNotNull(p);
Assert.assertEquals(3, p.getActions().size());
s.doRepair(true);
p = s.solve(i.getModel(), i.getSatConstraints(), i.getOptConstraint());
Assert.assertNotNull(p);
Assert.assertEquals(3, p.getActions().size());
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class IssuesTest method testFoo.
@Test
public void testFoo() throws Exception {
String buf = "{\"model\":{\"mapping\":{\"readyVMs\":[],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[0]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[1]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{}},\"views\":[{\"defConsumption\":2,\"nodes\":{},\"rcId\":\"CPU\",\"id\":\"shareableResource\",\"defCapacity\":7,\"vms\":{}}]},\"constraints\":[{\"nodes\":[0],\"vm\":0,\"continuous\":false,\"id\":\"ban\"},{\"nodes\":[1],\"vm\":1,\"continuous\":false,\"id\":\"ban\"},{\"rc\":\"CPU\",\"amount\":4,\"vm\":0,\"id\":\"preserve\"},{\"rc\":\"CPU\",\"amount\":4,\"vm\":1,\"id\":\"preserve\"}],\"objective\":{\"id\":\"minimizeMTTR\"}}";
Instance i = JSON.readInstance(new StringReader(buf));
ChocoScheduler s = new DefaultChocoScheduler();
ReconfigurationPlan p = s.solve(i);
Assert.assertNotNull(p);
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class IssuesTest method test16b.
/**
* Unit test derived from Issue 16.
*
* @throws org.btrplace.scheduler.SchedulerException
*/
@Test
public void test16b() throws SchedulerException {
Model model = new DefaultModel();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
Node n4 = model.newNode();
VM vm1 = model.newVM();
VM vm2 = model.newVM();
VM vm3 = model.newVM();
VM vm4 = model.newVM();
VM vm5 = model.newVM();
VM vm6 = model.newVM();
model.getMapping().on(n1, n2, n3, n4).run(n1, vm1, vm2).run(n2, vm3, vm4).run(n3, vm5, vm6);
Set<SatConstraint> ctrsC = new HashSet<>();
Set<VM> vms1 = new HashSet<>(Arrays.asList(vm1, vm3, vm5));
Set<VM> vms2 = new HashSet<>(Arrays.asList(vm2, vm4, vm6));
ctrsC.add(new Spread(vms1));
ctrsC.add(new Spread(vms2));
ctrsC.add(new Fence(vm3, Collections.singleton(n1)));
Offline off = new Offline(n2);
ctrsC.add(off);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan dp = cra.solve(model, ctrsC);
Assert.assertNotNull(dp);
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class IssuesTest method issue72c.
@Test
public void issue72c() throws Exception {
String buf = "{\"model\":{\"mapping\":{\"readyVMs\":[],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[9,8,7,6,5,4,3,2,1,0]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[19,18,17,16,15,14,13,12,11,10]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{}},\"views\":[{\"defConsumption\":0,\"nodes\":{\"0\":32768,\"1\":32768},\"rcId\":\"mem\",\"id\":\"shareableResource\",\"defCapacity\":8192,\"vms\":{\"11\":1024,\"12\":1024,\"13\":1024,\"14\":1024,\"15\":1024,\"16\":1024,\"17\":1024,\"18\":1024,\"19\":1024,\"0\":1024,\"1\":1024,\"2\":1024,\"3\":1024,\"4\":1024,\"5\":1024,\"6\":1024,\"7\":1024,\"8\":1024,\"9\":1024,\"10\":1024}},{\"defConsumption\":0,\"nodes\":{\"0\":700,\"1\":700},\"rcId\":\"cpu\",\"id\":\"shareableResource\",\"defCapacity\":8000,\"vms\":{\"11\":0,\"12\":0,\"13\":0,\"14\":0,\"15\":0,\"16\":50,\"17\":0,\"18\":0,\"19\":0,\"0\":0,\"1\":0,\"2\":0,\"3\":40,\"4\":0,\"5\":90,\"6\":0,\"7\":0,\"8\":0,\"9\":0,\"10\":0}}]},\"constraints\":[],\"objective\":{\"id\":\"minimizeMTTR\"}}";
Instance i = JSON.readInstance(new StringReader(buf));
ChocoScheduler s = new DefaultChocoScheduler();
s.doOptimize(false);
ReconfigurationPlan p = s.solve(i);
Assert.assertNotNull(p);
Assert.assertTrue(p.getActions().isEmpty());
s.doRepair(true);
p = s.solve(i.getModel(), i.getSatConstraints(), i.getOptConstraint());
Assert.assertTrue(p.getActions().isEmpty());
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class BootVMTest method testBootSequence.
/**
* Test that check when the action is shorter than the end of
* the reconfiguration process.
* In practice, 2 boot actions have to be executed sequentially
*/
@Test
public void testBootSequence() throws SchedulerException, ContradictionException {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
final VM vm1 = mo.newVM();
final VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
map.addOnlineNode(n1);
map.addOnlineNode(n2);
map.addReadyVM(vm1);
map.addReadyVM(vm2);
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(org.btrplace.plan.event.BootVM.class, new ConstantActionDuration<>(5));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(new HashSet<>(), map.getAllVMs(), new HashSet<>(), new HashSet<>()).build();
BootVM m1 = (BootVM) rp.getVMActions().get(rp.getVM(vm1));
BootVM m2 = (BootVM) rp.getVMActions().get(rp.getVM(vm2));
rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
rp.getNodeActions().get(1).getState().instantiateTo(1, Cause.Null);
rp.getModel().post(rp.getModel().arithm(m2.getStart(), ">=", m1.getEnd()));
new CMinMTTR().inject(ps, rp);
ReconfigurationPlan p = rp.solve(0, false);
Assert.assertNotNull(p);
Iterator<Action> ite = p.iterator();
org.btrplace.plan.event.BootVM b1 = (org.btrplace.plan.event.BootVM) ite.next();
org.btrplace.plan.event.BootVM b2 = (org.btrplace.plan.event.BootVM) ite.next();
Assert.assertEquals(vm1, b1.getVM());
Assert.assertEquals(vm2, b2.getVM());
Assert.assertTrue(b1.getEnd() <= b2.getStart());
Assert.assertEquals(5, b1.getEnd() - b1.getStart());
Assert.assertEquals(5, b2.getEnd() - b2.getStart());
}
Aggregations