Search in sources :

Example 6 with Instance

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);
}
Also used : Instance(org.btrplace.model.Instance) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) StringReader(java.io.StringReader) Test(org.testng.annotations.Test)

Example 7 with Instance

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());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Spread(org.btrplace.model.constraint.Spread) RunningCapacity(org.btrplace.model.constraint.RunningCapacity) Instance(org.btrplace.model.Instance) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) Test(org.testng.annotations.Test)

Example 8 with Instance

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);
}
Also used : Instance(org.btrplace.model.Instance) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) StringReader(java.io.StringReader) Test(org.testng.annotations.Test)

Example 9 with Instance

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());
}
Also used : Instance(org.btrplace.model.Instance) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) StringReader(java.io.StringReader) Test(org.testng.annotations.Test)

Example 10 with Instance

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);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Instance(org.btrplace.model.Instance) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) StringReader(java.io.StringReader) Test(org.testng.annotations.Test)

Aggregations

Instance (org.btrplace.model.Instance)34 Test (org.testng.annotations.Test)24 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)20 Model (org.btrplace.model.Model)19 ArrayList (java.util.ArrayList)17 DefaultModel (org.btrplace.model.DefaultModel)14 MinMTTR (org.btrplace.model.constraint.MinMTTR)13 TIntIntHashMap (gnu.trove.map.hash.TIntIntHashMap)12 Node (org.btrplace.model.Node)12 VM (org.btrplace.model.VM)12 StringReader (java.io.StringReader)10 HashSet (java.util.HashSet)10 SatConstraint (org.btrplace.model.constraint.SatConstraint)8 List (java.util.List)5 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)5 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)4 File (java.io.File)3 MinMigrations (org.btrplace.model.constraint.MinMigrations)3 Spread (org.btrplace.model.constraint.Spread)3 MigrateVM (org.btrplace.plan.event.MigrateVM)3