@Test public void testApply() { Model mo = new DefaultModel(); List<VM> vms = Util.newVMs(mo, 10); List<Node> ns = Util.newNodes(mo, 10); ReconfigurationPlan plan = makePlan(mo, ns, vms); Model res = new DependencyBasedPlanApplier().apply(plan); Mapping resMapping = res.getMapping(); Assert.assertTrue(resMapping.isOffline(ns.get(0))); Assert.assertTrue(resMapping.isOnline(ns.get(3))); ShareableResource rc = ShareableResource.get(res, "cpu"); Assert.assertEquals(rc.getConsumption(vms.get(2)), 7); Assert.assertEquals(resMapping.getVMLocation(vms.get(0)), ns.get(3)); Assert.assertEquals(resMapping.getVMLocation(vms.get(1)), ns.get(1)); Assert.assertEquals(resMapping.getVMLocation(vms.get(3)), ns.get(2)); }
@Override public Model apply(ReconfigurationPlan p) { Model res = p.getOrigin().copy(); List<Action> actions = new ArrayList<>(p.getActions()); actions.sort(startFirstComparator); for (Action a : actions) { if (!a.apply(res)) { return null; } fireAction(a); } return res; }
TimeBasedPlanApplier extends DefaultPlanApplier { @Override public Model apply(ReconfigurationPlan p) { Model res = p.getOrigin().copy(); List<Action> actions = new ArrayList<>(p.getActions()); actions.sort(startFirstComparator); for (Action a : actions) { if (!a.apply(res)) { return null; } fireAction(a); } return res; } }
TimeBasedPlanApplier extends DefaultPlanApplier { @Override public Model apply(ReconfigurationPlan p) { Model res = p.getOrigin().copy(); List<Action> actions = new ArrayList<>(p.getActions()); actions.sort(startFirstComparator); for (Action a : actions) { if (!a.apply(res)) { return null; } fireAction(a); } return res; }  }
TimeBasedPlanApplier extends DefaultPlanApplier { @Override public Model apply(ReconfigurationPlan p) { Model res = p.getOrigin().copy(); List<Action> actions = new ArrayList<>(p.getActions()); actions.sort(startFirstComparator); for (Action a : actions) { if (!a.apply(res)) { return null; } fireAction(a); } return res; }  @Override Model apply(ReconfigurationPlan p); @Override String toString(ReconfigurationPlan p); }
TimeBasedPlanApplier extends DefaultPlanApplier { @Override public Model apply(ReconfigurationPlan p) { Model res = p.getOrigin().copy(); List<Action> actions = new ArrayList<>(p.getActions()); actions.sort(startFirstComparator); for (Action a : actions) { if (!a.apply(res)) { return null; } fireAction(a); } return res; }  @Override Model apply(ReconfigurationPlan p); @Override String toString(ReconfigurationPlan p);  }