use of gnu.trove.map.hash.TIntIntHashMap in project scheduler by btrplace.
the class OverbookSplitterTest method simpleTest.
@Test
public void simpleTest() {
OverbookSplitter splitter = new OverbookSplitter();
List<Instance> instances = new ArrayList<>();
Model m0 = new DefaultModel();
Node n = m0.newNode(0);
m0.getMapping().addOnlineNode(n);
m0.getMapping().addOnlineNode(m0.newNode(1));
Model m1 = new DefaultModel();
m1.getMapping().addOnlineNode(m1.newNode(2));
m1.getMapping().addOnlineNode(m1.newNode(3));
instances.add(new Instance(m0, new ArrayList<>(), new MinMTTR()));
instances.add(new Instance(m1, new ArrayList<>(), new MinMTTR()));
Set<Node> all = new HashSet<>(m0.getMapping().getAllNodes());
all.addAll(m1.getMapping().getAllNodes());
TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
// Only nodes in m0
Overbook oSimple = new Overbook(n, "cpu", 2);
Assert.assertTrue(splitter.split(oSimple, null, instances, new TIntIntHashMap(), nodeIndex));
Assert.assertTrue(instances.get(0).getSatConstraints().contains(oSimple));
Assert.assertFalse(instances.get(1).getSatConstraints().contains(oSimple));
}
use of gnu.trove.map.hash.TIntIntHashMap in project scheduler by btrplace.
the class RunningSplitterTest method simpleTest.
@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();
/**
* READY: vm1
* n1 vm2
* n2 (vm3) vm4
*/
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);
// Only VMs in m0
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));
}
use of gnu.trove.map.hash.TIntIntHashMap in project scheduler by btrplace.
the class KilledSplitterTest method simpleTest.
@Test
public void simpleTest() {
KilledSplitter splitter = new KilledSplitter();
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()));
TIntIntHashMap index = Instances.makeVMIndex(instances);
Set<VM> all = new HashSet<>(m0.getMapping().getAllVMs());
all.addAll(m1.getMapping().getAllVMs());
// Only VMs in m0
Killed single = new Killed(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));
}
use of gnu.trove.map.hash.TIntIntHashMap 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 gnu.trove.map.hash.TIntIntHashMap in project scheduler by btrplace.
the class OnlineSplitterTest method simpleTest.
@Test
public void simpleTest() {
OnlineSplitter splitter = new OnlineSplitter();
List<Instance> instances = new ArrayList<>();
Model m0 = new DefaultModel();
Node n = m0.newNode();
m0.getMapping().addOnlineNode(n);
m0.getMapping().addOnlineNode(m0.newNode(1));
Model m1 = new DefaultModel();
m1.getMapping().addOnlineNode(m1.newNode(2));
m1.getMapping().addOnlineNode(m1.newNode(3));
instances.add(new Instance(m0, new ArrayList<>(), new MinMTTR()));
instances.add(new Instance(m1, new ArrayList<>(), new MinMTTR()));
Set<Node> all = new HashSet<>(m0.getMapping().getAllNodes());
all.addAll(m1.getMapping().getAllNodes());
TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
// Only nodes in m0
Online oSimple = new Online(n);
Assert.assertTrue(splitter.split(oSimple, null, instances, new TIntIntHashMap(), nodeIndex));
Assert.assertTrue(instances.get(0).getSatConstraints().contains(oSimple));
Assert.assertFalse(instances.get(1).getSatConstraints().contains(oSimple));
}
Aggregations