@Test public void testApply() { AllocateEvent na = new AllocateEvent(vms.get(0), "foo", 3); Model mo = new DefaultModel(); Mapping map = mo.getMapping(); map.addOnlineNode(ns.get(0)); map.addRunningVM(vms.get(0), ns.get(0)); Assert.assertFalse(na.apply(mo)); ShareableResource rc = new ShareableResource("foo"); mo.attach(rc); Assert.assertTrue(na.apply(mo)); Assert.assertEquals(3, rc.getConsumption(vms.get(0))); }
@Override public boolean apply(Model i) { ShareableResource r = ShareableResource.get(i, rc); if (r == null) { return false; } r.setConsumption(vm, qty); return true; }
AllocateEvent implements VMEvent { @Override public boolean apply(Model i) { ShareableResource r = ShareableResource.get(i, rc); if (r == null) { return false; } r.setConsumption(vm, qty); return true; } }
AllocateEvent implements VMEvent { @Override public boolean apply(Model i) { ShareableResource r = ShareableResource.get(i, rc); if (r == null) { return false; } r.setConsumption(vm, qty); return true; } AllocateEvent(VM vmId, String rcId, int amount); }
AllocateEvent implements VMEvent { @Override public boolean apply(Model i) { ShareableResource r = ShareableResource.get(i, rc); if (r == null) { return false; } r.setConsumption(vm, qty); return true; } AllocateEvent(VM vmId, String rcId, int amount); @Override VM getVM(); String getResourceId(); int getAmount(); @Override boolean apply(Model i); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override Object visit(ActionVisitor v); }
AllocateEvent implements VMEvent { @Override public boolean apply(Model i) { ShareableResource r = ShareableResource.get(i, rc); if (r == null) { return false; } r.setConsumption(vm, qty); return true; } AllocateEvent(VM vmId, String rcId, int amount); @Override VM getVM(); String getResourceId(); int getAmount(); @Override boolean apply(Model i); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override Object visit(ActionVisitor v);  }