Search in sources :

Example 61 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan 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 : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) MaxOnline(org.btrplace.model.constraint.MaxOnline) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Online(org.btrplace.model.constraint.Online) MaxOnline(org.btrplace.model.constraint.MaxOnline) Test(org.testng.annotations.Test)

Example 62 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan 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 : SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) 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) Online(org.btrplace.model.constraint.Online) MaxOnline(org.btrplace.model.constraint.MaxOnline) Test(org.testng.annotations.Test)

Example 63 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class CNoDelayTest method testOk2.

@Test
public void testOk2() 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("cpu", 4, 1);
    resources.setCapacity(n2, 3);
    resources.setConsumption(vm1, 4);
    Mapping map = model.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2).run(n3, vm3).run(n3, vm4);
    MappingUtils.fill(map, model.getMapping());
    model.attach(resources);
    Ban b = new Ban(vm1, Collections.singleton(n1));
    NoDelay nd = new NoDelay(vm4);
    // 1 solution (priority to vm4): vm4 to n2 ; vm3 to n2 ; vm1 to n3
    List<SatConstraint> constraints = new ArrayList<>();
    constraints.add(nd);
    constraints.add(b);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
    ReconfigurationPlan plan = cra.solve(model, constraints);
    Assert.assertNotNull(plan);
    Assert.assertTrue(nd.isSatisfied(plan));
}
Also used : SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) ShareableResource(org.btrplace.model.view.ShareableResource) Ban(org.btrplace.model.constraint.Ban) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) NoDelay(org.btrplace.model.constraint.NoDelay) Test(org.testng.annotations.Test)

Example 64 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class COfflineTest method testUnsolvableProblem.

@Test
public void testUnsolvableProblem() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    mo.getMapping().on(n1).run(n1, vm1);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan plan = cra.solve(mo, Collections.singleton(new Offline(n1)));
    Assert.assertNull(plan);
    SolvingStatistics stats = cra.getStatistics();
    Assert.assertTrue(stats.completed());
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Offline(org.btrplace.model.constraint.Offline) SolvingStatistics(org.btrplace.scheduler.choco.runner.SolvingStatistics) Test(org.testng.annotations.Test)

Example 65 with ReconfigurationPlan

use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.

the class COfflineTest method simpleTest.

/**
 * Simple test, no VMs.
 */
@Test
public void simpleTest() throws SchedulerException {
    Model model = new DefaultModel();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    Mapping map = model.getMapping().on(n1, n2);
    DefaultChocoScheduler cra = new DefaultChocoScheduler();
    cra.getDurationEvaluators().register(ShutdownNode.class, new ConstantActionDuration<>(10));
    cra.setTimeLimit(-1);
    ReconfigurationPlan plan = cra.solve(model, Offline.newOffline(map.getAllNodes()));
    Assert.assertNotNull(plan);
    Assert.assertEquals(plan.getSize(), 2);
    Assert.assertEquals(plan.getDuration(), 10);
    Model res = plan.getResult();
    Assert.assertEquals(res.getMapping().getOfflineNodes().size(), 2);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Test(org.testng.annotations.Test)

Aggregations

ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)185 Test (org.testng.annotations.Test)160 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)94 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)74 SatConstraint (org.btrplace.model.constraint.SatConstraint)53 ShareableResource (org.btrplace.model.view.ShareableResource)52 Model (org.btrplace.model.Model)49 ArrayList (java.util.ArrayList)46 Node (org.btrplace.model.Node)45 DefaultModel (org.btrplace.model.DefaultModel)44 VM (org.btrplace.model.VM)41 MigrateVM (org.btrplace.plan.event.MigrateVM)37 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)34 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)32 Parameters (org.btrplace.scheduler.choco.Parameters)29 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)29 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)28 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)24 Mapping (org.btrplace.model.Mapping)23 HashSet (java.util.HashSet)22