Search in sources :

Example 56 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class CBanTest method testBasic.

@Test
public void testBasic() throws SchedulerException {
    Node[] nodes = new Node[5];
    VM[] vms = new VM[5];
    Model mo = new DefaultModel();
    Mapping m = mo.getMapping();
    Set<VM> sVMs = new HashSet<>();
    Set<Node> sNodes = new HashSet<>();
    for (int i = 0; i < vms.length; i++) {
        nodes[i] = mo.newNode();
        vms[i] = mo.newVM();
        m.addOnlineNode(nodes[i]);
        m.addRunningVM(vms[i], nodes[i]);
        if (i % 2 == 0) {
            sVMs.add(vms[i]);
            sNodes.add(nodes[i]);
        }
    }
    Ban b = new Ban(vms[0], sNodes);
    Collection<SatConstraint> s = new HashSet<>();
    s.add(b);
    s.addAll(Running.newRunning(m.getAllVMs()));
    s.addAll(Online.newOnline(m.getAllNodes()));
    DefaultChocoScheduler cra = new DefaultChocoScheduler();
    cra.setTimeLimit(-1);
    ReconfigurationPlan p = cra.solve(mo, s);
    Assert.assertNotNull(p);
    Assert.assertEquals(1, p.getSize());
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) org.btrplace.model.constraint(org.btrplace.model.constraint) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 57 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class CFenceTest method testBasic.

@Test
public void testBasic() 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();
    Node n3 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm4).run(n2, vm2).run(n3, vm3);
    Set<Node> on = new HashSet<>(Arrays.asList(n1, n3));
    Fence f = new Fence(vm2, on);
    ChocoScheduler cra = new DefaultChocoScheduler();
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(f);
    cstrs.addAll(Online.newOnline(map.getAllNodes()));
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
    Assert.assertTrue(p.getSize() > 0);
    Assert.assertTrue(p.iterator().next() instanceof MigrateVM);
    // Assert.assertEquals(SatConstraint.Sat.SATISFIED, f.isSatisfied(p.getResult()));
    cstrs.add(new Ready(vm2));
    p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
    // Just the suspend of vm2
    Assert.assertEquals(1, p.getSize());
// Assert.assertEquals(SatConstraint.Sat.SATISFIED, f.isSatisfied(p.getResult()));
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) MigrateVM(org.btrplace.plan.event.MigrateVM) Test(org.testng.annotations.Test)

Example 58 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class CGatherTest method testContinuousWithPartialRunning.

@Test
public void testContinuousWithPartialRunning() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Mapping map = mo.getMapping().ready(vm1).on(n1, n2).run(n2, vm2);
    Gather g = new Gather(map.getAllVMs());
    g.setContinuous(true);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Running.newRunning(map.getAllVMs()));
    cstrs.add(g);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(mo, cstrs);
    Assert.assertNotNull(plan);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 59 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class CLonelyTest method testFeasibleContinuous.

/**
 * vm3 needs to go to n2 . vm1, vm2, vm3 must be lonely. n2 is occupied by "other" VMs, so
 * they have to go away before receiving vm3
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testFeasibleContinuous() throws SchedulerException {
    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();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm2, vm3).run(n2, vm4, vm5);
    Set<VM> mine = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
    ChocoScheduler cra = new DefaultChocoScheduler();
    Lonely l = new Lonely(mine);
    l.setContinuous(true);
    Set<SatConstraint> cstrs = new HashSet<>();
    cstrs.add(l);
    cstrs.add(new Fence(vm3, Collections.singleton(n2)));
    ReconfigurationPlan plan = cra.solve(mo, cstrs);
    Assert.assertNotNull(plan);
}
Also used : Lonely(org.btrplace.model.constraint.Lonely) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 60 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class CMaxOnlineTest method discreteMaxOnlineTest2.

@Test
public void discreteMaxOnlineTest2() throws SchedulerException {
    Model model = new DefaultModel();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    Node n3 = model.newNode();
    VM vm1 = model.newVM();
    VM vm2 = model.newVM();
    VM vm3 = model.newVM();
    VM vm4 = model.newVM();
    ShareableResource resources = new ShareableResource("vcpu", 1, 1);
    resources.setCapacity(n1, 4);
    resources.setCapacity(n2, 8);
    resources.setCapacity(n3, 2);
    resources.setConsumption(vm4, 2);
    Mapping map = model.getMapping().on(n1, n2, n3).run(n1, vm1, vm4).run(n2, vm2).run(n3, vm3);
    model.attach(resources);
    MappingUtils.fill(map, model.getMapping());
    Set<Node> nodes = map.getAllNodes();
    MaxOnline maxon = new MaxOnline(nodes, 2);
    Set<Node> nodes2 = new HashSet<>(Arrays.asList(n1, n2));
    MaxOnline maxon2 = new MaxOnline(nodes2, 1);
    List<SatConstraint> constraints = new ArrayList<>();
    constraints.add(maxon);
    constraints.add(maxon2);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.setMaxEnd(4);
    cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
    ReconfigurationPlan plan = cra.solve(model, constraints);
    Assert.assertNotNull(plan);
    Assert.assertTrue(maxon.isSatisfied(plan.getResult()));
}
Also used : SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ShareableResource(org.btrplace.model.view.ShareableResource) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) MaxOnline(org.btrplace.model.constraint.MaxOnline) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Aggregations

ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)185 Test (org.testng.annotations.Test)160 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)94 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)74 SatConstraint (org.btrplace.model.constraint.SatConstraint)53 ShareableResource (org.btrplace.model.view.ShareableResource)52 Model (org.btrplace.model.Model)49 ArrayList (java.util.ArrayList)46 Node (org.btrplace.model.Node)45 DefaultModel (org.btrplace.model.DefaultModel)44 VM (org.btrplace.model.VM)41 MigrateVM (org.btrplace.plan.event.MigrateVM)37 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)34 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)32 Parameters (org.btrplace.scheduler.choco.Parameters)29 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)29 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)28 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)24 Mapping (org.btrplace.model.Mapping)23 HashSet (java.util.HashSet)22