use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.
the class Bench method main.
/**
* Launcher
*
* @param args the CLI arguments
* @throws IOException
*/
@SuppressWarnings("squid:S1166")
public static void main(String[] args) throws IOException {
opts = new Options();
// Parse the cmdline arguments
CmdLineParser cli = new CmdLineParser(opts);
try {
cli.getProperties().withUsageWidth(80);
cli.parseArgument(args);
} catch (@SuppressWarnings("unused") CmdLineException ex) {
cli.printUsage(System.err);
System.exit(1);
}
Runtime runtime = Runtime.getRuntime();
int mb = 1024 * 1024;
out(1, "Total Memory: %d%n", runtime.totalMemory() / mb);
out(1, "Max Memory: %d%n", runtime.maxMemory() / mb);
Parameters ps = opts.parameters();
Iterator<LabelledInstance> ite = opts.instances().iterator();
while (ite.hasNext()) {
LabelledInstance i = ite.next();
solve(i, ps);
}
}
use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.
the class CMinMigrations method placeVMs.
/*
* Try to place the VMs associated on the actions in a random node while trying first to stay on the current node
*/
private void placeVMs(Parameters ps, List<AbstractStrategy<?>> strategies, List<VMTransition> actions, OnStableNodeFirst schedHeuristic, Map<IntVar, VM> map) {
IntValueSelector rnd = new WorstFit(map, rp, new BiggestDimension());
if (!useResources) {
rnd = new RandomVMPlacement(rp, map, true, ps.getRandomSeed());
}
IntVar[] hosts = dSlices(actions).map(Slice::getHoster).filter(v -> !v.isInstantiated()).toArray(IntVar[]::new);
if (hosts.length > 0) {
strategies.add(new IntStrategy(hosts, new HostingVariableSelector(rp.getModel(), schedHeuristic), rnd));
}
}
use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.
the class CMinMTTR method placeVMs.
/*
* Try to place the VMs associated on the actions in a random node while trying first to stay on the current node
*/
private void placeVMs(Parameters ps, List<AbstractStrategy<?>> strategies, List<VMTransition> actions, OnStableNodeFirst schedHeuristic, Map<IntVar, VM> map) {
IntValueSelector rnd = new WorstFit(map, rp, new BiggestDimension());
if (!useResources) {
rnd = new RandomVMPlacement(rp, map, true, ps.getRandomSeed());
}
IntVar[] hosts = dSlices(actions).map(Slice::getHoster).filter(v -> !v.isInstantiated()).toArray(IntVar[]::new);
if (hosts.length > 0) {
strategies.add(new IntStrategy(hosts, new HostingVariableSelector(rp.getModel(), schedHeuristic), rnd));
}
}
use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.
the class BootVMTest method testBootSequence.
/**
* Test that check when the action is shorter than the end of
* the reconfiguration process.
* In practice, 2 boot actions have to be executed sequentially
*/
@Test
public void testBootSequence() throws SchedulerException, ContradictionException {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
final VM vm1 = mo.newVM();
final VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
map.addOnlineNode(n1);
map.addOnlineNode(n2);
map.addReadyVM(vm1);
map.addReadyVM(vm2);
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(org.btrplace.plan.event.BootVM.class, new ConstantActionDuration<>(5));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(new HashSet<>(), map.getAllVMs(), new HashSet<>(), new HashSet<>()).build();
BootVM m1 = (BootVM) rp.getVMActions().get(rp.getVM(vm1));
BootVM m2 = (BootVM) rp.getVMActions().get(rp.getVM(vm2));
rp.getNodeActions().get(0).getState().instantiateTo(1, Cause.Null);
rp.getNodeActions().get(1).getState().instantiateTo(1, Cause.Null);
rp.getModel().post(rp.getModel().arithm(m2.getStart(), ">=", m1.getEnd()));
new CMinMTTR().inject(ps, rp);
ReconfigurationPlan p = rp.solve(0, false);
Assert.assertNotNull(p);
Iterator<Action> ite = p.iterator();
org.btrplace.plan.event.BootVM b1 = (org.btrplace.plan.event.BootVM) ite.next();
org.btrplace.plan.event.BootVM b2 = (org.btrplace.plan.event.BootVM) ite.next();
Assert.assertEquals(vm1, b1.getVM());
Assert.assertEquals(vm2, b2.getVM());
Assert.assertTrue(b1.getEnd() <= b2.getStart());
Assert.assertEquals(5, b1.getEnd() - b1.getStart());
Assert.assertEquals(5, b2.getEnd() - b2.getStart());
}
use of org.btrplace.scheduler.choco.Parameters in project scheduler by btrplace.
the class ForgeVMTest method testResolution.
@Test
public void testResolution() throws SchedulerException, ContradictionException {
Model mo = new DefaultModel();
Mapping m = mo.getMapping();
final VM vm1 = mo.newVM();
Node n1 = mo.newNode();
m.addOnlineNode(n1);
mo.getAttributes().put(vm1, "template", "small");
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(org.btrplace.plan.event.ForgeVM.class, new ConstantActionDuration<>(7));
dev.register(ShutdownNode.class, new ConstantActionDuration<>(20));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).build();
// Force the node to get offline
ShutdownableNode n = (ShutdownableNode) rp.getNodeAction(n1);
n.getState().instantiateTo(0, Cause.Null);
new CMinMTTR().inject(ps, rp);
ReconfigurationPlan p = rp.solve(0, false);
Assert.assertNotNull(p);
Assert.assertEquals(p.getDuration(), 20);
for (Action a : p) {
if (a instanceof org.btrplace.plan.event.ForgeVM) {
org.btrplace.plan.event.ForgeVM action = (org.btrplace.plan.event.ForgeVM) a;
Assert.assertTrue(p.getResult().getMapping().isReady(vm1));
Assert.assertEquals(action.getVM(), vm1);
Assert.assertEquals(action.getEnd(), 7);
Assert.assertEquals(action.getStart(), 0);
}
}
}
Aggregations