Search in sources :

Example 21 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class Bench method benchHA.

public static void benchHA(int nbSamples, Integer partSize, Integer ratio, Integer nbParts) {
    Model mo = new DefaultModel();
    Instance inst = new Instance(mo, new MinMTTR());
    int nbNodes = partSize * nbParts;
    int nbVMs = ratio * nbNodes;
    // Make the infrastructure
    List<Node> l = makeNodeList(mo, nbNodes);
    ShareableResource rcCpu = new ShareableResource("cpu", 20, 0);
    ShareableResource rcMem = new ShareableResource("mem", 16, /*GB*/
    0);
    List<Collection<Node>> edges = makeEdges(l, 250);
    mo.attach(rcCpu);
    mo.attach(rcMem);
    while (nbVMs != 0) {
        nbVMs -= makeApp(inst, nbVMs, edges);
    }
    FixedSizePartitioning partitioner = new FixedSizePartitioning(partSize);
    try {
        for (int x = 0; x < nbSamples; x++) {
            long start = System.currentTimeMillis();
            List<Instance> instances = partitioner.split(new DefaultParameters(), inst);
            long end = System.currentTimeMillis();
            System.err.println(instances.size() + " " + nbNodes + " " + nbNodes * ratio + " " + inst.getSatConstraints().size() + " " + (end - start));
        }
    } catch (SchedulerException ex) {
        Assert.fail(ex.getMessage(), ex);
    }
}
Also used : SchedulerException(org.btrplace.scheduler.SchedulerException) MinMTTR(org.btrplace.model.constraint.MinMTTR) ShareableResource(org.btrplace.model.view.ShareableResource) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters)

Example 22 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class ModelConverterTest method testConversion.

@Test
public void testConversion() throws JSONConverterException {
    ModelConverter conv = new ModelConverter();
    Model mo = new DefaultModel();
    Mapping m = mo.getMapping();
    Node n1 = mo.newNode();
    VM vm1 = mo.newVM();
    m.addOnlineNode(n1);
    m.addReadyVM(vm1);
    Attributes attrs = mo.getAttributes();
    attrs.put(vm1, "boot", 5);
    attrs.put(n1, "type", "xen");
    ShareableResource rc = new ShareableResource("cpu");
    rc.setConsumption(vm1, 5);
    rc.setCapacity(n1, 10);
    mo.attach(rc);
    String jo = conv.toJSONString(mo);
    System.out.println(jo);
    Model res = conv.fromJSON(jo);
    Assert.assertEquals(res, mo);
    Assert.assertTrue(res.contains(n1));
    Assert.assertTrue(res.contains(vm1));
}
Also used : ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 23 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class Capa method eval.

@Override
public Integer eval(Context mo, Object... args) {
    String rc = (String) args[1];
    ShareableResource r = ShareableResource.get(mo.getModel(), rc);
    if (r == null) {
        throw new IllegalArgumentException("View '" + rc + "' is missing");
    }
    return r.getCapacity((Node) args[0]);
}
Also used : ShareableResource(org.btrplace.model.view.ShareableResource)

Example 24 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class SliceRcComparatorTest method testDescending.

@Test
public void testDescending() {
    List<Slice> l = makeSlices();
    ShareableResource rc = new ShareableResource("cpu");
    for (Slice s : l) {
        rc.setConsumption(s.getSubject(), rnd.nextInt(10));
    }
    SliceRcComparator cmp = new SliceRcComparator(rc, false);
    Collections.sort(l, cmp);
    for (int i = 0; i < l.size() - 1; i++) {
        VM u1 = l.get(i).getSubject();
        VM u2 = l.get(i + 1).getSubject();
        Assert.assertTrue(rc.getConsumption(u1) >= rc.getConsumption(u2));
    }
}
Also used : VM(org.btrplace.model.VM) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 25 with ShareableResource

use of org.btrplace.model.view.ShareableResource in project scheduler by btrplace.

the class CMaxOnlineTest method discreteMaxOnlineTest2.

@Test
public void discreteMaxOnlineTest2() throws SchedulerException {
    Model model = new DefaultModel();
    Node n1 = model.newNode();
    Node n2 = model.newNode();
    Node n3 = model.newNode();
    VM vm1 = model.newVM();
    VM vm2 = model.newVM();
    VM vm3 = model.newVM();
    VM vm4 = model.newVM();
    ShareableResource resources = new ShareableResource("vcpu", 1, 1);
    resources.setCapacity(n1, 4);
    resources.setCapacity(n2, 8);
    resources.setCapacity(n3, 2);
    resources.setConsumption(vm4, 2);
    Mapping map = model.getMapping().on(n1, n2, n3).run(n1, vm1, vm4).run(n2, vm2).run(n3, vm3);
    model.attach(resources);
    MappingUtils.fill(map, model.getMapping());
    Set<Node> nodes = map.getAllNodes();
    MaxOnline maxon = new MaxOnline(nodes, 2);
    Set<Node> nodes2 = new HashSet<>(Arrays.asList(n1, n2));
    MaxOnline maxon2 = new MaxOnline(nodes2, 1);
    List<SatConstraint> constraints = new ArrayList<>();
    constraints.add(maxon);
    constraints.add(maxon2);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.setMaxEnd(4);
    cra.getMapper().mapConstraint(MaxOnline.class, CMaxOnline.class);
    ReconfigurationPlan plan = cra.solve(model, constraints);
    Assert.assertNotNull(plan);
    Assert.assertTrue(maxon.isSatisfied(plan.getResult()));
}
Also used : SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ShareableResource(org.btrplace.model.view.ShareableResource) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) MaxOnline(org.btrplace.model.constraint.MaxOnline) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Aggregations

ShareableResource (org.btrplace.model.view.ShareableResource)86 Test (org.testng.annotations.Test)61 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)47 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)41 SatConstraint (org.btrplace.model.constraint.SatConstraint)32 ArrayList (java.util.ArrayList)31 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)29 VM (org.btrplace.model.VM)27 Model (org.btrplace.model.Model)25 Node (org.btrplace.model.Node)25 DefaultModel (org.btrplace.model.DefaultModel)22 MigrateVM (org.btrplace.plan.event.MigrateVM)16 Mapping (org.btrplace.model.Mapping)13 Network (org.btrplace.model.view.network.Network)12 Switch (org.btrplace.model.view.network.Switch)12 Offline (org.btrplace.model.constraint.Offline)11 MinMTTRMig (org.btrplace.model.constraint.migration.MinMTTRMig)10 SchedulerException (org.btrplace.scheduler.SchedulerException)10 Fence (org.btrplace.model.constraint.Fence)7 Preserve (org.btrplace.model.constraint.Preserve)7