Search in sources :

Example 61 with DefaultChocoScheduler

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

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

the class NetworkAndMigrations method run.

@Override
public void run() {
    // New default model
    Model mo = new DefaultModel();
    Mapping ma = mo.getMapping();
    // Create and boot 2 source nodes and 1 destination node
    Node srcNode1 = mo.newNode();
    Node srcNode2 = mo.newNode();
    Node dstNode = mo.newNode();
    ma.addOnlineNode(srcNode1);
    ma.addOnlineNode(srcNode2);
    ma.addOnlineNode(dstNode);
    // Create 4 VMs and host 2 VMs on each source node
    VM vm0 = mo.newVM();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    ma.addRunningVM(vm0, srcNode1);
    ma.addRunningVM(vm1, srcNode1);
    ma.addRunningVM(vm2, srcNode2);
    ma.addRunningVM(vm3, srcNode2);
    // Set VM attributes 'memory used', 'hot dirty page size', 'hot dirty page duration' and 'cold dirty pages rate'
    // vm0 and vm3 are 'idle' VMs (with no special memory activity) but they still consume some memory
    // 2 GiB
    mo.getAttributes().put(vm0, "memUsed", 2000);
    // 2.2 GiB
    mo.getAttributes().put(vm3, "memUsed", 2200);
    // vm1 and vm2 consume memory and have a memory intensive workload equivalent to "stress --vm 1000 --bytes 50K"
    // 8 GiB
    mo.getAttributes().put(vm1, "memUsed", 8000);
    mo.getAttributes().put(vm1, "hotDirtySize", 56);
    mo.getAttributes().put(vm1, "hotDirtyDuration", 2);
    mo.getAttributes().put(vm1, "coldDirtyRate", 22.6);
    // 7.5 GiB
    mo.getAttributes().put(vm2, "memUsed", 7500);
    mo.getAttributes().put(vm2, "hotDirtySize", 56);
    mo.getAttributes().put(vm2, "hotDirtyDuration", 2);
    mo.getAttributes().put(vm2, "coldDirtyRate", 22.6);
    // Add placement constraints: we want to shutdown the source nodes to force VMs migration to destination nodes
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(new Offline(srcNode1));
    cstrs.add(new Offline(srcNode2));
    // Try to solve as is and show the computed plan
    ReconfigurationPlan p = new DefaultChocoScheduler().solve(mo, cstrs);
    System.out.println(p);
    // Set a default network view and try to solve again
    // connect nodes to a non-blocking switch using 1 Gbit/s links
    Network net = Network.createDefaultNetwork(mo);
    p = new DefaultChocoScheduler().solve(mo, cstrs);
    System.out.println(p);
    // Create and attach a custom network view and try to solve again
    mo.detach(net);
    net = new Network();
    // Connect the nodes through a main non-blocking switch
    // The source nodes are connected with 1Gbit/sec. links while the destination node has 10Gbit/sec. link.
    Switch swMain = net.newSwitch();
    net.connect(1000, swMain, srcNode1, srcNode2);
    net.connect(10000, swMain, dstNode);
    mo.attach(net);
    p = new DefaultChocoScheduler().solve(mo, cstrs);
    System.out.println(p);
    System.out.flush();
}
Also used : SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Offline(org.btrplace.model.constraint.Offline) Switch(org.btrplace.model.view.network.Switch) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Network(org.btrplace.model.view.network.Network)

Example 63 with DefaultChocoScheduler

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

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

Example 65 with DefaultChocoScheduler

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

the class CGatherTest method testContinuousWithRelocationOfVMs.

/**
 * We try to relocate co-located VMs in continuous mode. Not allowed
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testContinuousWithRelocationOfVMs() 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().on(n1, n2).run(n2, vm1, vm2);
    Gather g = new Gather(map.getAllVMs());
    g.setContinuous(true);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Running.newRunning(map.getAllVMs()));
    cstrs.add(g);
    cstrs.add(new Fence(vm1, Collections.singleton(n1)));
    cstrs.add(new Fence(vm2, Collections.singleton(n1)));
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(mo, cstrs);
    Assert.assertNull(plan);
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) 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