@Test public void testGetMisplaced() { 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().on(n1, n2, n3) .run(n1, vm1, vm2, vm3) .run(n2, vm4).ready(vm5); RunningCapacity c = new RunningCapacity(map.getAllNodes(), 4); CRunningCapacity cc = new CRunningCapacity(c); Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR()); Assert.assertTrue(cc.getMisPlacedVMs(i).isEmpty()); map.addRunningVM(vm5, n3); Assert.assertEquals(cc.getMisPlacedVMs(i), map.getAllVMs()); }
@Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); Set<VM> bad = new HashSet<>(); int remainder = cstr.getAmount(); for (Node n : cstr.getInvolvedNodes()) { remainder -= map.getRunningVMs(n).size(); if (remainder < 0) { for (Node n2 : cstr.getInvolvedNodes()) { bad.addAll(map.getRunningVMs(n2)); } return bad; } } return bad; }
CRunningCapacity implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); Set<VM> bad = new HashSet<>(); int remainder = cstr.getAmount(); for (Node n : cstr.getInvolvedNodes()) { remainder -= map.getRunningVMs(n).size(); if (remainder < 0) { for (Node n2 : cstr.getInvolvedNodes()) { bad.addAll(map.getRunningVMs(n2)); } return bad; } } return bad; } }
CRunningCapacity implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); Set<VM> bad = new HashSet<>(); int remainder = cstr.getAmount(); for (Node n : cstr.getInvolvedNodes()) { remainder -= map.getRunningVMs(n).size(); if (remainder < 0) { for (Node n2 : cstr.getInvolvedNodes()) { bad.addAll(map.getRunningVMs(n2)); } return bad; } } return bad; } CRunningCapacity(RunningCapacity c); }
CRunningCapacity implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); Set<VM> bad = new HashSet<>(); int remainder = cstr.getAmount(); for (Node n : cstr.getInvolvedNodes()) { remainder -= map.getRunningVMs(n).size(); if (remainder < 0) { for (Node n2 : cstr.getInvolvedNodes()) { bad.addAll(map.getRunningVMs(n2)); } return bad; } } return bad; } CRunningCapacity(RunningCapacity c); @Override boolean inject(Parameters ps, ReconfigurationProblem rp); @Override Set<VM> getMisPlacedVMs(Instance i); @Override String toString(); }
CRunningCapacity implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); Set<VM> bad = new HashSet<>(); int remainder = cstr.getAmount(); for (Node n : cstr.getInvolvedNodes()) { remainder -= map.getRunningVMs(n).size(); if (remainder < 0) { for (Node n2 : cstr.getInvolvedNodes()) { bad.addAll(map.getRunningVMs(n2)); } return bad; } } return bad; } CRunningCapacity(RunningCapacity c); @Override boolean inject(Parameters ps, ReconfigurationProblem rp); @Override Set<VM> getMisPlacedVMs(Instance i); @Override String toString();  }