use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class CShareableResourceTest method testWithFloat.
@Test
public void testWithFloat() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2).run(n1, vm1, vm2);
org.btrplace.model.view.ShareableResource rc = new ShareableResource("foo");
rc.setCapacity(n1, 32);
rc.setConsumption(vm1, 3);
rc.setConsumption(vm2, 2);
mo.attach(rc);
ChocoScheduler cra = new DefaultChocoScheduler();
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Online.newOnline(map.getAllNodes()));
Overbook o = new Overbook(n1, "foo", 1.5, false);
cstrs.add(o);
Overbook o2 = new Overbook(n2, "foo", 1.5, false);
cstrs.add(o2);
cstrs.add(new Preserve(vm1, "foo", 5));
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class CShareableResourceTest method testEmpty.
// Issue124
@Test
public void testEmpty() throws SchedulerException {
String buf = "{\"model\":{\"mapping\":{\"readyVMs\":[],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[1,0]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{}},\"views\":[{\"defConsumption\":0,\"nodes\":{},\"rcId\":\"CPU\",\"id\":\"shareableResource\",\"defCapacity\":0,\"vms\":{}}]},\"constraints\":[{\"continuous\":false,\"id\":\"spread\",\"vms\":[0,1]}],\"objective\":{\"id\":\"minimizeMTTR\"}}";
Instance i = JSON.readInstance(new StringReader(buf));
ChocoScheduler s = new DefaultChocoScheduler();
ReconfigurationPlan p = s.solve(i);
Assert.assertNotNull(p);
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class Decommissionning method run.
@Override
public void run() {
int ratio = 1;
int nbPCPUs = 4;
int nbNodes = 2;
// The current DC
Model mo = new DefaultModel();
for (int i = 0; i < nbNodes; i++) {
Node n = mo.newNode();
mo.getMapping().addOnlineNode(n);
// 4 VMs per node
for (int j = 0; j < ratio * nbPCPUs; j++) {
VM v = mo.newVM();
mo.getMapping().addRunningVM(v, n);
}
}
// Resource allocation
ShareableResource rc = new ShareableResource("cpu", 8, 1);
mo.attach(rc);
// The new DC
for (int i = 0; i < nbNodes; i++) {
Node n = mo.newNode();
mo.getMapping().addOfflineNode(n);
rc.setCapacity(n, 10);
}
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Offline.newOffline(mo.getMapping().getOnlineNodes()));
MaxOnline m = new MaxOnline(mo.getMapping().getAllNodes(), nbNodes + 1, true);
cstrs.add(m);
ChocoScheduler cra = new DefaultChocoScheduler();
cra.setMaxEnd(3);
cra.setVerbosity(1);
ReconfigurationPlan p = cra.solve(mo, cstrs);
System.out.println(p);
System.out.println(cra.getStatistics());
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class GettingStarted method run.
@Override
public void run() {
Model model = makeModel();
List<SatConstraint> cstrs = makeConstraints();
ChocoScheduler ra = new DefaultChocoScheduler();
ReconfigurationPlan plan = ra.solve(model, cstrs);
if (plan != null) {
System.out.println("Time-based plan:");
System.out.println(new TimeBasedPlanApplier().toString(plan));
System.out.println("\nDependency based plan:");
System.out.println(new DependencyBasedPlanApplier().toString(plan));
}
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class ModelCustomization method run.
@Override
public void run() {
Model model = makeModel();
List<SatConstraint> cstrs = makeConstraints(model);
// Set attributes for the VMs
Attributes attrs = model.getAttributes();
for (VM vm : model.getMapping().getAllVMs()) {
attrs.put(vm, "template", vm.id() % 2 == 0 ? "small" : "large");
attrs.put(vm, "clone", true);
attrs.put(vm, "forge", vm.id() % 2 == 0 ? 2 : 10);
// forge == 2 && template == small for vm0, vm2, vm4, vm6, vm8
// forge == 10 && template == large for vm1, vm3, vm5, vm7, vm9
}
// Change the duration evaluator for MigrateVM action
ChocoScheduler cra = new DefaultChocoScheduler();
DurationEvaluators dev = cra.getDurationEvaluators();
dev.register(MigrateVM.class, new LinearToAResourceActionDuration<VM>("mem", 2, 3));
dev.register(BootVM.class, new ConstantActionDuration<>(1));
dev.register(ShutdownVM.class, new ConstantActionDuration<>(1));
// Relocate VM4:
// using a migration: (2 * mem + 3) = (2 * 2 + 3) = 7 sec.
// using a re-instantiation: forge + boot + shutdown = 2 + 1 + 1 = 4 sec.
// Relocate VM5:
// using a migration: (2 * mem + 3) = (2 * 3 + 3) = 9 sec.
// using a re-instantiation: forge + boot + shutdown = 10 + 1 + 1 = 12 sec.
cra.doOptimize(true);
ReconfigurationPlan plan = cra.solve(model, cstrs);
System.out.println(plan);
}
Aggregations