@Test public void simpleTest() { RunningSplitter splitter = new RunningSplitter(); List<Instance> instances = new ArrayList<>(); Model origin = new DefaultModel(); Node n1 = origin.newNode(); Node n2 = origin.newNode(); VM vm1 = origin.newVM(); VM vm2 = origin.newVM(); VM vm3 = origin.newVM(); VM vm4 = origin.newVM(); origin.getMapping().addOnlineNode(n1); origin.getMapping().addReadyVM(vm1); origin.getMapping().addRunningVM(vm2, n1); origin.getMapping().addOnlineNode(n2); origin.getMapping().addSleepingVM(vm3, n2); origin.getMapping().addRunningVM(vm4, n2); Model m0 = new DefaultModel(); m0.newNode(n1.id()); m0.newVM(vm1.id()); m0.newVM(vm2.id()); m0.getMapping().addOnlineNode(n1); m0.getMapping().addReadyVM(vm1); m0.getMapping().addRunningVM(vm2, n1); Model m1 = new DefaultModel(); m1.newNode(n2.id()); m1.newVM(vm3.id()); m1.newVM(vm4.id()); m1.getMapping().addOnlineNode(n2); m1.getMapping().addSleepingVM(vm3, n2); m1.getMapping().addRunningVM(vm4, n2); 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); Running single = new Running(vm1); 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(Running 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); }
RunningSplitter implements ConstraintSplitter<Running> { @Override public boolean split(Running 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); } }
RunningSplitter implements ConstraintSplitter<Running> { @Override public boolean split(Running 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); }  }
RunningSplitter implements ConstraintSplitter<Running> { @Override public boolean split(Running 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<Running> getKey(); @Override boolean split(Running cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition); }
RunningSplitter implements ConstraintSplitter<Running> { @Override public boolean split(Running 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<Running> getKey(); @Override boolean split(Running cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, TIntIntHashMap nodePosition);  }