use of org.btrplace.plan.event.BootNode in project scheduler by btrplace.
the class ReconfigurationPlanCheckerTest method testSequencing.
@Test(dependsOnMethods = { "tesAddandRemove" })
public void testSequencing() throws SatConstraintViolationException {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 10);
List<VM> vms = Util.newVMs(mo, 10);
Mapping m = mo.getMapping();
m.addOnlineNode(ns.get(0));
m.addOnlineNode(ns.get(1));
m.addOfflineNode(ns.get(3));
m.addReadyVM(vms.get(1));
m.addRunningVM(vms.get(0), ns.get(0));
ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
SatConstraintChecker<?> chk = mock(SatConstraintChecker.class);
MigrateVM m1 = new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 3);
BootVM b1 = new BootVM(vms.get(1), ns.get(0), 1, 5);
BootNode bn = new BootNode(ns.get(3), 3, 6);
p.add(m1);
p.add(b1);
p.add(bn);
Model res = p.getResult();
Assert.assertNotNull(res);
ReconfigurationPlanChecker rc = new ReconfigurationPlanChecker();
rc.addChecker(chk);
InOrder order = inOrder(chk);
rc.check(p);
order.verify(chk).startsWith(mo);
order.verify(chk).start(m1);
order.verify(chk).start(b1);
order.verify(chk).end(m1);
order.verify(chk).start(bn);
order.verify(chk).end(b1);
order.verify(chk).end(bn);
order.verify(chk).endsWith(res);
}
use of org.btrplace.plan.event.BootNode in project scheduler by btrplace.
the class TimeBasedPlanApplierTest method makePlan.
private static ReconfigurationPlan makePlan(Model mo, List<Node> ns, List<VM> vms) {
Mapping map = mo.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addOnlineNode(ns.get(2));
map.addOfflineNode(ns.get(3));
map.addRunningVM(vms.get(0), ns.get(2));
map.addRunningVM(vms.get(1), ns.get(0));
map.addRunningVM(vms.get(2), ns.get(1));
map.addRunningVM(vms.get(3), ns.get(1));
BootNode bN4 = new BootNode(ns.get(3), 3, 5);
MigrateVM mVM1 = new MigrateVM(vms.get(0), ns.get(2), ns.get(3), 6, 7);
Allocate aVM3 = new Allocate(vms.get(2), ns.get(1), "cpu", 7, 8, 9);
MigrateVM mVM2 = new MigrateVM(vms.get(1), ns.get(0), ns.get(1), 1, 3);
MigrateVM mVM4 = new MigrateVM(vms.get(3), ns.get(1), ns.get(2), 1, 7);
ShutdownNode sN1 = new ShutdownNode(ns.get(0), 5, 7);
ShareableResource rc = new ShareableResource("cpu");
rc.setConsumption(vms.get(2), 3);
mo.attach(rc);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
plan.add(bN4);
plan.add(mVM1);
plan.add(aVM3);
plan.add(mVM2);
plan.add(mVM4);
plan.add(sN1);
return plan;
}
use of org.btrplace.plan.event.BootNode in project scheduler by btrplace.
the class ReconfigurationPlanFuzzer method addNode.
private boolean addNode(Node n, ReconfigurationPlan p) {
double src = rnd.nextDouble();
double dst = rnd.nextDouble();
int[] bounds = schedule();
if (src < srcOffNodes) {
p.getOrigin().getMapping().addOfflineNode(n);
if (dst > dstOffNodes) {
p.add(new BootNode(n, bounds[0], bounds[1]));
p.getOrigin().getAttributes().put(n, "boot", bounds[1] - bounds[0]);
return true;
}
} else {
p.getOrigin().getMapping().addOnlineNode(n);
if (dst < srcOffNodes) {
p.add(new ShutdownNode(n, bounds[0], bounds[1]));
p.getOrigin().getAttributes().put(n, "shutdown", bounds[1] - bounds[0]);
}
}
return false;
}
Aggregations