Search in sources :

Example 16 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.

the class CAmongTest method testWithNoSolution.

/**
 * No solution because constraints force to spread the VMs among 2 groups.
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testWithNoSolution() 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();
    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> s = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> s2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Collection<Node>> pGrps = new HashSet<>(Arrays.asList(s, s2));
    Among a = new Among(vms, pGrps);
    a.setContinuous(false);
    ChocoScheduler cra = new DefaultChocoScheduler();
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Running.newRunning(map.getAllVMs()));
    cstrs.add(new Fence(vm2, Collections.singleton(n3)));
    cstrs.add(new Fence(vm1, Collections.singleton(n1)));
    cstrs.add(a);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(p);
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 17 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.

the class CAmongTest method testWithGroupChange.

@Test
public void testWithGroupChange() 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();
    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 = Arrays.asList(s1, s2);
    Among a = new Among(vms, pGrps);
    a.setContinuous(false);
    ChocoScheduler cra = new DefaultChocoScheduler();
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Running.newRunning(map.getAllVMs()));
    cstrs.add(new Fence(vm2, s2));
    cstrs.add(a);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
// System.out.println(p);
// Assert.assertEquals(a.isSatisfied(p.getResult()), SatConstraint.Sat.SATISFIED);
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 18 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler 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 19 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler 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 20 with DefaultChocoScheduler

use of org.btrplace.scheduler.choco.DefaultChocoScheduler 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)

Aggregations

DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)104 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)94 Test (org.testng.annotations.Test)90 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)83 ShareableResource (org.btrplace.model.view.ShareableResource)43 SatConstraint (org.btrplace.model.constraint.SatConstraint)40 ArrayList (java.util.ArrayList)37 DefaultModel (org.btrplace.model.DefaultModel)19 Model (org.btrplace.model.Model)19 Node (org.btrplace.model.Node)19 VM (org.btrplace.model.VM)18 MigrateVM (org.btrplace.plan.event.MigrateVM)17 Fence (org.btrplace.model.constraint.Fence)14 Network (org.btrplace.model.view.network.Network)14 BootVM (org.btrplace.plan.event.BootVM)14 ShutdownVM (org.btrplace.plan.event.ShutdownVM)14 Offline (org.btrplace.model.constraint.Offline)13 Switch (org.btrplace.model.view.network.Switch)13 MinMTTRMig (org.btrplace.model.constraint.migration.MinMTTRMig)11 SchedulerException (org.btrplace.scheduler.SchedulerException)11