@Test public void simpleTest() { LonelySplitter splitter = new LonelySplitter(); List<Instance> instances = new ArrayList<>(); Model m0 = new DefaultModel(); m0.getMapping().addReadyVM(m0.newVM(1)); m0.getMapping().addRunningVM(m0.newVM(2), m0.newNode(1)); Model m1 = new DefaultModel(); m1.getMapping().addReadyVM(m1.newVM(3)); m1.getMapping().addSleepingVM(m1.newVM(4), m1.newNode(2)); m1.getMapping().addRunningVM(m1.newVM(5), m1.newNode(3)); instances.add(new Instance(m0, new ArrayList<>(), new MinMTTR())); instances.add(new Instance(m1, new ArrayList<>(), new MinMTTR())); TIntIntHashMap index = Instances.makeVMIndex(instances); Set<VM> all = new HashSet<>(m0.getMapping().getAllVMs()); all.addAll(m1.getMapping().getAllVMs()); Lonely single = new Lonely(m0.getMapping().getAllVMs()); Assert.assertTrue(splitter.split(single, null, instances, index, new TIntIntHashMap())); Assert.assertTrue(instances.get(0).getSatConstraints().contains(single)); Assert.assertFalse(instances.get(1).getSatConstraints().contains(single)); Lonely among = new Lonely(all, false); Assert.assertTrue(splitter.split(among, null, instances, index, new TIntIntHashMap())); Assert.assertTrue(instances.get(0).getSatConstraints().contains(new Lonely(m0.getMapping().getAllVMs(), false))); Assert.assertTrue(instances.get(1).getSatConstraints().contains(new Lonely(m1.getMapping().getAllVMs(), false))); }
@Override public boolean split(Lonely cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to != from) { partitions.get(idx).getSatConstraints().add(new Lonely(new ElementSubSet<>(index, idx, from, to), c)); } return true; }); }
LonelySplitter implements ConstraintSplitter<Lonely> { @Override public boolean split(Lonely cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to != from) { partitions.get(idx).getSatConstraints().add(new Lonely(new ElementSubSet<>(index, idx, from, to), c)); } return true; }); } }
LonelySplitter implements ConstraintSplitter<Lonely> { @Override public boolean split(Lonely cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to != from) { partitions.get(idx).getSatConstraints().add(new Lonely(new ElementSubSet<>(index, idx, from, to), c)); } return true; }); }  }
LonelySplitter implements ConstraintSplitter<Lonely> { @Override public boolean split(Lonely cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to != from) { partitions.get(idx).getSatConstraints().add(new Lonely(new ElementSubSet<>(index, idx, from, to), c)); } return true; }); }  @Override Class<Lonely> getKey(); @Override boolean split(Lonely cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition); }
LonelySplitter implements ConstraintSplitter<Lonely> { @Override public boolean split(Lonely cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to != from) { partitions.get(idx).getSatConstraints().add(new Lonely(new ElementSubSet<>(index, idx, from, to), c)); } return true; }); }  @Override Class<Lonely> getKey(); @Override boolean split(Lonely cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition);  }