Search in sources :

Example 16 with Running

use of org.btrplace.model.constraint.Running in project scheduler by btrplace.

the class CRunningTest method testGetMisplaced.

@Test
public void testGetMisplaced() {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    mo.getMapping().on(n1).ready(vm1).run(n1, vm2);
    Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
    CRunning k = new CRunning(new Running(vm1));
    Assert.assertEquals(1, k.getMisPlacedVMs(i).size());
    Assert.assertTrue(k.getMisPlacedVMs(i).contains(vm1));
    k = new CRunning(new Running(vm2));
    Assert.assertEquals(0, k.getMisPlacedVMs(i).size());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR) Running(org.btrplace.model.constraint.Running) Test(org.testng.annotations.Test)

Example 17 with Running

use of org.btrplace.model.constraint.Running in project scheduler by btrplace.

the class CSeqTest method testWithOnlyTransitions.

@Test
public void testWithOnlyTransitions() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2).ready(vm1).run(n1, vm2, vm4).sleep(n2, vm3);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(new Running(vm1));
    cstrs.add(new Sleeping(vm2));
    cstrs.add(new Running(vm3));
    cstrs.add(new Ready(vm4));
    cstrs.addAll(Online.newOnline(map.getAllNodes()));
    ChocoScheduler cra = new DefaultChocoScheduler();
    List<VM> seq = Arrays.asList(vm1, vm2, vm3, vm4);
    cstrs.add(new Seq(seq));
    ReconfigurationPlan plan = cra.solve(mo, cstrs);
    Assert.assertNotNull(plan);
}
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) Ready(org.btrplace.model.constraint.Ready) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Sleeping(org.btrplace.model.constraint.Sleeping) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Running(org.btrplace.model.constraint.Running) Seq(org.btrplace.model.constraint.Seq) Test(org.testng.annotations.Test)

Example 18 with Running

use of org.btrplace.model.constraint.Running in project scheduler by btrplace.

the class RunningBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodRunnings")
public void testGoodSignatures(String str, int nbVMs, boolean c) throws Exception {
    ScriptBuilder b = new ScriptBuilder(new DefaultModel());
    Set<SatConstraint> cstrs = b.build("namespace test; VM[1..10] : tiny;\n@N[1..20] : defaultNode;" + str).getConstraints();
    Assert.assertEquals(cstrs.size(), nbVMs);
    Set<VM> vms = new HashSet<>();
    for (SatConstraint x : cstrs) {
        Assert.assertTrue(x instanceof Running);
        Assert.assertTrue(vms.addAll(x.getInvolvedVMs()));
        Assert.assertEquals(x.isContinuous(), c);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) VM(org.btrplace.model.VM) Running(org.btrplace.model.constraint.Running) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 19 with Running

use of org.btrplace.model.constraint.Running in project scheduler by btrplace.

the class DefaultChocoSchedulerTest method testGetStatisticsWithNoSolution.

@Test
public void testGetStatisticsWithNoSolution() throws SchedulerException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    VM v = mo.newVM();
    Node n = mo.newNode();
    map.addReadyVM(v);
    map.addOfflineNode(n);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, Arrays.asList(new Running(v), new Offline(n)));
    Assert.assertNull(p);
    SolvingStatistics stats = cra.getStatistics();
    Assert.assertNotNull(stats);
    Assert.assertTrue(stats.getSolutions().isEmpty());
// Assert.assertFalse(stats.hitTimeout());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Running(org.btrplace.model.constraint.Running) Offline(org.btrplace.model.constraint.Offline) Mapping(org.btrplace.model.Mapping) SolvingStatistics(org.btrplace.scheduler.choco.runner.SolvingStatistics) Test(org.testng.annotations.Test)

Example 20 with Running

use of org.btrplace.model.constraint.Running in project scheduler by btrplace.

the class DefaultChocoSchedulerTest method testNonHomogeneousIncrease.

/**
 * Issue #14
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testNonHomogeneousIncrease() throws SchedulerException {
    ShareableResource cpu = new ShareableResource("cpu");
    ShareableResource mem = new ShareableResource("mem");
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    cpu.setCapacity(n1, 10);
    mem.setCapacity(n1, 10);
    cpu.setCapacity(n2, 10);
    mem.setCapacity(n2, 10);
    cpu.setConsumption(vm1, 5);
    mem.setConsumption(vm1, 4);
    cpu.setConsumption(vm2, 3);
    mem.setConsumption(vm2, 8);
    cpu.setConsumption(vm3, 5);
    cpu.setConsumption(vm3, 4);
    cpu.setConsumption(vm4, 4);
    cpu.setConsumption(vm4, 5);
    // vm1 requires more cpu resources, but fewer mem resources
    Preserve pCPU = new Preserve(vm1, "cpu", 7);
    Preserve pMem = new Preserve(vm1, "mem", 2);
    mo.getMapping().on(n1, n2).run(n1, vm1).run(n2, vm3, vm4).ready(vm2);
    mo.attach(cpu);
    mo.attach(mem);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.setMaxEnd(5);
    ReconfigurationPlan p = cra.solve(mo, Arrays.asList(pCPU, pMem, new Online(n1), new Running(vm2), new Ready(vm3)));
    Assert.assertNotNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Ready(org.btrplace.model.constraint.Ready) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Running(org.btrplace.model.constraint.Running) ShareableResource(org.btrplace.model.view.ShareableResource) Online(org.btrplace.model.constraint.Online) Preserve(org.btrplace.model.constraint.Preserve) 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