use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class CShareableResourceTest method testInsertAction.
/**
* Reproduce issue#145.
*/
/*@Test*/
public void testInsertAction() {
Model mo = new DefaultModel();
ShareableResource cpu = new ShareableResource("cpu");
ShareableResource mem = new ShareableResource("mem");
mo.attach(cpu);
mo.attach(mem);
Node node = mo.newNode();
Node node2 = mo.newNode();
mo.getMapping().on(node, node2);
cpu.setCapacity(node, 100000);
mem.setCapacity(node, 100000);
cpu.setCapacity(node2, 100000);
mem.setCapacity(node2, 100000);
for (int i = 0; i < 10000; i++) {
VM vm = mo.newVM();
mo.getMapping().run(node, vm);
cpu.setConsumption(vm, 1);
mem.setConsumption(vm, 1);
}
ChocoScheduler sched = new DefaultChocoScheduler();
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Running.newRunning(mo.getMapping().getAllVMs()));
cstrs.addAll(NoDelay.newNoDelay(mo.getMapping().getAllVMs()));
cstrs.addAll(Fence.newFence(mo.getMapping().getAllVMs(), Arrays.asList(node2)));
cstrs.addAll(Preserve.newPreserve(mo.getMapping().getAllVMs(), "cpu", 2));
cstrs.addAll(Preserve.newPreserve(mo.getMapping().getAllVMs(), "mem", 2));
ReconfigurationPlan plan = sched.solve(mo, cstrs);
System.out.println(plan);
System.out.println(sched.getStatistics());
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler 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.scheduler.choco.DefaultChocoScheduler 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.scheduler.choco.DefaultChocoScheduler 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.scheduler.choco.DefaultChocoScheduler 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));
}
}
Aggregations