Search in sources :

Example 21 with DefaultReconfigurationPlan

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

the class SpreadTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 4);
    List<VM> vms = Util.newVMs(mo, 4);
    Mapping map = mo.getMapping();
    map.addOnlineNode(ns.get(0));
    map.addOnlineNode(ns.get(1));
    map.addOnlineNode(ns.get(2));
    map.addOnlineNode(ns.get(3));
    map.addRunningVM(vms.get(0), ns.get(0));
    map.addRunningVM(vms.get(1), ns.get(1));
    Spread s = new Spread(map.getAllVMs());
    ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
    Assert.assertEquals(s.isSatisfied(p), true);
    MigrateVM m1 = new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 1, 2);
    p.add(m1);
    Assert.assertEquals(s.isSatisfied(p), false);
    // No overlapping at moment 1
    MigrateVM m2 = new MigrateVM(vms.get(1), ns.get(1), ns.get(2), 0, 1);
    p.add(m2);
    Assert.assertEquals(s.isSatisfied(p), true);
    map.addRunningVM(vms.get(2), ns.get(1));
    s = new Spread(map.getAllVMs());
    p = new DefaultReconfigurationPlan(mo);
    System.out.println(p.getOrigin() + "\n" + p.getResult());
    Assert.assertEquals(s.isSatisfied(p), false);
    p.add(new MigrateVM(vms.get(2), ns.get(1), ns.get(2), 0, 5));
    Assert.assertEquals(s.isSatisfied(p), true);
}
Also used : DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) Test(org.testng.annotations.Test)

Example 22 with DefaultReconfigurationPlan

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

the class ReconfigurationPlanFuzzer method get.

@Override
public ReconfigurationPlan get() {
    Model mo = new DefaultModel();
    ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
    for (int i = 0; i < nbNodes; i++) {
        Node n = mo.newNode();
        addNode(n, p);
    }
    for (int i = 0; i < nbVMs; i++) {
        addVM(mo.newVM(), p);
    }
    exts.forEach(d -> d.decorate(p));
    return p;
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel)

Example 23 with DefaultReconfigurationPlan

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

the class SolutionStatisticsTest method test.

@Test
public void test() {
    Metrics m = new Metrics();
    ReconfigurationPlan p = new DefaultReconfigurationPlan(new DefaultModel());
    SolutionStatistics st = new SolutionStatistics(m, p);
    Assert.assertFalse(st.hasObjective());
    st.setObjective(12);
    Assert.assertEquals(st.getMetrics(), m);
    Assert.assertEquals(st.getReconfigurationPlan(), p);
    Assert.assertTrue(st.hasObjective());
    Assert.assertEquals(st.objective(), 12);
    System.out.println(st);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Test(org.testng.annotations.Test)

Example 24 with DefaultReconfigurationPlan

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

the class SingleRunnerStatisticsTest method testInstantiate.

@Test
public void testInstantiate() {
    Parameters ps = new DefaultParameters();
    Model mo = new DefaultModel();
    long st = System.currentTimeMillis();
    List<SatConstraint> cstrs = new ArrayList<>();
    Instance i = new Instance(mo, cstrs, new MinMTTR());
    SingleRunnerStatistics stats = new SingleRunnerStatistics(ps, i, st);
    Assert.assertEquals(stats.getStart(), st);
    Assert.assertEquals(stats.getCoreBuildDuration(), -1);
    Assert.assertEquals(stats.getSpecializationDuration(), -1);
    Assert.assertEquals(stats.getInstance(), i);
    Assert.assertEquals(stats.getNbManagedVMs(), -1);
    Assert.assertEquals(stats.getParameters(), ps);
    Assert.assertEquals(stats.getSolutions().size(), 0);
    Assert.assertEquals(stats.completed(), false);
    Assert.assertEquals(stats.getMetrics(), null);
    stats.setCoreBuildDuration(12);
    stats.setSpecialisationDuration(17);
    stats.setNbManagedVMs(18);
    stats.setCompleted(true);
    Assert.assertEquals(stats.getCoreBuildDuration(), 12);
    Assert.assertEquals(stats.getSpecializationDuration(), 17);
    Assert.assertEquals(stats.getNbManagedVMs(), 18);
    Assert.assertEquals(stats.completed(), true);
    ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
    SolutionStatistics sol = new SolutionStatistics(new Metrics(), plan);
    stats.addSolution(sol);
    Assert.assertEquals(stats.getSolutions().size(), 1);
    Assert.assertEquals(stats.getSolutions().get(0), sol);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) Instance(org.btrplace.model.Instance) SatConstraint(org.btrplace.model.constraint.SatConstraint) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) SolutionStatistics(org.btrplace.scheduler.choco.runner.SolutionStatistics) ArrayList(java.util.ArrayList) MinMTTR(org.btrplace.model.constraint.MinMTTR) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) Metrics(org.btrplace.scheduler.choco.runner.Metrics) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Aggregations

DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)24 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)24 Test (org.testng.annotations.Test)21 MigrateVM (org.btrplace.plan.event.MigrateVM)12 ShutdownVM (org.btrplace.plan.event.ShutdownVM)6 HashSet (java.util.HashSet)4 DefaultModel (org.btrplace.model.DefaultModel)4 Model (org.btrplace.model.Model)4 BootVM (org.btrplace.plan.event.BootVM)4 ShareableResource (org.btrplace.model.view.ShareableResource)3 Allocate (org.btrplace.plan.event.Allocate)3 BootNode (org.btrplace.plan.event.BootNode)3 ShutdownNode (org.btrplace.plan.event.ShutdownNode)3 Node (org.btrplace.model.Node)2 Action (org.btrplace.plan.event.Action)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Instance (org.btrplace.model.Instance)1 Mapping (org.btrplace.model.Mapping)1 MinMTTR (org.btrplace.model.constraint.MinMTTR)1