Search in sources :

Example 36 with MinMTTR

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

the class CLonelyTest method testWithNonPersistingVMs.

@Test
public void testWithNonPersistingVMs() {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).ready(vm1, vm2);
    Set<VM> mine = new HashSet<>(Arrays.asList(vm1, vm2));
    Lonely l = new Lonely(mine);
    Instance i = new Instance(mo, Collections.singleton(l), new MinMTTR());
    ChocoScheduler cra = new DefaultChocoScheduler();
    Assert.assertNotNull(cra.solve(i));
    Assert.assertEquals(cra.getStatistics().lastSolution().getSize(), 0);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Lonely(org.btrplace.model.constraint.Lonely) MinMTTR(org.btrplace.model.constraint.MinMTTR) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 37 with MinMTTR

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

the class CAmongTest method testGetMisplaced.

@Test
public void testGetMisplaced() {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    VM vm5 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Node n4 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3, n4).run(n1, vm1).run(n2, vm2, vm3).ready(vm4, vm5);
    Set<VM> vms = new HashSet<>(Arrays.asList(vm1, vm2, vm5));
    Collection<Node> s1 = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> s2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Collection<Node>> pGrps = new HashSet<>(Arrays.asList(s1, s2));
    Among a = new Among(vms, pGrps);
    CAmong ca = new CAmong(a);
    Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
    Assert.assertEquals(ca.getMisPlacedVMs(i), Collections.emptySet());
    map.addRunningVM(vm5, n3);
    Assert.assertEquals(ca.getMisPlacedVMs(i), vms);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) MinMTTR(org.btrplace.model.constraint.MinMTTR) Mapping(org.btrplace.model.Mapping) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Collection(java.util.Collection) Among(org.btrplace.model.constraint.Among) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 38 with MinMTTR

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

the class COfflineTest method testGetMisplacedAndSatisfied.

@Test
public void testGetMisplacedAndSatisfied() {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2);
    Offline off = new Offline(n1);
    COffline coff = new COffline(off);
    Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
    Assert.assertTrue(coff.getMisPlacedVMs(i).isEmpty());
    map.addRunningVM(vm1, n1);
    Assert.assertEquals(coff.getMisPlacedVMs(i), map.getAllVMs());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR) Offline(org.btrplace.model.constraint.Offline) Mapping(org.btrplace.model.Mapping) Test(org.testng.annotations.Test)

Example 39 with MinMTTR

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

the class FixedSizePartitioningTest method makeInstance.

private static Instance makeInstance() {
    Model mo = new DefaultModel();
    for (int i = 0; i < 13; i++) {
        Node n = mo.newNode();
        mo.getMapping().addOnlineNode(n);
        for (int j = 0; j < 3; j++) {
            VM v = mo.newVM();
            mo.getMapping().addRunningVM(v, n);
        }
    }
    for (int i = 0; i < 5; i++) {
        mo.getMapping().addReadyVM(mo.newVM());
    }
    return new Instance(mo, Running.newRunning(mo.getMapping().getAllVMs()), new MinMTTR());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR)

Example 40 with MinMTTR

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

the class StaticPartitioningTest method testParallelSolve.

@Test
public void testParallelSolve() throws SchedulerException {
    SynchronizedElementBuilder eb = new SynchronizedElementBuilder(new DefaultElementBuilder());
    Model origin = new DefaultModel(eb);
    Node n1 = origin.newNode();
    Node n2 = origin.newNode();
    VM vm1 = origin.newVM();
    VM vm2 = origin.newVM();
    /*
         * 2 nodes among 2 instances, 2 VMs to boot on the nodes
         */
    origin.getMapping().addOnlineNode(n1);
    origin.getMapping().addOfflineNode(n2);
    origin.getMapping().addReadyVM(vm1);
    origin.getMapping().addReadyVM(vm2);
    Model s1 = new SubModel(origin, eb, Collections.singletonList(n1), Collections.singleton(vm1));
    Model s2 = new SubModel(origin, eb, Collections.singletonList(n2), Collections.singleton(vm2));
    Instance i0 = new Instance(origin, new MinMTTR());
    final Instance i1 = new Instance(s1, Running.newRunning(Collections.singletonList(vm1)), new MinMTTR());
    final Instance i2 = new Instance(s2, new MinMTTR());
    i2.getSatConstraints().add(new Running(vm2));
    StaticPartitioning st = new StaticPartitioning() {

        @Override
        public List<Instance> split(Parameters ps, Instance i) throws SchedulerException {
            return Arrays.asList(i1, i2);
        }
    };
    Parameters p = new DefaultChocoScheduler();
    ReconfigurationPlan plan = st.solve(p, i0);
    Assert.assertNotNull(plan);
    Model dst = plan.getResult();
    Assert.assertEquals(dst.getMapping().getOnlineNodes().size(), 2);
    Assert.assertEquals(dst.getMapping().getRunningVMs().size(), 2);
    // Now, there is no solution for i2. the resulting plan should be null
    i2.getSatConstraints().addAll(Offline.newOffline(n2));
    plan = st.solve(p, i0);
    Assert.assertNull(plan);
    Assert.assertEquals(st.getStatistics().getSolutions().size(), 0);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Parameters(org.btrplace.scheduler.choco.Parameters) Instance(org.btrplace.model.Instance) DefaultElementBuilder(org.btrplace.model.DefaultElementBuilder) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) MinMTTR(org.btrplace.model.constraint.MinMTTR) SubModel(org.btrplace.scheduler.runner.disjoint.model.SubModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) SubModel(org.btrplace.scheduler.runner.disjoint.model.SubModel) DefaultModel(org.btrplace.model.DefaultModel) Running(org.btrplace.model.constraint.Running) SynchronizedElementBuilder(org.btrplace.model.SynchronizedElementBuilder) Test(org.testng.annotations.Test)

Aggregations

MinMTTR (org.btrplace.model.constraint.MinMTTR)47 Model (org.btrplace.model.Model)42 Instance (org.btrplace.model.Instance)41 Test (org.testng.annotations.Test)41 DefaultModel (org.btrplace.model.DefaultModel)40 Node (org.btrplace.model.Node)33 VM (org.btrplace.model.VM)33 ArrayList (java.util.ArrayList)22 HashSet (java.util.HashSet)22 TIntIntHashMap (gnu.trove.map.hash.TIntIntHashMap)15 SatConstraint (org.btrplace.model.constraint.SatConstraint)10 Mapping (org.btrplace.model.Mapping)9 Running (org.btrplace.model.constraint.Running)8 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)8 Collection (java.util.Collection)6 Offline (org.btrplace.model.constraint.Offline)5 ShareableResource (org.btrplace.model.view.ShareableResource)5 Spread (org.btrplace.model.constraint.Spread)4 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)4 Ban (org.btrplace.model.constraint.Ban)3