@Test public void testSplittable() throws SchedulerException { List<VM> vms = Arrays.asList(vm1, vm2, vm3); Collection<Collection<Node>> parts = new ArrayList<>(); parts.add(Arrays.asList(n1, n2)); parts.add(Collections.singletonList(n3)); parts.add(Collections.singletonList(n4)); Among single = new Among(vms, parts); FixedNodeSetsPartitioning partitionner = new FixedNodeSetsPartitioning(parts); partitionner.setPartitions(parts); List<Instance> instances = partitionner.split(new DefaultParameters(), new Instance(mo, Collections.emptyList(), new MinMTTR())); TIntIntHashMap vmIndex = Instances.makeVMIndex(instances); TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances); splitter.split(single, new Instance(mo, new MinMTTR()), instances, vmIndex, nodeIndex); Among a = (Among) instances.get(0).getSatConstraints().iterator().next(); Assert.assertEquals(a.getGroupsOfNodes().size(), 1); Assert.assertEquals(a.getInvolvedNodes(), Arrays.asList(n1, n2)); for (Instance i : instances) { System.out.println(i.getSatConstraints()); } }
@Override public boolean split(final Among cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, final TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to - from >= 2) { ElementSubSet<VM> vms = new ElementSubSet<>(index, idx, from, to); final Collection<Collection<Node>> subParams = new ArrayList<>(); for (Collection<Node> ns : cstr.getGroupsOfNodes()) { SplittableElementSet<Node> nodeIndex = SplittableElementSet.newNodeIndex(ns, nodePosition); Set<Node> s = nodeIndex.getSubSet(idx); if (s != null && !s.isEmpty()) { subParams.add(s); } } partitions.get(idx).getSatConstraints().add(new Among(vms, subParams, c)); } return true; }); }
AmongSplitter implements ConstraintSplitter<Among> { @Override public boolean split(final Among cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, final TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to - from >= 2) { ElementSubSet<VM> vms = new ElementSubSet<>(index, idx, from, to); final Collection<Collection<Node>> subParams = new ArrayList<>(); for (Collection<Node> ns : cstr.getGroupsOfNodes()) { SplittableElementSet<Node> nodeIndex = SplittableElementSet.newNodeIndex(ns, nodePosition); Set<Node> s = nodeIndex.getSubSet(idx); if (s != null && !s.isEmpty()) { subParams.add(s); } } partitions.get(idx).getSatConstraints().add(new Among(vms, subParams, c)); } return true; }); } }
AmongSplitter implements ConstraintSplitter<Among> { @Override public boolean split(final Among cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, final TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to - from >= 2) { ElementSubSet<VM> vms = new ElementSubSet<>(index, idx, from, to); final Collection<Collection<Node>> subParams = new ArrayList<>(); for (Collection<Node> ns : cstr.getGroupsOfNodes()) { SplittableElementSet<Node> nodeIndex = SplittableElementSet.newNodeIndex(ns, nodePosition); Set<Node> s = nodeIndex.getSubSet(idx); if (s != null && !s.isEmpty()) { subParams.add(s); } } partitions.get(idx).getSatConstraints().add(new Among(vms, subParams, c)); } return true; }); }  }
AmongSplitter implements ConstraintSplitter<Among> { @Override public boolean split(final Among cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, final TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to - from >= 2) { ElementSubSet<VM> vms = new ElementSubSet<>(index, idx, from, to); final Collection<Collection<Node>> subParams = new ArrayList<>(); for (Collection<Node> ns : cstr.getGroupsOfNodes()) { SplittableElementSet<Node> nodeIndex = SplittableElementSet.newNodeIndex(ns, nodePosition); Set<Node> s = nodeIndex.getSubSet(idx); if (s != null && !s.isEmpty()) { subParams.add(s); } } partitions.get(idx).getSatConstraints().add(new Among(vms, subParams, c)); } return true; }); }  @Override Class<Among> getKey(); @Override boolean split(final Among cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, final TIntIntHashMap nodePosition); }
AmongSplitter implements ConstraintSplitter<Among> { @Override public boolean split(final Among cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, final TIntIntHashMap nodePosition) { final boolean c = cstr.isContinuous(); return SplittableElementSet.newVMIndex(cstr.getInvolvedVMs(), vmsPosition). forEachPartition((index, idx, from, to) -> { if (to - from >= 2) { ElementSubSet<VM> vms = new ElementSubSet<>(index, idx, from, to); final Collection<Collection<Node>> subParams = new ArrayList<>(); for (Collection<Node> ns : cstr.getGroupsOfNodes()) { SplittableElementSet<Node> nodeIndex = SplittableElementSet.newNodeIndex(ns, nodePosition); Set<Node> s = nodeIndex.getSubSet(idx); if (s != null && !s.isEmpty()) { subParams.add(s); } } partitions.get(idx).getSatConstraints().add(new Among(vms, subParams, c)); } return true; }); }  @Override Class<Among> getKey(); @Override boolean split(final Among cstr, Instance origin, final List<Instance> partitions, TIntIntHashMap vmsPosition, final TIntIntHashMap nodePosition);  }