Search in sources :

Example 16 with MinMTTR

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

the class FixedNodeSetsPartitioningTest method makeInstance.

private Instance makeInstance() {
    Model mo = new DefaultModel();
    for (int i = 0; i < 20; i++) {
        Node n = mo.newNode();
        mo.getMapping().addOnlineNode(n);
        VM v = mo.newVM();
        // 1 VM per node is already running
        mo.getMapping().addRunningVM(v, n);
    }
    // 30 VMs to launch
    for (int i = 0; i < 30; i++) {
        VM v = mo.newVM();
        mo.getMapping().addReadyVM(v);
    }
    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 17 with MinMTTR

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

the class IssuesTest method testIssue89.

@Test
public static void testIssue89() throws Exception {
    final Model model = new DefaultModel();
    final Mapping mapping = model.getMapping();
    final Node node0 = model.newNode(0);
    final int[] ids0 = { 1, 45, 43, 40, 39, 38, 82, 80, 79, 78, 30, 75, 18, 16, 15, 14, 60, 9, 55, 54, 50, 48 };
    final Node node1 = model.newNode(1);
    final int[] ids1 = { 84, 83, 81, 77, 73, 71, 64, 63, 62, 57, 53, 52, 47, 46, 44, 41, 34, 31, 28, 25, 13, 8, 6, 4, 3, 0 };
    final Node node2 = model.newNode(2);
    final int[] ids2 = { 21, 67, 42, 36, 35, 33, 76, 74, 23, 69, 68, 20, 61, 12, 11, 10, 5, 51 };
    final Node node3 = model.newNode(3);
    final int[] ids3 = { 2, 66, 86, 85, 37, 32, 29, 27, 26, 72, 24, 70, 22, 19, 65, 17, 59, 58, 56, 7, 49 };
    final ShareableResource cpu = new ShareableResource("cpu", 45, 1);
    final ShareableResource mem = new ShareableResource("mem", 90, 2);
    populateNodeVm(model, mapping, node0, ids0);
    populateNodeVm(model, mapping, node1, ids1);
    populateNodeVm(model, mapping, node2, ids2);
    populateNodeVm(model, mapping, node3, ids3);
    model.attach(cpu);
    model.attach(mem);
    final Collection<SatConstraint> satConstraints = new ArrayList<>();
    // We want to cause Node 3 to go offline to see how the VMs hosted on that
    // node will get rebalanced.
    satConstraints.add(new Offline(node3));
    final OptConstraint optConstraint = new MinMTTR();
    DefaultChocoScheduler scheduler = new DefaultChocoScheduler();
    scheduler.doOptimize(false);
    scheduler.doRepair(true);
    scheduler.setTimeLimit(60000);
    ReconfigurationPlan plan = scheduler.solve(model, satConstraints, optConstraint);
    System.out.println(scheduler.getStatistics());
    Assert.assertTrue(plan.isApplyable());
    satConstraints.clear();
    // This is somewhat similar to making Node 3 going offline by ensuring that
    // all VMs can no longer get hosted on that node.
    satConstraints.addAll(mapping.getAllVMs().stream().map(vm -> new Ban(vm, Collections.singletonList(node3))).collect(Collectors.toList()));
    scheduler = new DefaultChocoScheduler();
    scheduler.doOptimize(false);
    scheduler.doRepair(true);
    plan = scheduler.solve(model, satConstraints, optConstraint);
    Assert.assertTrue(plan.isApplyable());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) MinMTTR(org.btrplace.model.constraint.MinMTTR) CMinMTTR(org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR) Offline(org.btrplace.model.constraint.Offline) Mapping(org.btrplace.model.Mapping) ShareableResource(org.btrplace.model.view.ShareableResource) Ban(org.btrplace.model.constraint.Ban) OptConstraint(org.btrplace.model.constraint.OptConstraint) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 18 with MinMTTR

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

the class COverbookTest method testGetMisplaced.

@Test
public void testGetMisplaced() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    VM vm5 = mo.newVM();
    VM vm6 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2, vm3).run(n3, vm4, vm5, vm6);
    ShareableResource rcCPU = new ShareableResource("cpu", 1, 1);
    mo.attach(rcCPU);
    Overbook o1 = new Overbook(n1, "cpu", 1);
    Overbook o2 = new Overbook(n2, "cpu", 2);
    Overbook o3 = new Overbook(n3, "cpu", 3);
    COverbook co1 = new COverbook(o1);
    COverbook co2 = new COverbook(o2);
    COverbook co3 = new COverbook(o3);
    Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
    Assert.assertTrue(co1.getMisPlacedVMs(i).isEmpty());
    Assert.assertTrue(co2.getMisPlacedVMs(i).isEmpty());
    Assert.assertEquals(o3.getInvolvedVMs(), co3.getMisPlacedVMs(i));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) BootVM(org.btrplace.plan.event.BootVM) VM(org.btrplace.model.VM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Node(org.btrplace.model.Node) Overbook(org.btrplace.model.constraint.Overbook) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 19 with MinMTTR

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

the class CSleepingTest method testGetMisplaced.

@Test
public void testGetMisplaced() {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    Node n1 = mo.newNode();
    mo.getMapping().on(n1).ready(vm1).run(n1, vm2).sleep(n1, vm3);
    Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
    CSleeping k = new CSleeping(new Sleeping(vm3));
    Assert.assertEquals(0, k.getMisPlacedVMs(i).size());
    k = new CSleeping(new Sleeping(vm1));
    Assert.assertEquals(1, k.getMisPlacedVMs(i).size());
    Assert.assertTrue(k.getMisPlacedVMs(i).contains(vm1));
    k = new CSleeping(new Sleeping(vm3));
    Assert.assertEquals(0, k.getMisPlacedVMs(i).size());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Sleeping(org.btrplace.model.constraint.Sleeping) Instance(org.btrplace.model.Instance) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR) Test(org.testng.annotations.Test)

Example 20 with MinMTTR

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

the class CSplitAmongTest 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();
    VM vm6 = mo.newVM();
    VM vm7 = mo.newVM();
    VM vm8 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    Node n4 = mo.newNode();
    Node n5 = mo.newNode();
    Mapping map = mo.getMapping().on(n1, n2, n3, n4, n5).run(n1, vm1, vm3).run(n2, vm2).run(n3, vm4, vm6).run(n4, vm5).run(n5, vm7);
    // Isolated VM not considered by the constraint
    map.addRunningVM(vm8, n1);
    Collection<VM> vg1 = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
    Collection<VM> vg2 = new HashSet<>(Arrays.asList(vm4, vm5, vm6));
    Collection<VM> vg3 = new HashSet<>(Collections.singletonList(vm7));
    Collection<Node> pg1 = new HashSet<>(Arrays.asList(n1, n2));
    Collection<Node> pg2 = new HashSet<>(Arrays.asList(n3, n4));
    Collection<Node> pg3 = new HashSet<>(Collections.singletonList(n5));
    Collection<Collection<VM>> vgs = new HashSet<>(Arrays.asList(vg1, vg2, vg3));
    Collection<Collection<Node>> pgs = new HashSet<>(Arrays.asList(pg1, pg2, pg3));
    SplitAmong s = new SplitAmong(vgs, pgs);
    CSplitAmong cs = new CSplitAmong(s);
    Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
    Assert.assertTrue(cs.getMisPlacedVMs(i).isEmpty());
    map.remove(vm7);
    map.addRunningVM(vm6, n5);
    // vg2 is on 2 group of nodes, the whole group is mis-placed
    Assert.assertEquals(cs.getMisPlacedVMs(i), vg2);
    map.addRunningVM(vm7, n5);
    // vg1 and vg2 overlap on n1. The two groups are mis-placed
    map.addRunningVM(vm6, n2);
    Assert.assertTrue(cs.getMisPlacedVMs(i).containsAll(vg1));
    Assert.assertTrue(cs.getMisPlacedVMs(i).containsAll(vg2));
    Assert.assertEquals(cs.getMisPlacedVMs(i).size(), vg1.size() + vg2.size());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SplitAmong(org.btrplace.model.constraint.SplitAmong) 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) HashSet(java.util.HashSet) 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