Search in sources :

Example 6 with MinMigrations

use of org.btrplace.model.constraint.MinMigrations 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 7 with MinMigrations

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

the class CMinMigrationsTest method testNtnx.

@Test
public void testNtnx() {
    String root = "src/test/resources/min-migrations.json";
    Instance i = JSON.readInstance(new File(root));
    i = new Instance(i.getModel(), i.getSatConstraints(), new MinMigrations());
    ChocoScheduler s = new DefaultChocoScheduler();
    s.doOptimize(true);
    ReconfigurationPlan p = s.solve(i);
    Assert.assertNotNull(p);
    System.out.println(s.getStatistics());
    System.out.println(p);
    Assert.assertEquals(p.getActions().stream().filter(x -> x instanceof MigrateVM).count(), 1);
    Assert.assertEquals(3, p.getDuration());
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Instance(org.btrplace.model.Instance) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) MinMigrations(org.btrplace.model.constraint.MinMigrations) File(java.io.File) Test(org.testng.annotations.Test)

Example 8 with MinMigrations

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

the class SchedulerTest method testDefaultMethods.

@Test
public void testDefaultMethods() {
    final ReconfigurationPlan expected = new DefaultReconfigurationPlan(new DefaultModel());
    final Scheduler sched = i -> expected;
    final List<SatConstraint> cstrs = new ArrayList<>();
    final MinMigrations obj = new MinMigrations();
    Assert.assertEquals(expected, sched.solve(expected.getOrigin(), cstrs, obj));
    Assert.assertEquals(expected, sched.solve(expected.getOrigin(), cstrs));
}
Also used : List(java.util.List) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) Assert(org.testng.Assert) Test(org.testng.annotations.Test) MinMigrations(org.btrplace.model.constraint.MinMigrations) DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) DefaultModel(org.btrplace.model.DefaultModel) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) SatConstraint(org.btrplace.model.constraint.SatConstraint) ArrayList(java.util.ArrayList) MinMigrations(org.btrplace.model.constraint.MinMigrations) Test(org.testng.annotations.Test)

Aggregations

MinMigrations (org.btrplace.model.constraint.MinMigrations)8 Test (org.testng.annotations.Test)8 DefaultModel (org.btrplace.model.DefaultModel)6 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)6 Model (org.btrplace.model.Model)5 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)5 ArrayList (java.util.ArrayList)4 Instance (org.btrplace.model.Instance)4 Node (org.btrplace.model.Node)4 SatConstraint (org.btrplace.model.constraint.SatConstraint)4 ShareableResource (org.btrplace.model.view.ShareableResource)4 MigrateVM (org.btrplace.plan.event.MigrateVM)4 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)4 VM (org.btrplace.model.VM)3 File (java.io.File)2 List (java.util.List)2 OptConstraint (org.btrplace.model.constraint.OptConstraint)2 Preserve (org.btrplace.model.constraint.Preserve)2 Spread (org.btrplace.model.constraint.Spread)2 Constraint (org.chocosolver.solver.constraints.Constraint)2