@Test public void testSingleGetMisplaced() { Model mo = new DefaultModel(); VM vm1 = mo.newVM(); VM vm2 = mo.newVM(); VM vm4 = mo.newVM(); Node n1 = mo.newNode(); Mapping m = mo.getMapping().on(n1).run(n1, vm1).ready(vm2, vm4); RunningCapacity c = new RunningCapacity(Collections.singleton(n1), 1); CRunningCapacity cc = new CRunningCapacity(c); Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR()); Assert.assertTrue(cc.getMisPlacedVMs(i).isEmpty()); m.addRunningVM(vm4, n1); Assert.assertEquals(m.getRunningVMs(n1), cc.getMisPlacedVMs(i)); }
@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();  }