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;
}
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;
}
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);
}
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);
}
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));
}
Aggregations