Search in sources :

Example 21 with Running

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))));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Running(org.btrplace.model.constraint.Running) VMTransitionBuilder(org.btrplace.scheduler.choco.transition.VMTransitionBuilder) TransitionFactory(org.btrplace.scheduler.choco.transition.TransitionFactory) Test(org.testng.annotations.Test)

Example 22 with Running

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);
}
Also used : Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ShareableResource(org.btrplace.model.view.ShareableResource) Gather(org.btrplace.model.constraint.Gather) Spread(org.btrplace.model.constraint.Spread) VM(org.btrplace.model.VM) StringReader(java.io.StringReader) Running(org.btrplace.model.constraint.Running) Online(org.btrplace.model.constraint.Online) Test(org.testng.annotations.Test)

Example 23 with Running

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);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Mapping(org.btrplace.model.Mapping) ShareableResource(org.btrplace.model.view.ShareableResource) Preserve(org.btrplace.model.constraint.Preserve) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Sleeping(org.btrplace.model.constraint.Sleeping) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) BootVM(org.btrplace.plan.event.BootVM) VM(org.btrplace.model.VM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Overbook(org.btrplace.model.constraint.Overbook) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Running(org.btrplace.model.constraint.Running) Test(org.testng.annotations.Test)

Example 24 with Running

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);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Parameters(org.btrplace.scheduler.choco.Parameters) Instance(org.btrplace.model.Instance) DefaultElementBuilder(org.btrplace.model.DefaultElementBuilder) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MinMTTR(org.btrplace.model.constraint.MinMTTR) SubModel(org.btrplace.scheduler.runner.disjoint.model.SubModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) SubModel(org.btrplace.scheduler.runner.disjoint.model.SubModel) DefaultModel(org.btrplace.model.DefaultModel) Running(org.btrplace.model.constraint.Running) SynchronizedElementBuilder(org.btrplace.model.SynchronizedElementBuilder) Test(org.testng.annotations.Test)

Aggregations

Running (org.btrplace.model.constraint.Running)24 VM (org.btrplace.model.VM)20 Test (org.testng.annotations.Test)20 DefaultModel (org.btrplace.model.DefaultModel)17 Model (org.btrplace.model.Model)17 Node (org.btrplace.model.Node)17 SatConstraint (org.btrplace.model.constraint.SatConstraint)13 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)13 ArrayList (java.util.ArrayList)12 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)10 Instance (org.btrplace.model.Instance)8 MinMTTR (org.btrplace.model.constraint.MinMTTR)8 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)8 Mapping (org.btrplace.model.Mapping)7 ShareableResource (org.btrplace.model.view.ShareableResource)7 HashSet (java.util.HashSet)5 Ready (org.btrplace.model.constraint.Ready)5 Preserve (org.btrplace.model.constraint.Preserve)4 BootVM (org.btrplace.plan.event.BootVM)4 Fence (org.btrplace.model.constraint.Fence)3