use of org.btrplace.model.Instance in project scheduler by btrplace.
the class IssuesTest method testIssue117.
@Test
public void testIssue117() throws Exception {
String buf = "{\"model\":{\"mapping\":{\"readyVMs\":[5,4],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[0]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[1]},\"2\":{\"sleepingVMs\":[],\"runningVMs\":[3,2]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{\"4\":{\"placeHolder\":true},\"5\":{\"placeHolder\":true}}},\"views\":[{\"defConsumption\":2,\"nodes\":{},\"rcId\":\"mem\",\"id\":\"shareableResource\",\"defCapacity\":6,\"vms\":{\"1\":4,\"4\":4,\"5\":2}},{\"defConsumption\":2,\"nodes\":{},\"rcId\":\"cpu\",\"id\":\"shareableResource\",\"defCapacity\":6,\"vms\":{\"0\":4,\"1\":4,\"4\":4,\"5\":2}}]},\"constraints\":[{\"vm\":4,\"continuous\":false,\"id\":\"running\"},{\"continuous\":false,\"id\":\"spread\",\"vms\":[1,3,4]},{\"vm\":5,\"continuous\":false,\"id\":\"running\"}],\"objective\":{\"id\":\"minimizeMTTR\"}}";
Instance i = JSON.readInstance(new StringReader(buf));
ChocoScheduler s = new DefaultChocoScheduler();
ReconfigurationPlan plan = s.solve(i);
Assert.assertNotNull(plan);
}
use of org.btrplace.model.Instance 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.model.Instance 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.model.Instance 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.model.Instance in project scheduler by btrplace.
the class CShareableResourceTest method testEmpty.
// Issue124
@Test
public void testEmpty() throws SchedulerException {
String buf = "{\"model\":{\"mapping\":{\"readyVMs\":[],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[1,0]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{}},\"views\":[{\"defConsumption\":0,\"nodes\":{},\"rcId\":\"CPU\",\"id\":\"shareableResource\",\"defCapacity\":0,\"vms\":{}}]},\"constraints\":[{\"continuous\":false,\"id\":\"spread\",\"vms\":[0,1]}],\"objective\":{\"id\":\"minimizeMTTR\"}}";
Instance i = JSON.readInstance(new StringReader(buf));
ChocoScheduler s = new DefaultChocoScheduler();
ReconfigurationPlan p = s.solve(i);
Assert.assertNotNull(p);
}
Aggregations