Search in sources :

Example 36 with SatConstraint

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

the class IssuesTest method testIssue176.

/**
 * Boot plenty of VMs.
 */
@Test
public void testIssue176() {
    Model mo = new DefaultModel();
    ShareableResource slots = new ShareableResource("slots");
    for (int i = 0; i < 4; i++) {
        final Node no = mo.newNode();
        mo.getMapping().on(no);
        slots.setCapacity(no, 100);
        for (int j = 0; j < 5; j++) {
            mo.getMapping().addRunningVM(mo.newVM(), no);
        }
    }
    // 95 VMs * nbNodes can be hosted.
    for (int i = 0; i < 95 * mo.getMapping().getNbNodes(); i++) {
        mo.getMapping().addReadyVM(mo.newVM());
    }
    final List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Running.newRunning(mo.getMapping().getReadyVMs()));
    final Instance ii = new Instance(mo, cstrs, new MinMigrations());
    ChocoScheduler sched = new DefaultChocoScheduler();
    Assert.assertNotNull(sched.solve(ii));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) ArrayList(java.util.ArrayList) MinMigrations(org.btrplace.model.constraint.MinMigrations) ShareableResource(org.btrplace.model.view.ShareableResource) OptConstraint(org.btrplace.model.constraint.OptConstraint) Constraint(org.chocosolver.solver.constraints.Constraint) SatConstraint(org.btrplace.model.constraint.SatConstraint) Test(org.testng.annotations.Test)

Example 37 with SatConstraint

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

the class CMaxOnlineTest method testSimpleContinuousCase.

@Test
public void testSimpleContinuousCase() throws SchedulerException {
    Model model = new DefaultModel();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    model.getMapping().addOnlineNode(n1);
    model.getMapping().addOfflineNode(n2);
    MaxOnline maxOnline = new MaxOnline(model.getMapping().getAllNodes(), 1, true);
    List<SatConstraint> constraints = new ArrayList<>();
    constraints.add(maxOnline);
    constraints.add(new Online(n2));
    ChocoScheduler cra = new DefaultChocoScheduler();
    // cra.setTimeLimit(5);
    cra.setMaxEnd(4);
    cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
    ReconfigurationPlan plan = cra.solve(model, constraints);
    Assert.assertNotNull(plan);
    Assert.assertTrue(maxOnline.isSatisfied(plan));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) MaxOnline(org.btrplace.model.constraint.MaxOnline) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Node(org.btrplace.model.Node) 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) Online(org.btrplace.model.constraint.Online) MaxOnline(org.btrplace.model.constraint.MaxOnline) Test(org.testng.annotations.Test)

Example 38 with SatConstraint

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

the class CMaxOnlineTest method testContinuousRestrictionSimpleCase.

@Test
public void testContinuousRestrictionSimpleCase() throws SchedulerException {
    Model model = new DefaultModel();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    Node n3 = model.newNode();
    VM vm1 = model.newVM();
    VM vm3 = model.newVM();
    VM vm4 = model.newVM();
    ShareableResource resources = new ShareableResource("cpu", 4, 1);
    resources.setCapacity(n1, 8);
    resources.setConsumption(vm4, 2);
    Mapping map = model.getMapping().on(n1, n3).off(n2).run(n1, vm1, vm4).run(n3, vm3);
    MappingUtils.fill(map, model.getMapping());
    model.attach(resources);
    MaxOnline maxon = new MaxOnline(map.getAllNodes(), 2, true);
    List<SatConstraint> constraints = new ArrayList<>();
    constraints.add(maxon);
    constraints.add(new Online(n2));
    ChocoScheduler cra = new DefaultChocoScheduler();
    // cra.setTimeLimit(3);
    cra.setMaxEnd(3);
    cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
    ReconfigurationPlan plan = cra.solve(model, constraints);
    Assert.assertNotNull(plan);
    Assert.assertTrue(maxon.isSatisfied(plan));
}
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) 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) Online(org.btrplace.model.constraint.Online) MaxOnline(org.btrplace.model.constraint.MaxOnline) Test(org.testng.annotations.Test)

Example 39 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint 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 : 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) 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) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 40 with SatConstraint

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

the class COverbookTest method testBasic.

@Test
public void testBasic() throws SchedulerException {
    Node[] nodes = new Node[2];
    VM[] vms = new VM[3];
    Model mo = new DefaultModel();
    Mapping m = mo.getMapping();
    ShareableResource rcCPU = new ShareableResource("cpu");
    for (int i = 0; i < vms.length; i++) {
        if (i < nodes.length) {
            nodes[i] = mo.newNode();
            rcCPU.setCapacity(nodes[i], 2);
            m.addOnlineNode(nodes[i]);
        }
        vms[i] = mo.newVM();
        rcCPU.setConsumption(vms[i], 1);
        m.addReadyVM(vms[i]);
    }
    mo.attach(rcCPU);
    Overbook o = new Overbook(nodes[0], "cpu", 2);
    Overbook o2 = new Overbook(nodes[1], "cpu", 2);
    Collection<SatConstraint> c = new HashSet<>();
    c.add(o);
    c.add(o2);
    c.addAll(Running.newRunning(m.getAllVMs()));
    c.add(new Preserve(vms[0], "cpu", 1));
    c.addAll(Online.newOnline(m.getAllNodes()));
    DefaultChocoScheduler cra = new DefaultChocoScheduler();
    cra.getMapper().mapConstraint(Overbook.class, COverbook.class);
    ReconfigurationPlan p = cra.solve(mo, c);
    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) Mapping(org.btrplace.model.Mapping) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) Preserve(org.btrplace.model.constraint.Preserve) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) BootVM(org.btrplace.plan.event.BootVM) VM(org.btrplace.model.VM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Overbook(org.btrplace.model.constraint.Overbook) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

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