@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, vm5); Set<VM> mine = new HashSet<>(Arrays.asList(vm1, vm2, vm3)); CLonely c = new CLonely(new Lonely(mine)); Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR()); Assert.assertTrue(c.getMisPlacedVMs(i).isEmpty()); map.addRunningVM(vm2, n2); Assert.assertEquals(c.getMisPlacedVMs(i), map.getRunningVMs(n2)); }
@Override public Set<VM> getMisPlacedVMs(Instance i) { Set<VM> bad = new HashSet<>(); Set<Node> hosts = new HashSet<>(); Collection<VM> vms = cstr.getInvolvedVMs(); Mapping map = i.getModel().getMapping(); for (VM vm : vms) { if (map.isRunning(vm)) { hosts.add(map.getVMLocation(vm)); } } for (Node n : hosts) { for (VM vm : map.getRunningVMs(n)) { if (!vms.contains(vm)) { bad.addAll(map.getRunningVMs(n)); break; } } } return bad; }
CLonely implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Set<VM> bad = new HashSet<>(); Set<Node> hosts = new HashSet<>(); Collection<VM> vms = cstr.getInvolvedVMs(); Mapping map = i.getModel().getMapping(); for (VM vm : vms) { if (map.isRunning(vm)) { hosts.add(map.getVMLocation(vm)); } } for (Node n : hosts) { for (VM vm : map.getRunningVMs(n)) { if (!vms.contains(vm)) { bad.addAll(map.getRunningVMs(n)); break; } } } return bad; } }
CLonely implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Set<VM> bad = new HashSet<>(); Set<Node> hosts = new HashSet<>(); Collection<VM> vms = cstr.getInvolvedVMs(); Mapping map = i.getModel().getMapping(); for (VM vm : vms) { if (map.isRunning(vm)) { hosts.add(map.getVMLocation(vm)); } } for (Node n : hosts) { for (VM vm : map.getRunningVMs(n)) { if (!vms.contains(vm)) { bad.addAll(map.getRunningVMs(n)); break; } } } return bad; } CLonely(Lonely c); }
CLonely implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Set<VM> bad = new HashSet<>(); Set<Node> hosts = new HashSet<>(); Collection<VM> vms = cstr.getInvolvedVMs(); Mapping map = i.getModel().getMapping(); for (VM vm : vms) { if (map.isRunning(vm)) { hosts.add(map.getVMLocation(vm)); } } for (Node n : hosts) { for (VM vm : map.getRunningVMs(n)) { if (!vms.contains(vm)) { bad.addAll(map.getRunningVMs(n)); break; } } } return bad; } CLonely(Lonely c); @Override boolean inject(Parameters ps, ReconfigurationProblem rp); @Override Set<VM> getMisPlacedVMs(Instance i); @Override String toString(); }
CLonely implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Set<VM> bad = new HashSet<>(); Set<Node> hosts = new HashSet<>(); Collection<VM> vms = cstr.getInvolvedVMs(); Mapping map = i.getModel().getMapping(); for (VM vm : vms) { if (map.isRunning(vm)) { hosts.add(map.getVMLocation(vm)); } } for (Node n : hosts) { for (VM vm : map.getRunningVMs(n)) { if (!vms.contains(vm)) { bad.addAll(map.getRunningVMs(n)); break; } } } return bad; } CLonely(Lonely c); @Override boolean inject(Parameters ps, ReconfigurationProblem rp); @Override Set<VM> getMisPlacedVMs(Instance i); @Override String toString();  }