Search in sources :

Example 1 with ChocoScheduler

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

the class CRunningCapacityTest 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));
    List<SatConstraint> l = new ArrayList<>();
    l.add(new Running(vm5));
    l.add(new Fence(vm5, Collections.singleton(n1)));
    org.btrplace.model.constraint.RunningCapacity x = new org.btrplace.model.constraint.RunningCapacity(on, 4);
    x.setContinuous(true);
    l.add(x);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.getDurationEvaluators().register(ShutdownVM.class, new ConstantActionDuration<>(10));
    ReconfigurationPlan plan = cra.solve(mo, l);
    Assert.assertNotNull(plan);
    Assert.assertEquals(plan.getSize(), 2);
}
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) BootVM(org.btrplace.plan.event.BootVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) org.btrplace.model.constraint(org.btrplace.model.constraint) org.btrplace.model(org.btrplace.model) Test(org.testng.annotations.Test)

Example 2 with ChocoScheduler

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

the class CAmongTest method testWithNoSolution.

/**
 * No solution because constraints force to spread the VMs among 2 groups.
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testWithNoSolution() 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> s = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> s2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Collection<Node>> pGrps = new HashSet<>(Arrays.asList(s, s2));
    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(new Fence(vm2, Collections.singleton(n3)));
    cstrs.add(new Fence(vm1, Collections.singleton(n1)));
    cstrs.add(a);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(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) 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) Among(org.btrplace.model.constraint.Among) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 3 with ChocoScheduler

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

the class CAmongTest method testWithGroupChange.

@Test
public void testWithGroupChange() 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 = Arrays.asList(s1, s2);
    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(new Fence(vm2, s2));
    cstrs.add(a);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
// System.out.println(p);
// Assert.assertEquals(a.isSatisfied(p.getResult()), SatConstraint.Sat.SATISFIED);
}
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) 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) Among(org.btrplace.model.constraint.Among) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 4 with ChocoScheduler

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

the class CAmongTest method testContinuousWithNotAlreadySatisfied.

@Test
public void testContinuousWithNotAlreadySatisfied() 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, 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(new Fence(vm2, Collections.singleton(n3)));
    cstrs.add(a);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(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) 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) Among(org.btrplace.model.constraint.Among) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 5 with ChocoScheduler

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

the class CFenceTest method testBasic.

@Test
public void testBasic() 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();
    Node n3 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm4).run(n2, vm2).run(n3, vm3);
    Set<Node> on = new HashSet<>(Arrays.asList(n1, n3));
    Fence f = new Fence(vm2, on);
    ChocoScheduler cra = new DefaultChocoScheduler();
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(f);
    cstrs.addAll(Online.newOnline(map.getAllNodes()));
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
    Assert.assertTrue(p.getSize() > 0);
    Assert.assertTrue(p.iterator().next() instanceof MigrateVM);
    // Assert.assertEquals(SatConstraint.Sat.SATISFIED, f.isSatisfied(p.getResult()));
    cstrs.add(new Ready(vm2));
    p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
    // Just the suspend of vm2
    Assert.assertEquals(1, p.getSize());
// Assert.assertEquals(SatConstraint.Sat.SATISFIED, f.isSatisfied(p.getResult()));
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) MigrateVM(org.btrplace.plan.event.MigrateVM) Test(org.testng.annotations.Test)

Aggregations

ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)86 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)86 Test (org.testng.annotations.Test)80 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)76 DefaultModel (org.btrplace.model.DefaultModel)66 Model (org.btrplace.model.Model)66 Node (org.btrplace.model.Node)64 VM (org.btrplace.model.VM)63 SatConstraint (org.btrplace.model.constraint.SatConstraint)52 ArrayList (java.util.ArrayList)47 Mapping (org.btrplace.model.Mapping)37 ShareableResource (org.btrplace.model.view.ShareableResource)32 Fence (org.btrplace.model.constraint.Fence)18 HashSet (java.util.HashSet)17 Preserve (org.btrplace.model.constraint.Preserve)12 ShutdownVM (org.btrplace.plan.event.ShutdownVM)12 Collection (java.util.Collection)11 MigrateVM (org.btrplace.plan.event.MigrateVM)10 Running (org.btrplace.model.constraint.Running)8 BootVM (org.btrplace.plan.event.BootVM)8