Search in sources :

Example 26 with Fence

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

the class CSpreadTest method testContinuous.

@Test
public void testContinuous() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2);
    List<SatConstraint> cstr = new ArrayList<>();
    ChocoScheduler cra = new DefaultChocoScheduler();
    cstr.add(new Spread(mo.getMapping().getAllVMs(), true));
    cstr.addAll(Online.newOnline(mo.getMapping().getAllNodes()));
    cstr.add(new Fence(vm1, Collections.singleton(n2)));
    ReconfigurationPlan p = cra.solve(mo, cstr);
    Assert.assertNotNull(p);
    System.err.println(p);
    Mapping res = p.getResult().getMapping();
    Assert.assertEquals(2, p.getSize());
    Assert.assertNotSame(res.getVMLocation(vm1), res.getVMLocation(vm2));
}
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) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Spread(org.btrplace.model.constraint.Spread) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Example 27 with Fence

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

the class CSpreadTest method testSeparateWithContinuous.

/**
 * 2 VMs are already hosted on a same node, check
 * if separation is working in continuous mode
 */
@Test
public void testSeparateWithContinuous() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    mo.getMapping().on(n1, n2).run(n1, vm1, vm2);
    List<SatConstraint> cstr = new ArrayList<>();
    ChocoScheduler cra = new DefaultChocoScheduler();
    Spread s = new Spread(mo.getMapping().getAllVMs());
    s.setContinuous(true);
    cstr.add(s);
    cstr.addAll(Online.newOnline(mo.getMapping().getAllNodes()));
    cstr.add(new Fence(vm1, Collections.singleton(n2)));
    ReconfigurationPlan p = cra.solve(mo, cstr);
    Assert.assertNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Spread(org.btrplace.model.constraint.Spread) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) 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) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Example 28 with Fence

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

the class CResourceCapacityTest method testSingleContinuousSolvable.

@Test
public void testSingleContinuousSolvable() 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();
    Mapping map = mo.getMapping().on(n1, n2).run(n1, vm1, vm2).ready(vm4);
    ShareableResource rc = new ShareableResource("cpu", 5, 5);
    rc.setConsumption(vm1, 3);
    rc.setConsumption(vm2, 1);
    rc.setConsumption(vm3, 1);
    rc.setConsumption(vm4, 3);
    mo.attach(rc);
    List<SatConstraint> cstrs = new ArrayList<>();
    ResourceCapacity s = new ResourceCapacity(n1, "cpu", 4);
    s.setContinuous(true);
    cstrs.add(s);
    cstrs.add(new Fence(vm4, Collections.singleton(n1)));
    cstrs.add(new Running(vm4));
    cstrs.addAll(Overbook.newOverbooks(map.getAllNodes(), "cpu", 1));
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
    Assert.assertEquals(p.getSize(), 2);
}
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) ResourceCapacity(org.btrplace.model.constraint.ResourceCapacity) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Running(org.btrplace.model.constraint.Running) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Example 29 with Fence

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

the class CResourceCapacityTest method testFeasibleContinuousResolution.

@Test
public void testFeasibleContinuousResolution() 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();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm2).run(n2, vm3, vm4).ready(vm5);
    Set<Node> on = new HashSet<>(Arrays.asList(n1, n2));
    ShareableResource rc = new ShareableResource("cpu", 5, 5);
    rc.setConsumption(vm1, 2);
    rc.setConsumption(vm2, 3);
    rc.setConsumption(vm3, 3);
    rc.setConsumption(vm4, 1);
    rc.setConsumption(vm5, 5);
    mo.attach(rc);
    List<SatConstraint> l = new ArrayList<>();
    l.add(new Running(vm5));
    l.add(new Fence(vm5, Collections.singleton(n1)));
    ResourceCapacity x = new ResourceCapacity(on, "cpu", 10);
    x.setContinuous(true);
    l.add(x);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(mo, l);
    Assert.assertNotNull(plan);
    // System.out.println(plan);
    Assert.assertTrue(plan.getSize() > 0);
}
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) ResourceCapacity(org.btrplace.model.constraint.ResourceCapacity) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Running(org.btrplace.model.constraint.Running) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 30 with Fence

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

the class CSplitAmongTest method testDiscreteWithGroupChange.

@Test
public void testDiscreteWithGroupChange() 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();
    VM vm6 = mo.newVM();
    VM vm7 = mo.newVM();
    VM vm8 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Node n4 = mo.newNode();
    Node n5 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3, n4, n5).run(n1, vm1, vm3).run(n2, vm2).run(n3, vm4, vm6).run(n4, vm5).run(n5, vm7);
    // Isolated VM not considered by the constraint
    map.addRunningVM(vm8, n1);
    Collection<VM> vg1 = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
    Collection<VM> vg2 = new HashSet<>(Arrays.asList(vm4, vm5, vm6));
    Collection<Node> pg1 = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> pg2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Node> pg3 = new HashSet<>(Collections.singletonList(n5));
    Collection<Collection<VM>> vgs = new HashSet<>(Arrays.asList(vg1, vg2));
    Collection<Collection<Node>> pgs = new HashSet<>(Arrays.asList(pg1, pg2, pg3));
    List<SatConstraint> cstrs = new ArrayList<>();
    SplitAmong s = new SplitAmong(vgs, pgs);
    s.setContinuous(false);
    // Move group of VMs 1 to the group of nodes 2. This is allowed
    // group of VMs 2 will move to another group of node so at the end, the constraint should be satisfied
    cstrs.add(s);
    for (VM v : vg1) {
        cstrs.add(new Fence(v, pg2));
    }
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(mo, cstrs);
    Assert.assertNotNull(plan);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SplitAmong(org.btrplace.model.constraint.SplitAmong) 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) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Collection(java.util.Collection) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

Fence (org.btrplace.model.constraint.Fence)30 Model (org.btrplace.model.Model)27 VM (org.btrplace.model.VM)27 SatConstraint (org.btrplace.model.constraint.SatConstraint)27 DefaultModel (org.btrplace.model.DefaultModel)26 Node (org.btrplace.model.Node)26 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)25 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)23 ArrayList (java.util.ArrayList)22 Test (org.testng.annotations.Test)22 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)19 Mapping (org.btrplace.model.Mapping)16 HashSet (java.util.HashSet)11 ShareableResource (org.btrplace.model.view.ShareableResource)10 Collection (java.util.Collection)7 Instance (org.btrplace.model.Instance)7 Offline (org.btrplace.model.constraint.Offline)7 Network (org.btrplace.model.view.network.Network)7 Switch (org.btrplace.model.view.network.Switch)6 SchedulerException (org.btrplace.scheduler.SchedulerException)6