use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class BenchTest method instance.
public static Instance instance() {
Model mo = new DefaultModel();
VM v1 = mo.newVM();
VM v2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
mo.getMapping().on(n1, n2, n3).run(n1, v1).run(n2, v2).off(n3);
Set<VM> s = new HashSet<>();
s.add(v1);
s.add(v2);
List<SatConstraint> cstrs = Arrays.asList(new Spread(s, true), new Fence(v1, n2), new Offline(n1));
return new Instance(mo, cstrs, new MinMTTR());
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class CKilledTest method testGetMisplaced.
@Test
public void testGetMisplaced() {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm5 = mo.newVM();
Node n1 = mo.newNode();
mo.getMapping().ready(vm1).on(n1).run(n1, vm2);
CKilled k = new CKilled(new Killed(vm5));
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
Assert.assertTrue(k.getMisPlacedVMs(i).isEmpty());
k = new CKilled(new Killed(vm2));
Assert.assertEquals(1, k.getMisPlacedVMs(i).size());
Assert.assertTrue(k.getMisPlacedVMs(i).contains(vm2));
k = new CKilled(new Killed(vm1));
Assert.assertEquals(1, k.getMisPlacedVMs(i).size());
Assert.assertTrue(k.getMisPlacedVMs(i).contains(vm1));
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class InstanceConverterTest method testConversion.
@Test
public void testConversion() throws JSONConverterException {
Model mo = new DefaultModel();
Mapping ma = mo.getMapping();
Node n1 = mo.newNode();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
ma.addOnlineNode(n1);
ma.addOfflineNode(n1);
ma.addReadyVM(vm1);
ma.addReadyVM(vm2);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Online.newOnline(ma.getAllNodes()));
cstrs.add(new Running(vm2));
Instance i = new Instance(mo, cstrs, new MinMTTR());
InstanceConverter conv = new InstanceConverter();
String o = conv.toJSONString(i);
System.out.println(o);
Instance res = conv.fromJSON(o);
Assert.assertEquals(i, res);
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class MinMttrConverterTest method test.
@Test
public void test() throws JSONConverterException {
Model mo = new DefaultModel();
ConstraintsConverter conv = new ConstraintsConverter();
conv.register(new MinMTTRConverter());
MinMTTR m = new MinMTTR();
Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(m)), m);
System.out.println(conv.toJSON(m));
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class SleepingSplitterTest method simpleTest.
@Test
public void simpleTest() {
SleepingSplitter splitter = new SleepingSplitter();
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
Sleeping single = new Sleeping(vm2);
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));
}
Aggregations