use of org.btrplace.scheduler.runner.disjoint.FixedNodeSetsPartitioning in project scheduler by btrplace.
the class MaxOnlineSplitterTest method testSplit.
@Test
public void testSplit() throws SchedulerException {
MaxOnlineSplitter splitter = new MaxOnlineSplitter();
Model mo = new DefaultModel();
Node[] ns = new Node[10];
for (int i = 0; i < ns.length; i++) {
Node n = mo.newNode();
mo.getMapping().addOnlineNode(n);
ns[i] = n;
}
FixedNodeSetsPartitioning cut = new FixedSizePartitioning(5);
Instance origin = new Instance(mo, Collections.emptyList(), new MinMTTR());
List<Instance> instances = cut.split(new DefaultParameters(), origin);
TIntIntHashMap vmIndex = Instances.makeVMIndex(instances);
TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
MaxOnline m1 = new MaxOnline(new HashSet<>(Arrays.asList(ns[0], ns[1], ns[2], ns[3], ns[4])), 3);
// This one is valid as m1 stay in the first partition
Assert.assertTrue(splitter.split(m1, origin, instances, vmIndex, nodeIndex));
boolean found = false;
for (Instance i : instances) {
if (i.getSatConstraints().contains(m1)) {
if (found) {
Assert.fail(m1 + " is already in a partition");
}
found = true;
}
}
// Invalid, the constraint is over 2 partitions
MaxOnline m2 = new MaxOnline(new HashSet<>(Arrays.asList(ns[0], ns[1], ns[5])), 3);
Assert.assertFalse(splitter.split(m2, origin, instances, vmIndex, nodeIndex));
}
use of org.btrplace.scheduler.runner.disjoint.FixedNodeSetsPartitioning in project scheduler by btrplace.
the class AmongSplitterTest method testSplittable.
@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);
/*
N1 v1 v2
N2 v3
---
N3 v4
--
N4 v5
*/
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());
}
}
Aggregations