use of org.btrplace.model.constraint.Running in project scheduler by btrplace.
the class DefaultChocoSchedulerTest method testTransitionFactoryCustomisation.
/**
* Remove the ready->running transition so the solving process will fail
*
* @throws org.btrplace.scheduler.SchedulerException
*/
@Test
public void testTransitionFactoryCustomisation() throws SchedulerException {
ChocoScheduler cra = new DefaultChocoScheduler();
TransitionFactory tf = cra.getTransitionFactory();
VMTransitionBuilder b = tf.getBuilder(VMState.READY, VMState.RUNNING);
Assert.assertTrue(tf.remove(b));
Model mo = new DefaultModel();
VM v = mo.newVM();
mo.getMapping().addReadyVM(v);
Assert.assertNull(cra.solve(mo, Collections.singletonList(new Running(v))));
}
use of org.btrplace.model.constraint.Running in project scheduler by btrplace.
the class IssuesTest method testIssue171.
@Test
public void testIssue171() {
String buf = "{\"model\":{\"mapping\":{\"readyVMs\":[3],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[2]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[1]},\"2\":{\"sleepingVMs\":[],\"runningVMs\":[0]},\"3\":{\"sleepingVMs\":[],\"runningVMs\":[]},\"4\":{\"sleepingVMs\":[],\"runningVMs\":[]},\"5\":{\"sleepingVMs\":[],\"runningVMs\":[]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{}},\"views\":[{\"defConsumption\":0,\"nodes\":{\"0\":4,\"1\":4,\"2\":4,\"3\":4,\"4\":2147483,\"5\":2147483},\"rcId\":\"memory\",\"id\":\"shareableResource\",\"defCapacity\":0,\"vms\":{\"0\":4,\"1\":4,\"2\":4}}]},\"constraints\":[{\"vm\":0,\"id\":\"running\"},{\"vm\":1,\"id\":\"running\"},{\"vm\":2,\"id\":\"running\"},{\"node\":5,\"id\":\"online\"},{\"node\":4,\"id\":\"online\"},{\"node\":3,\"id\":\"online\"},{\"node\":2,\"id\":\"online\"},{\"node\":1,\"id\":\"online\"},{\"node\":0,\"id\":\"online\"},{\"continuous\":true,\"id\":\"spread\",\"vms\":[1,2]},{\"continuous\":false,\"id\":\"gather\",\"vms\":[2,3]},{\"vm\":3,\"id\":\"running\"}],\"objective\":{\"id\":\"minimizeMTTR\"}}";
Instance i = JSON.readInstance(new StringReader(buf));
i.getModel().getMapping().remove(new Node(3));
ShareableResource mem = ShareableResource.get(i.getModel(), "memory");
mem.unset(new Node(5));
mem.unset(new Node(4));
mem.unset(new Node(3));
i.getSatConstraints().removeIf(Online.class::isInstance);
i.getSatConstraints().removeIf(Spread.class::isInstance);
i.getSatConstraints().removeIf(Gather.class::isInstance);
i.getSatConstraints().removeIf(r -> r instanceof Running && !r.getInvolvedVMs().contains(new VM(3)));
i.getModel().getMapping().remove(new VM(0));
i.getModel().getMapping().remove(new Node(2));
i.getModel().getMapping().remove(new Node(5));
i.getModel().getMapping().remove(new Node(4));
ChocoScheduler s = new DefaultChocoScheduler();
ReconfigurationPlan plan = s.solve(i);
Assert.assertNotNull(plan);
}
use of org.btrplace.model.constraint.Running in project scheduler by btrplace.
the class COverbookTest method testWithScheduling1.
@Test
public void testWithScheduling1() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm3 = mo.newVM();
Node n1 = mo.newNode();
Mapping m = mo.getMapping().on(n1).run(n1, vm1).ready(vm3);
ShareableResource rcCPU = new ShareableResource("cpu", 2, 2);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.add(new Running(vm3));
cstrs.add(new Sleeping(vm1));
cstrs.addAll(Online.newOnline(m.getAllNodes()));
cstrs.add(new Overbook(n1, "cpu", 1));
cstrs.add(new Preserve(vm1, "cpu", 2));
cstrs.add(new Preserve(vm3, "cpu", 2));
mo.attach(rcCPU);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
}
use of org.btrplace.model.constraint.Running 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