Search in sources :

Example 46 with ReconfigurationPlan

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

the class SolverTuning method solve.

private static void solve(ChocoScheduler cra, Model model, Set<SatConstraint> constraints) {
    try {
        ReconfigurationPlan p = cra.solve(model, constraints);
        if (p != null) {
            System.out.println("\nReconfiguration plan:");
            System.out.println(p);
        }
    } finally {
        System.out.println("--- Solving using repair : " + cra.doRepair());
        System.out.println(cra.getStatistics());
    }
}
Also used : ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan)

Example 47 with ReconfigurationPlan

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

the class AdvancedMigScheduling method solve.

private static void solve(Model mo, List<SatConstraint> cstrs) {
    ReconfigurationPlan p = new DefaultChocoScheduler().solve(mo, cstrs);
    System.out.println(p);
    System.out.flush();
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan)

Example 48 with ReconfigurationPlan

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

the class StaticPartitioning method merge.

private ReconfigurationPlan merge(Instance i, Collection<SolvingStatistics> results) throws SplitException {
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(i.getModel());
    // Only if there is a solution
    for (SolvingStatistics result : results) {
        getStatistics().addPartitionStatistics(result);
        ReconfigurationPlan p = result.lastSolution();
        if (p == null) {
            return null;
        }
        for (Action a : p) {
            if (!plan.add(a)) {
                throw new SplitException(plan.getOrigin(), "Unable to add action '" + a + "' while merging the sub-plans");
            }
        }
    }
    return plan;
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) Action(org.btrplace.plan.event.Action) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) SolvingStatistics(org.btrplace.scheduler.choco.runner.SolvingStatistics)

Example 49 with ReconfigurationPlan

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

the class FixedNodeSetsPartitioningTest method testSplit.

@Test
public void testSplit() throws SchedulerException {
    Instance origin = makeInstance();
    List<Collection<Node>> parts = splitIn(origin.getModel().getMapping().getAllNodes(), 3);
    FixedNodeSetsPartitioning f = new FixedNodeSetsPartitioning(parts);
    f.setWorkersCount(3);
    List<Instance> subs = f.split(new DefaultParameters(), origin);
    // Check disjoint set of ready VMs
    Set<VM> allReady = new HashSet<>();
    for (Instance i : subs) {
        allReady.addAll(i.getModel().getMapping().getReadyVMs());
    }
    Assert.assertEquals(allReady.size(), 30);
    // Quick solve
    DefaultChocoScheduler cra = new DefaultChocoScheduler();
    cra.setInstanceSolver(f);
    ReconfigurationPlan plan = cra.solve(origin);
    // all the VMs to launch have been booted
    Assert.assertEquals(plan.getSize(), 30);
    System.out.println(cra.getStatistics());
    System.out.flush();
}
Also used : DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Test(org.testng.annotations.Test)

Example 50 with ReconfigurationPlan

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

the class FixedSizePartitioningTest method testRandomSplit.

@Test
public void testRandomSplit() throws SchedulerException {
    Instance origin = makeInstance();
    FixedSizePartitioning f = new FixedSizePartitioning(5);
    f.randomPickUp(true);
    Assert.assertEquals(f.randomPickUp(), true);
    List<Instance> l1 = f.split(params, origin);
    Assert.assertEquals(l1.size(), 3);
    checkCorrectness(l1);
    List<Instance> l2 = f.split(params, origin);
    Assert.assertEquals(l2.size(), 3);
    checkCorrectness(l2);
    /*      //Just check the list of nodes are different
        for (int i = 0; i < l1.size(); i++) {
            for (int j = 0; j < l2.size(); j++) {
                Assert.assertFalse(l1.get(i).getModel().getMapping().getAllNodes().equals(
                        l2.get(j).getModel().getMapping().getAllNodes()), "l1:" + l1.get(i).getModel().getMapping().getAllNodes()
                                                                        + " l2:" + l2.get(i).getModel().getMapping().getAllNodes());
            }
        }*/
    // Get a solution, the ready VMs must have been launched
    ReconfigurationPlan plan = f.solve(params, origin);
    Assert.assertEquals(plan.getSize(), 5);
}
Also used : 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