use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class CLonelyTest method testWithNonPersistingVMs.
@Test
public void testWithNonPersistingVMs() {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
mo.getMapping().on(n1, n2, n3).ready(vm1, vm2);
Set<VM> mine = new HashSet<>(Arrays.asList(vm1, vm2));
Lonely l = new Lonely(mine);
Instance i = new Instance(mo, Collections.singleton(l), new MinMTTR());
ChocoScheduler cra = new DefaultChocoScheduler();
Assert.assertNotNull(cra.solve(i));
Assert.assertEquals(cra.getStatistics().lastSolution().getSize(), 0);
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class CAmongTest method testGetMisplaced.
@Test
public void testGetMisplaced() {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
VM vm5 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
Node n4 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2, n3, n4).run(n1, vm1).run(n2, vm2, vm3).ready(vm4, vm5);
Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2, vm5));
Collection<Node> s1 = new HashSet<>(Arrays.asList(n1, n2));
Collection<Node> s2 = new HashSet<>(Arrays.asList(n3, n4));
Collection<Collection<Node>> pGrps = new HashSet<>(Arrays.asList(s1, s2));
Among a = new Among(vms, pGrps);
CAmong ca = new CAmong(a);
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
Assert.assertEquals(ca.getMisPlacedVMs(i), Collections.emptySet());
map.addRunningVM(vm5, n3);
Assert.assertEquals(ca.getMisPlacedVMs(i), vms);
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class COfflineTest method testGetMisplacedAndSatisfied.
@Test
public void testGetMisplacedAndSatisfied() {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2);
Offline off = new Offline(n1);
COffline coff = new COffline(off);
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
Assert.assertTrue(coff.getMisPlacedVMs(i).isEmpty());
map.addRunningVM(vm1, n1);
Assert.assertEquals(coff.getMisPlacedVMs(i), map.getAllVMs());
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class FixedSizePartitioningTest method makeInstance.
private static Instance makeInstance() {
Model mo = new DefaultModel();
for (int i = 0; i < 13; i++) {
Node n = mo.newNode();
mo.getMapping().addOnlineNode(n);
for (int j = 0; j < 3; j++) {
VM v = mo.newVM();
mo.getMapping().addRunningVM(v, n);
}
}
for (int i = 0; i < 5; i++) {
mo.getMapping().addReadyVM(mo.newVM());
}
return new Instance(mo, Running.newRunning(mo.getMapping().getAllVMs()), new MinMTTR());
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class StaticPartitioningTest method testParallelSolve.
@Test
public void testParallelSolve() throws SchedulerException {
SynchronizedElementBuilder eb = new SynchronizedElementBuilder(new DefaultElementBuilder());
Model origin = new DefaultModel(eb);
Node n1 = origin.newNode();
Node n2 = origin.newNode();
VM vm1 = origin.newVM();
VM vm2 = origin.newVM();
/*
* 2 nodes among 2 instances, 2 VMs to boot on the nodes
*/
origin.getMapping().addOnlineNode(n1);
origin.getMapping().addOfflineNode(n2);
origin.getMapping().addReadyVM(vm1);
origin.getMapping().addReadyVM(vm2);
Model s1 = new SubModel(origin, eb, Collections.singletonList(n1), Collections.singleton(vm1));
Model s2 = new SubModel(origin, eb, Collections.singletonList(n2), Collections.singleton(vm2));
Instance i0 = new Instance(origin, new MinMTTR());
final Instance i1 = new Instance(s1, Running.newRunning(Collections.singletonList(vm1)), new MinMTTR());
final Instance i2 = new Instance(s2, new MinMTTR());
i2.getSatConstraints().add(new Running(vm2));
StaticPartitioning st = new StaticPartitioning() {
@Override
public List<Instance> split(Parameters ps, Instance i) throws SchedulerException {
return Arrays.asList(i1, i2);
}
};
Parameters p = new DefaultChocoScheduler();
ReconfigurationPlan plan = st.solve(p, i0);
Assert.assertNotNull(plan);
Model dst = plan.getResult();
Assert.assertEquals(dst.getMapping().getOnlineNodes().size(), 2);
Assert.assertEquals(dst.getMapping().getRunningVMs().size(), 2);
// Now, there is no solution for i2. the resulting plan should be null
i2.getSatConstraints().addAll(Offline.newOffline(n2));
plan = st.solve(p, i0);
Assert.assertNull(plan);
Assert.assertEquals(st.getStatistics().getSolutions().size(), 0);
}
Aggregations