Search in sources :

Example 21 with DefaultParameters

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

the class FixedNodeSetsPartitioningTest method testSplitWithUnsplittableConstraint.

@Test(expectedExceptions = { SchedulerException.class })
public void testSplitWithUnsplittableConstraint() throws SchedulerException {
    Instance orig = makeInstance();
    orig.getSatConstraints().add(new MaxOnline(orig.getModel().getMapping().getAllNodes(), 5));
    List<Collection<Node>> parts = splitIn(orig.getModel().getMapping().getAllNodes(), 3);
    FixedNodeSetsPartitioning f = new FixedNodeSetsPartitioning(parts);
    f.split(new DefaultParameters(), orig);
}
Also used : DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) MaxOnline(org.btrplace.model.constraint.MaxOnline) Test(org.testng.annotations.Test)

Example 22 with DefaultParameters

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

the class AmongSplitterTest method testSplittable.

@Test
public void testSplittable() throws SchedulerException {
    List<VM> vms = Arrays.asList(vm1, vm2, vm3);
    Collection<Collection<Node>> parts = new ArrayList<>();
    parts.add(Arrays.asList(n1, n2));
    parts.add(Collections.singletonList(n3));
    parts.add(Collections.singletonList(n4));
    Among single = new Among(vms, parts);
    /*
         N1 v1 v2
         N2 v3
         ---
         N3 v4
         --
         N4 v5
         */
    FixedNodeSetsPartitioning partitionner = new FixedNodeSetsPartitioning(parts);
    partitionner.setPartitions(parts);
    List<Instance> instances = partitionner.split(new DefaultParameters(), new Instance(mo, Collections.emptyList(), new MinMTTR()));
    TIntIntHashMap vmIndex = Instances.makeVMIndex(instances);
    TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
    splitter.split(single, new Instance(mo, new MinMTTR()), instances, vmIndex, nodeIndex);
    Among a = (Among) instances.get(0).getSatConstraints().iterator().next();
    Assert.assertEquals(a.getGroupsOfNodes().size(), 1);
    Assert.assertEquals(a.getInvolvedNodes(), Arrays.asList(n1, n2));
    for (Instance i : instances) {
        System.out.println(i.getSatConstraints());
    }
}
Also used : FixedNodeSetsPartitioning(org.btrplace.scheduler.runner.disjoint.FixedNodeSetsPartitioning) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) MinMTTR(org.btrplace.model.constraint.MinMTTR) Among(org.btrplace.model.constraint.Among) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) Test(org.testng.annotations.Test)

Example 23 with DefaultParameters

use of org.btrplace.scheduler.choco.DefaultParameters 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)

Example 24 with DefaultParameters

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

the class BootVMTest method testBasics.

/**
 * Just boot a VM on a  node.
 */
@Test
public void testBasics() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    final VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addReadyVM(vm1);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(org.btrplace.plan.event.BootVM.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(new HashSet<>(), map.getAllVMs(), new HashSet<>(), new HashSet<>()).build();
    rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
    rp.getNodeActions().get(1).getState().instantiateTo(1, Cause.Null);
    BootVM m = (BootVM) rp.getVMActions().get(0);
    Assert.assertEquals(vm1, m.getVM());
    Assert.assertNull(m.getCSlice());
    Assert.assertTrue(m.getDuration().isInstantiatedTo(5));
    Assert.assertTrue(m.getState().isInstantiatedTo(1));
    Assert.assertFalse(m.getDSlice().getHoster().isInstantiated());
    Assert.assertFalse(m.getDSlice().getStart().isInstantiated());
    Assert.assertFalse(m.getDSlice().getEnd().isInstantiated());
    new CMinMTTR().inject(ps, rp);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    org.btrplace.plan.event.BootVM a = (org.btrplace.plan.event.BootVM) p.getActions().iterator().next();
    Node dest = rp.getNode(m.getDSlice().getHoster().getValue());
    Assert.assertEquals(vm1, a.getVM());
    Assert.assertEquals(dest, a.getDestinationNode());
    Assert.assertEquals(5, a.getEnd() - a.getStart());
}
Also used : Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 25 with DefaultParameters

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

the class ForgeVMTest method testWithoutTemplate.

@Test(expectedExceptions = { SchedulerException.class })
public void testWithoutTemplate() throws SchedulerException {
    Model mo = new DefaultModel();
    final VM vm1 = mo.newVM();
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(org.btrplace.plan.event.ForgeVM.class, new ConstantActionDuration<>(7));
    new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).build();
}
Also used : Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) Test(org.testng.annotations.Test)

Aggregations

DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)40 Test (org.testng.annotations.Test)35 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)32 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)30 Parameters (org.btrplace.scheduler.choco.Parameters)29 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)29 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)28 CMinMTTR (org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR)14 DefaultModel (org.btrplace.model.DefaultModel)11 Model (org.btrplace.model.Model)11 Node (org.btrplace.model.Node)10 ShutdownNode (org.btrplace.plan.event.ShutdownNode)10 HashSet (java.util.HashSet)9 Mapping (org.btrplace.model.Mapping)9 VM (org.btrplace.model.VM)9 BootNode (org.btrplace.plan.event.BootNode)9 Action (org.btrplace.plan.event.Action)8 MigrateVM (org.btrplace.plan.event.MigrateVM)8 ShareableResource (org.btrplace.model.view.ShareableResource)6 ArrayList (java.util.ArrayList)5