@Test public void simpleTest() { ReadySplitter splitter = new ReadySplitter(); List<Instance> instances = new ArrayList<>(); Model m0 = new DefaultModel(); VM v = m0.newVM(1); m0.getMapping().addReadyVM(v); 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())); Set<VM> all = new HashSet<>(m0.getMapping().getAllVMs()); all.addAll(m1.getMapping().getAllVMs()); TIntIntHashMap index = Instances.makeVMIndex(instances); Ready single = new Ready(v); 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)); }
@Override public boolean split(Ready cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { VM v = cstr.getInvolvedVMs().iterator().next(); int i = vmsPosition.get(v.id()); return partitions.get(i).getSatConstraints().add(cstr); }
ReadySplitter implements ConstraintSplitter<Ready> { @Override public boolean split(Ready cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { VM v = cstr.getInvolvedVMs().iterator().next(); int i = vmsPosition.get(v.id()); return partitions.get(i).getSatConstraints().add(cstr); } }
ReadySplitter implements ConstraintSplitter<Ready> { @Override public boolean split(Ready cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { VM v = cstr.getInvolvedVMs().iterator().next(); int i = vmsPosition.get(v.id()); return partitions.get(i).getSatConstraints().add(cstr); }  }
ReadySplitter implements ConstraintSplitter<Ready> { @Override public boolean split(Ready cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { VM v = cstr.getInvolvedVMs().iterator().next(); int i = vmsPosition.get(v.id()); return partitions.get(i).getSatConstraints().add(cstr); }  @Override Class<Ready> getKey(); @Override boolean split(Ready cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition); }
ReadySplitter implements ConstraintSplitter<Ready> { @Override public boolean split(Ready cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition) { VM v = cstr.getInvolvedVMs().iterator().next(); int i = vmsPosition.get(v.id()); return partitions.get(i).getSatConstraints().add(cstr); }  @Override Class<Ready> getKey(); @Override boolean split(Ready cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition);  }