Search in sources :

Example 6 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class StaticPartitioning method merge.

private ReconfigurationPlan merge(Instance i, Collection<SolvingStatistics> results) throws SplitException {
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(i.getModel());
    // Only if there is a solution
    for (SolvingStatistics result : results) {
        getStatistics().addPartitionStatistics(result);
        ReconfigurationPlan p = result.lastSolution();
        if (p == null) {
            return null;
        }
        for (Action a : p) {
            if (!plan.add(a)) {
                throw new SplitException(plan.getOrigin(), "Unable to add action '" + a + "' while merging the sub-plans");
            }
        }
    }
    return plan;
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) Action(org.btrplace.plan.event.Action) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) SolvingStatistics(org.btrplace.scheduler.choco.runner.SolvingStatistics)

Example 7 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class ReconfigurationPlanConverter method fromJSON.

@Override
public ReconfigurationPlan fromJSON(JSONObject ob) throws JSONConverterException {
    checkKeys(ob, ORIGIN_LABEL, ACTIONS_LABEL);
    Model m = mc.fromJSON((JSONObject) ob.get(ORIGIN_LABEL));
    ActionConverter ac = new ActionConverter(m);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(m);
    for (Action a : ac.listFromJSON((JSONArray) ob.get(ACTIONS_LABEL))) {
        plan.add(a);
    }
    return plan;
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) Action(org.btrplace.plan.event.Action) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model)

Example 8 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class ReconfigurationPlanConverterTest method testConversion.

@Test
public void testConversion() throws JSONConverterException {
    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();
    map.addOnlineNode(n1);
    map.addOfflineNode(n2);
    map.addOnlineNode(n3);
    map.addReadyVM(vm1);
    map.addRunningVM(vm2, n1);
    map.addRunningVM(vm3, n1);
    map.addSleepingVM(vm4, n3);
    map.addRunningVM(vm5, n3);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    plan.add(new MigrateVM(vm2, n1, n3, 0, 1));
    plan.add(new BootVM(vm1, n3, 1, 2));
    plan.add(new BootNode(n2, 2, 5));
    plan.add(new Allocate(vm1, n3, "foo", 5, 3, 5));
    ReconfigurationPlanConverter rcp = new ReconfigurationPlanConverter();
    String j = rcp.toJSONString(plan);
    ReconfigurationPlan p2 = rcp.fromJSON(j);
    Assert.assertEquals(p2, plan);
}
Also used : BootNode(org.btrplace.plan.event.BootNode) BootNode(org.btrplace.plan.event.BootNode) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) BootVM(org.btrplace.plan.event.BootVM) BootVM(org.btrplace.plan.event.BootVM) Allocate(org.btrplace.plan.event.Allocate) Test(org.testng.annotations.Test)

Example 9 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class GatherTest method testContinuousIsSatisfied.

@Test(dependsOnMethods = { "testDiscreteIsSatisfied" })
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 10);
    List<VM> vms = Util.newVMs(mo, 10);
    Set<VM> s = new HashSet<>(Arrays.asList(vms.get(0), vms.get(1)));
    Gather g = new Gather(s);
    g.setContinuous(true);
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addRunningVM(vms.get(0), ns.get(0));
    map.addReadyVM(vms.get(1));
    map.addRunningVM(vms.get(1), ns.get(1));
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(g.isSatisfied(plan), false);
    map.addReadyVM(vms.get(1));
    Assert.assertEquals(g.isSatisfied(plan), true);
    plan.add(new BootVM(vms.get(1), ns.get(0), 0, 1));
    Assert.assertEquals(g.isSatisfied(plan), true);
    map.addRunningVM(vms.get(1), ns.get(0));
    plan = new DefaultReconfigurationPlan(mo);
    plan.add(new MigrateVM(vms.get(1), ns.get(0), ns.get(1), 0, 1));
    plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 1));
    Assert.assertEquals(g.isSatisfied(plan), false);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) BootVM(org.btrplace.plan.event.BootVM) BootVM(org.btrplace.plan.event.BootVM) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 10 with DefaultReconfigurationPlan

use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.

the class MaxOnlineTest method isSatisfiedReconfigurationPlan.

@Test
public void isSatisfiedReconfigurationPlan() {
    Model model = new DefaultModel();
    Mapping map = model.getMapping();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    Node n3 = model.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addOfflineNode(n3);
    Set<Node> s = new HashSet<>(Arrays.asList(n1, n2, n3));
    MaxOnline mo = new MaxOnline(s, 2);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(model);
    Assert.assertTrue(mo.isSatisfied(plan));
    plan.add(new BootNode(n3, 3, 9));
    Assert.assertFalse(mo.isSatisfied(plan));
    plan.add(new ShutdownNode(n2, 0, 5));
    Assert.assertTrue(mo.isSatisfied(plan));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) BootNode(org.btrplace.plan.event.BootNode) Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)24 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)24 Test (org.testng.annotations.Test)21 MigrateVM (org.btrplace.plan.event.MigrateVM)12 ShutdownVM (org.btrplace.plan.event.ShutdownVM)6 HashSet (java.util.HashSet)4 DefaultModel (org.btrplace.model.DefaultModel)4 Model (org.btrplace.model.Model)4 BootVM (org.btrplace.plan.event.BootVM)4 ShareableResource (org.btrplace.model.view.ShareableResource)3 Allocate (org.btrplace.plan.event.Allocate)3 BootNode (org.btrplace.plan.event.BootNode)3 ShutdownNode (org.btrplace.plan.event.ShutdownNode)3 Node (org.btrplace.model.Node)2 Action (org.btrplace.plan.event.Action)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Instance (org.btrplace.model.Instance)1 Mapping (org.btrplace.model.Mapping)1 MinMTTR (org.btrplace.model.constraint.MinMTTR)1