Search in sources :

Example 21 with SatConstraint

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

the class RelocatableVMTest method testReinstantiationWithPreserve.

@Test
public void testReinstantiationWithPreserve() throws SchedulerException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    VM vm5 = mo.newVM();
    VM vm6 = mo.newVM();
    VM vm7 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addRunningVM(vm5, n1);
    map.addRunningVM(vm6, n1);
    map.addRunningVM(vm7, n2);
    ShareableResource rc = new ShareableResource("cpu", 10, 10);
    rc.setCapacity(n1, 7);
    rc.setConsumption(vm5, 3);
    rc.setConsumption(vm6, 3);
    rc.setConsumption(vm7, 5);
    for (VM vm : map.getAllVMs()) {
        mo.getAttributes().put(vm, "template", "small");
        mo.getAttributes().put(vm, "clone", true);
    }
    Preserve pr = new Preserve(vm5, "cpu", 5);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.getDurationEvaluators().register(MigrateVM.class, new ConstantActionDuration<>(20));
    mo.attach(rc);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Online.newOnline(map.getAllNodes()));
    cstrs.add(pr);
    cra.doOptimize(true);
    try {
        ReconfigurationPlan p = cra.solve(mo, cstrs);
        Assert.assertNotNull(p);
    } catch (SchedulerException e) {
        Assert.fail(e.getMessage(), e);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SchedulerException(org.btrplace.scheduler.SchedulerException) 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) ShareableResource(org.btrplace.model.view.ShareableResource) 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) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 22 with SatConstraint

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

the class RelocatableVMTest method testRelocateDueToPreserve.

@Test
public void testRelocateDueToPreserve() throws SchedulerException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    final VM vm1 = mo.newVM();
    final VM vm2 = mo.newVM();
    final VM vm3 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addRunningVM(vm1, n1);
    map.addRunningVM(vm2, n1);
    map.addRunningVM(vm3, n2);
    ShareableResource rc = new ShareableResource("cpu", 10, 10);
    rc.setCapacity(n1, 7);
    rc.setConsumption(vm1, 3);
    rc.setConsumption(vm2, 3);
    rc.setConsumption(vm3, 5);
    Preserve pr = new Preserve(vm1, "cpu", 5);
    ChocoScheduler cra = new DefaultChocoScheduler();
    mo.attach(rc);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Online.newOnline(map.getAllNodes()));
    cstrs.addAll(Overbook.newOverbooks(map.getAllNodes(), "cpu", 1));
    cstrs.add(pr);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
}
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) ShareableResource(org.btrplace.model.view.ShareableResource) 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) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 23 with SatConstraint

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

the class Decommissionning method run.

@Override
public void run() {
    int ratio = 1;
    int nbPCPUs = 4;
    int nbNodes = 2;
    // The current DC
    Model mo = new DefaultModel();
    for (int i = 0; i < nbNodes; i++) {
        Node n = mo.newNode();
        mo.getMapping().addOnlineNode(n);
        // 4 VMs per node
        for (int j = 0; j < ratio * nbPCPUs; j++) {
            VM v = mo.newVM();
            mo.getMapping().addRunningVM(v, n);
        }
    }
    // Resource allocation
    ShareableResource rc = new ShareableResource("cpu", 8, 1);
    mo.attach(rc);
    // The new DC
    for (int i = 0; i < nbNodes; i++) {
        Node n = mo.newNode();
        mo.getMapping().addOfflineNode(n);
        rc.setCapacity(n, 10);
    }
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Offline.newOffline(mo.getMapping().getOnlineNodes()));
    MaxOnline m = new MaxOnline(mo.getMapping().getAllNodes(), nbNodes + 1, true);
    cstrs.add(m);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.setMaxEnd(3);
    cra.setVerbosity(1);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    System.out.println(p);
    System.out.println(cra.getStatistics());
}
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) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) MaxOnline(org.btrplace.model.constraint.MaxOnline) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel)

Example 24 with SatConstraint

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

the class GettingStarted method makeConstraints.

/**
 * Declare some constraints.
 */
public List<SatConstraint> makeConstraints() {
    List<SatConstraint> cstrs = new ArrayList<>();
    // VM1 and VM2 must be running on distinct nodes
    cstrs.add(new Spread(new HashSet<>(Arrays.asList(vms.get(1), vms.get(2)))));
    // VM0 must have at least 3 virtual CPU dedicated to it
    cstrs.add(new Preserve(vms.get(0), "cpu", 3));
    // N3 must be set offline
    cstrs.add(new Offline(nodes.get(3)));
    // VM4 must be running, It asks for 3 cpu and 2 mem resources
    cstrs.add(new Running(vms.get(4)));
    cstrs.add(new Preserve(vms.get(4), "cpu", 3));
    cstrs.add(new Preserve(vms.get(4), "mem", 2));
    // VM3 must be turned off, i.e. set back to the ready state
    cstrs.add(new Ready(vms.get(3)));
    return cstrs;
}
Also used : Ready(org.btrplace.model.constraint.Ready) Spread(org.btrplace.model.constraint.Spread) SatConstraint(org.btrplace.model.constraint.SatConstraint) ArrayList(java.util.ArrayList) Running(org.btrplace.model.constraint.Running) Offline(org.btrplace.model.constraint.Offline) Preserve(org.btrplace.model.constraint.Preserve) HashSet(java.util.HashSet)

Example 25 with SatConstraint

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

the class GettingStarted method run.

@Override
public void run() {
    Model model = makeModel();
    List<SatConstraint> cstrs = makeConstraints();
    ChocoScheduler ra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = ra.solve(model, cstrs);
    if (plan != null) {
        System.out.println("Time-based plan:");
        System.out.println(new TimeBasedPlanApplier().toString(plan));
        System.out.println("\nDependency based plan:");
        System.out.println(new DependencyBasedPlanApplier().toString(plan));
    }
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) TimeBasedPlanApplier(org.btrplace.plan.TimeBasedPlanApplier) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) DependencyBasedPlanApplier(org.btrplace.plan.DependencyBasedPlanApplier) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel)

Aggregations

SatConstraint (org.btrplace.model.constraint.SatConstraint)111 DefaultModel (org.btrplace.model.DefaultModel)90 Test (org.testng.annotations.Test)82 VM (org.btrplace.model.VM)79 Node (org.btrplace.model.Node)77 Model (org.btrplace.model.Model)76 ArrayList (java.util.ArrayList)74 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)72 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)65 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)51 Mapping (org.btrplace.model.Mapping)50 ShareableResource (org.btrplace.model.view.ShareableResource)41 HashSet (java.util.HashSet)33 Fence (org.btrplace.model.constraint.Fence)27 Offline (org.btrplace.model.constraint.Offline)17 Preserve (org.btrplace.model.constraint.Preserve)16 MigrateVM (org.btrplace.plan.event.MigrateVM)15 ScriptBuilder (org.btrplace.btrpsl.ScriptBuilder)14 Instance (org.btrplace.model.Instance)14 Network (org.btrplace.model.view.network.Network)14