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);
}
}
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));
}
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]);
}
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));
}
}
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()));
}
Aggregations