use of org.btrplace.model.constraint.MinMigrations in project scheduler by btrplace.
the class MinMigrationsConverterTest method test.
@Test
public void test() throws JSONConverterException {
Model mo = new DefaultModel();
ConstraintsConverter conv = new ConstraintsConverter();
conv.register(new MinMigrationsConverter());
MinMigrations m = new MinMigrations();
Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(m)), m);
System.out.println(conv.toJSON(m));
}
use of org.btrplace.model.constraint.MinMigrations in project scheduler by btrplace.
the class VectorPackingTest method testSlotFilteringWithUniformVMs.
/**
* 1GB free on every node and only 2GB VMs. We ask for booting a 2GB VM. No
* solution detected immediately if the hosting capacity is capped to the
* max number of VMs per node (100) as their sum will not exceed the
* number of running VMs.
*/
@Test
public void testSlotFilteringWithUniformVMs() {
int capa = 201;
DefaultModel mo = new DefaultModel();
Mapping map = mo.getMapping();
ShareableResource mem = new ShareableResource("mem");
ShareableResource cpu = new ShareableResource("cpu");
ShareableResource ctrl = new ShareableResource("ctrl");
mo.attach(mem);
mo.attach(cpu);
mo.attach(ctrl);
Instance ii = new Instance(mo, new ArrayList<>(), new MinMigrations());
for (int i = 0; i < 500; i++) {
final Node no = mo.newNode();
map.on(no);
mem.setCapacity(no, capa);
cpu.setCapacity(no, capa);
ctrl.setCapacity(no, capa);
// 1 left on every node.
for (int j = 0; j < capa / 2; j++) {
final VM vm = mo.newVM();
map.run(no, vm);
mem.setConsumption(vm, 2);
cpu.setConsumption(vm, 2);
ctrl.setConsumption(vm, 2);
}
final VM vm = mo.newVM();
map.run(no, vm);
mem.setConsumption(vm, 0);
cpu.setConsumption(vm, 0);
ctrl.setConsumption(vm, 0);
}
final VM p = mo.newVM();
mem.setConsumption(p, 2);
cpu.setConsumption(p, 2);
ctrl.setConsumption(p, 2);
map.addReadyVM(p);
final ChocoScheduler sched = new DefaultChocoScheduler();
ii.getSatConstraints().add(new Running(p));
sched.doRepair(false);
ReconfigurationPlan plan = sched.solve(ii);
Assert.assertNull(plan);
// The problem is stated during the initial propagation.
SolvingStatistics stats = sched.getStatistics();
Assert.assertEquals(0, stats.getMetrics().nodes());
// With 0 size VMs, same conclusion.
for (Node no : map.getOnlineNodes()) {
final VM vm = mo.newVM();
map.run(no, vm);
mem.setConsumption(vm, 0);
ctrl.setConsumption(vm, 0);
cpu.setConsumption(vm, 0);
}
plan = sched.solve(ii);
Assert.assertNull(plan);
// The problem is stated during the initial propagation.
stats = sched.getStatistics();
Assert.assertEquals(0, stats.getMetrics().nodes());
System.out.println(stats);
}
use of org.btrplace.model.constraint.MinMigrations in project scheduler by btrplace.
the class CMinMigrationsTest method main.
public static void main(String[] args) {
String root = "/Users/fabien.hermenier/Documents/BtrPlace/nutanix/instances";
List<OptConstraint> objs = Arrays.asList(/*new MinMTTR(),*/
new MinMigrations());
boolean verbose = true;
for (OptConstraint o : objs) {
System.out.print(" " + o);
}
System.out.println();
for (int idx = 1; idx <= 256; idx += 5) {
String path = root + "/lazan/lazan-" + idx + ".json.gz";
if (verbose) {
System.out.println("--- " + idx + " --- ");
} else {
System.out.print(idx);
}
List<Long> res = new ArrayList<>();
for (OptConstraint o : objs) {
if (verbose) {
System.out.println("\t" + o);
}
Instance i = JSON.readInstance(new File(path));
if (Network.get(i.getModel()) != null) {
i.getModel().detach(Network.get(i.getModel()));
}
i = new Instance(i.getModel(), i.getSatConstraints(), o);
ChocoScheduler s = new DefaultChocoScheduler();
s.doOptimize(false);
s.setTimeLimit(30);
s.doRepair(false);
ReconfigurationPlan p = s.solve(i);
Assert.assertNotNull(p);
res.add(p.getActions().stream().filter(x -> x instanceof MigrateVM).mapToLong(x -> x.getEnd() - x.getStart()).sum());
// res.add((long)s.getStatistics().lastSolution().getDuration());
if (verbose) {
System.out.println(s.getStatistics());
// System.out.println(p);
}
}
if (!verbose) {
for (Long l : res) {
System.out.print("\t" + l);
}
System.out.println();
}
}
}
use of org.btrplace.model.constraint.MinMigrations in project scheduler by btrplace.
the class CMinMigrationsTest method simpleTest.
@Test
public void simpleTest() {
Model mo = new DefaultModel();
Node n0 = mo.newNode();
Node n1 = mo.newNode();
VM vm0 = mo.newVM();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
mo.getMapping().on(n0, n1).run(n0, vm0, vm1, vm2);
ShareableResource mem = new ShareableResource("mem", 5, 1);
// cpu dimension to create the violation
ShareableResource cpu = new ShareableResource("cpu", 5, 1);
// VM0 as the big VM
mem.setConsumption(vm0, 3);
mo.attach(cpu);
mo.attach(mem);
List<SatConstraint> cstrs = new ArrayList<>();
// The 3 VMs no longer feet on n0
cstrs.add(new Preserve(vm0, "cpu", 5));
ChocoScheduler s = new DefaultChocoScheduler();
s.doOptimize(true);
ReconfigurationPlan p = s.solve(mo, cstrs, new MinMigrations());
System.out.println(s.getStatistics());
System.out.println(p);
// VM0 to n1
Assert.assertEquals(p.getActions().size(), 1);
// VM0 to n1
Assert.assertEquals(p.getResult().getMapping().getVMLocation(vm0), n1);
}
use of org.btrplace.model.constraint.MinMigrations in project scheduler by btrplace.
the class CMinMigrationsTest method testWithFreeNodes.
/**
* Issue #137.
* ShutdownableNode.isOnline() is not instantiated at the end of the problem
*/
@Test
public void testWithFreeNodes() {
Model mo = new DefaultModel();
Node n0 = mo.newNode();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
VM v1 = mo.newVM();
VM v2 = mo.newVM();
DefaultChocoScheduler s = new DefaultChocoScheduler();
mo.getMapping().on(n0, n1, n2).run(n0, v1, v2);
Instance i = new Instance(mo, Arrays.asList(new Spread(mo.getMapping().getAllVMs(), false)), new MinMigrations());
ReconfigurationPlan p = s.solve(i);
Assert.assertNotNull(p);
}
Aggregations