@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(); Node n4 = mo.newNode(); Node n5 = mo.newNode(); mo.getMapping().on(n1, n2, n3, n4) .off(n5) .run(n1, vm1, vm2) .run(n2, vm3) .run(n3, vm4) .sleep(n4, vm5); Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2)); Set<Node> ns = new HashSet<>(Arrays.asList(n1, n2)); CFence c = new CFence(new Fence(vm1, ns)); Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR()); Assert.assertTrue(c.getMisPlacedVMs(i).isEmpty()); ns.add(mo.newNode()); Assert.assertTrue(c.getMisPlacedVMs(i).isEmpty()); vms.add(vm3); Assert.assertTrue(c.getMisPlacedVMs(i).isEmpty()); vms.add(vm4); Set<VM> bad = new CFence(new Fence(vm4, ns)).getMisPlacedVMs(i); Assert.assertEquals(1, bad.size()); Assert.assertTrue(bad.contains(vm4)); }
@Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); VM vm = cstr.getInvolvedVMs().iterator().next(); if (map.isRunning(vm) && !cstr.getInvolvedNodes().contains(map.getVMLocation(vm))) { return Collections.singleton(vm); } return Collections.emptySet(); }
CFence implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); VM vm = cstr.getInvolvedVMs().iterator().next(); if (map.isRunning(vm) && !cstr.getInvolvedNodes().contains(map.getVMLocation(vm))) { return Collections.singleton(vm); } return Collections.emptySet(); } }
CFence implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); VM vm = cstr.getInvolvedVMs().iterator().next(); if (map.isRunning(vm) && !cstr.getInvolvedNodes().contains(map.getVMLocation(vm))) { return Collections.singleton(vm); } return Collections.emptySet(); } CFence(Fence c); }
CFence implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); VM vm = cstr.getInvolvedVMs().iterator().next(); if (map.isRunning(vm) && !cstr.getInvolvedNodes().contains(map.getVMLocation(vm))) { return Collections.singleton(vm); } return Collections.emptySet(); } CFence(Fence c); @Override boolean inject(Parameters ps, ReconfigurationProblem rp); @Override Set<VM> getMisPlacedVMs(Instance i); @Override String toString(); }
CFence implements ChocoConstraint { @Override public Set<VM> getMisPlacedVMs(Instance i) { Mapping map = i.getModel().getMapping(); VM vm = cstr.getInvolvedVMs().iterator().next(); if (map.isRunning(vm) && !cstr.getInvolvedNodes().contains(map.getVMLocation(vm))) { return Collections.singleton(vm); } return Collections.emptySet(); } CFence(Fence c); @Override boolean inject(Parameters ps, ReconfigurationProblem rp); @Override Set<VM> getMisPlacedVMs(Instance i); @Override String toString();  }