Search in sources :

Example 46 with ChocoScheduler

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

the class CShareableResourceTest method testInitiallyUnsatisfied.

@Test
public void testInitiallyUnsatisfied() throws SchedulerException {
    Model mo = new DefaultModel();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    ShareableResource rc = new ShareableResource("cpu", 1, 1);
    VM v1 = mo.newVM();
    VM v2 = mo.newVM();
    mo.getMapping().addOnlineNode(n1);
    mo.getMapping().addOnlineNode(n2);
    mo.getMapping().addRunningVM(v1, n1);
    mo.getMapping().addRunningVM(v2, n1);
    mo.attach(rc);
    ChocoScheduler s = new DefaultChocoScheduler();
    try {
        Assert.assertNull(s.solve(mo, new ArrayList<>()));
        Assert.fail("Should have thrown an exception");
    } catch (@SuppressWarnings("unused") SchedulerException e) {
        Assert.assertEquals(s.getStatistics().getMetrics().backtracks(), 0);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) SchedulerException(org.btrplace.scheduler.SchedulerException) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) ArrayList(java.util.ArrayList) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 47 with ChocoScheduler

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

the class CShareableResourceTest method testMisplaced.

@Test
public void testMisplaced() throws SchedulerException {
    Model mo = new DefaultModel();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    ShareableResource rc = new ShareableResource("cpu", 10, 1);
    VM v1 = mo.newVM();
    VM v2 = mo.newVM();
    mo.getMapping().addOnlineNode(n1);
    mo.getMapping().addOnlineNode(n2);
    mo.getMapping().addRunningVM(v1, n1);
    mo.getMapping().addRunningVM(v2, n1);
    mo.attach(rc);
    List<SatConstraint> l = new ArrayList<>();
    l.addAll(Preserve.newPreserve(mo.getMapping().getAllVMs(), "cpu", 5));
    ChocoScheduler s = new DefaultChocoScheduler();
    s.doRepair(true);
    ReconfigurationPlan p = s.solve(mo, l);
    Assert.assertEquals(s.getStatistics().getNbManagedVMs(), 0);
    Assert.assertNotNull(p);
    Assert.assertEquals(p.getResult().getMapping(), mo.getMapping());
    Assert.assertEquals(p.getSize(), 2);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) ArrayList(java.util.ArrayList) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 48 with ChocoScheduler

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

the class SolverTuning method run.

@Override
@SuppressWarnings("squid:S1166")
public void run() {
    // Make a default model with 500 nodes hosting 3,000 VMs
    Model model = makeModel();
    Set<SatConstraint> constraints = new HashSet<>();
    // We allow memory over-commitment with a overbooking ratio of 50%
    // i.e. 1MB physical RAM for 1.5MB virtual RAM
    constraints.addAll(Overbook.newOverbooks(model.getMapping().getAllNodes(), "mem", 1.5));
    /**
     * On 10 nodes, 4 of the 6 hosted VMs ask now for a 4GB bandwidth
     */
    for (int i = 0; i < 5; i++) {
        Node n = nodes.get(i);
        Set<VM> vmsOnN = model.getMapping().getRunningVMs(n);
        Iterator<VM> ite = vmsOnN.iterator();
        for (int j = 0; ite.hasNext() && j < 4; j++) {
            VM v = ite.next();
            constraints.add(new Preserve(v, "bandwidth", 4));
        }
    }
    ChocoScheduler cra = new DefaultChocoScheduler();
    // Customize the estimated duration of actions
    cra.getDurationEvaluators().register(MigrateVM.class, new LinearToAResourceActionDuration<VM>("mem", 1, 3));
    // We want the best possible solution, computed in up to 5 sec.
    cra.doOptimize(true);
    cra.setTimeLimit(5);
    // We solve without the repair mode
    cra.doRepair(false);
    try {
        solve(cra, model, constraints);
    } catch (@SuppressWarnings("unused") SchedulerException ex) {
    // Just in case the testing environment is not performant enough
    // It does not matter that much if there is no enough time to get a solution here
    }
    // Re-solve using the repair mode to check for the improvement
    cra.doRepair(true);
    solve(cra, model, constraints);
}
Also used : SchedulerException(org.btrplace.scheduler.SchedulerException) SatConstraint(org.btrplace.model.constraint.SatConstraint) SatConstraint(org.btrplace.model.constraint.SatConstraint) Preserve(org.btrplace.model.constraint.Preserve) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) MigrateVM(org.btrplace.plan.event.MigrateVM)

Example 49 with ChocoScheduler

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

the class CAmongTest method testContinuousWithAlreadySatisfied.

@Test
public void testContinuousWithAlreadySatisfied() 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 = new HashSet<>(Arrays.asList(s1, s2));
    Among a = new Among(vms, pGrps);
    a.setContinuous(true);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Running.newRunning(map.getAllVMs()));
    cstrs.add(a);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(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 50 with ChocoScheduler

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

the class CAmongTest method testWithOnGroup.

@Test
public void testWithOnGroup() 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).run(n3, vm3).ready(vm4, vm5);
    Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
    Collection<Collection<Node>> pGrps = new HashSet<>();
    Set<Node> s = new HashSet<>();
    s.add(n1);
    s.add(n2);
    pGrps.add(s);
    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(a);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(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)

Aggregations

ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)82 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)82 Test (org.testng.annotations.Test)76 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)73 ShareableResource (org.btrplace.model.view.ShareableResource)30 SatConstraint (org.btrplace.model.constraint.SatConstraint)28 ArrayList (java.util.ArrayList)25 DefaultModel (org.btrplace.model.DefaultModel)17 Model (org.btrplace.model.Model)17 Node (org.btrplace.model.Node)17 VM (org.btrplace.model.VM)16 BootVM (org.btrplace.plan.event.BootVM)12 ShutdownVM (org.btrplace.plan.event.ShutdownVM)12 MigrateVM (org.btrplace.plan.event.MigrateVM)10 Fence (org.btrplace.model.constraint.Fence)9 Preserve (org.btrplace.model.constraint.Preserve)8 org.btrplace.model.constraint (org.btrplace.model.constraint)7 MaxOnline (org.btrplace.model.constraint.MaxOnline)6 org.btrplace.model (org.btrplace.model)5 SchedulerException (org.btrplace.scheduler.SchedulerException)5