use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.
the class UCC15 method decommissioning_40gb.
public SolvingStatistics decommissioning_40gb() throws SchedulerException {
// Set nb of nodes and vms
int nbNodesRack = 24;
int nbSrcNodes = nbNodesRack * 8;
int nbDstNodes = nbNodesRack * 4;
int nbVMs = nbSrcNodes * 2;
// Set mem + cpu for VMs and Nodes
int memVM = 4, cpuVM = 1;
int memSrcNode = 16, cpuSrcNode = 4;
int memDstNode = 16, cpuDstNode = 4;
// Set memoryUsed and dirtyRate (for all VMs)
int tpl1MemUsed = 2000, tpl1MaxDirtySize = 5, tpl1MaxDirtyDuration = 3;
// idle vm
double tpl1DirtyRate = 0;
int tpl2MemUsed = 4000, tpl2MaxDirtySize = 96, tpl2MaxDirtyDuration = 2;
// stress --vm 1000 --bytes 70K
double tpl2DirtyRate = 3;
int tpl3MemUsed = 2000, tpl3MaxDirtySize = 96, tpl3MaxDirtyDuration = 2;
// stress --vm 1000 --bytes 70K
double tpl3DirtyRate = 3;
int tpl4MemUsed = 4000, tpl4MaxDirtySize = 5, tpl4MaxDirtyDuration = 3;
// idle vm
double tpl4DirtyRate = 0;
// New default model
Model mo = new DefaultModel();
Mapping ma = mo.getMapping();
// Create online source nodes and offline destination nodes
List<Node> srcNodes = new ArrayList<>(), dstNodes = new ArrayList<>();
for (int i = 0; i < nbSrcNodes; i++) {
srcNodes.add(mo.newNode());
ma.addOnlineNode(srcNodes.get(i));
}
for (int i = 0; i < nbDstNodes; i++) {
dstNodes.add(mo.newNode());
ma.addOfflineNode(dstNodes.get(i));
}
// Set boot and shutdown time
for (Node n : dstNodes) {
mo.getAttributes().put(n, "boot", 120);
/*~2 minutes to boot*/
}
for (Node n : srcNodes) {
mo.getAttributes().put(n, "shutdown", 17);
/*~30 seconds to shutdown*/
}
// Create running VMs on src nodes
List<VM> vms = new ArrayList<>();
VM v;
for (int i = 0; i < nbSrcNodes; i++) {
if (i % 2 == 0) {
v = mo.newVM();
vms.add(v);
mo.getAttributes().put(v, "memUsed", tpl1MemUsed);
mo.getAttributes().put(v, "coldDirtyRate", tpl1DirtyRate);
mo.getAttributes().put(v, "hotDirtySize", tpl1MaxDirtySize);
mo.getAttributes().put(v, "hotDirtyDuration", tpl1MaxDirtyDuration);
ma.addRunningVM(v, srcNodes.get(i));
v = mo.newVM();
vms.add(v);
mo.getAttributes().put(v, "memUsed", tpl2MemUsed);
mo.getAttributes().put(v, "coldDirtyRate", tpl2DirtyRate);
mo.getAttributes().put(v, "hotDirtySize", tpl2MaxDirtySize);
mo.getAttributes().put(v, "hotDirtyDuration", tpl2MaxDirtyDuration);
ma.addRunningVM(v, srcNodes.get(i));
} else {
v = mo.newVM();
vms.add(v);
mo.getAttributes().put(v, "memUsed", tpl3MemUsed);
mo.getAttributes().put(v, "coldDirtyRate", tpl3DirtyRate);
mo.getAttributes().put(v, "hotDirtySize", tpl3MaxDirtySize);
mo.getAttributes().put(v, "hotDirtyDuration", tpl3MaxDirtyDuration);
ma.addRunningVM(v, srcNodes.get(i));
v = mo.newVM();
vms.add(v);
mo.getAttributes().put(v, "memUsed", tpl4MemUsed);
mo.getAttributes().put(v, "coldDirtyRate", tpl4DirtyRate);
mo.getAttributes().put(v, "hotDirtySize", tpl4MaxDirtySize);
mo.getAttributes().put(v, "hotDirtyDuration", tpl4MaxDirtyDuration);
ma.addRunningVM(v, srcNodes.get(i));
}
}
// Add resource decorators
ShareableResource rcMem = new ShareableResource("mem", 0, 0);
ShareableResource rcCPU = new ShareableResource("cpu", 0, 0);
for (Node n : srcNodes) {
rcMem.setCapacity(n, memSrcNode);
rcCPU.setCapacity(n, cpuSrcNode);
}
for (Node n : dstNodes) {
rcMem.setCapacity(n, memDstNode);
rcCPU.setCapacity(n, cpuDstNode);
}
for (VM vm : vms) {
rcMem.setConsumption(vm, memVM);
rcCPU.setConsumption(vm, cpuVM);
}
mo.attach(rcMem);
mo.attach(rcCPU);
// Add a NetworkView view
Network net = new Network();
Switch swSrcRack1 = net.newSwitch();
Switch swSrcRack2 = net.newSwitch();
Switch swSrcRack3 = net.newSwitch();
Switch swSrcRack4 = net.newSwitch();
Switch swSrcRack5 = net.newSwitch();
Switch swSrcRack6 = net.newSwitch();
Switch swSrcRack7 = net.newSwitch();
Switch swSrcRack8 = net.newSwitch();
Switch swDstRack1 = net.newSwitch();
Switch swDstRack2 = net.newSwitch();
Switch swDstRack3 = net.newSwitch();
Switch swDstRack4 = net.newSwitch();
Switch swMain = net.newSwitch();
net.connect(1000, swSrcRack1, srcNodes.subList(0, nbNodesRack));
net.connect(1000, swSrcRack2, srcNodes.subList(nbNodesRack, nbNodesRack * 2));
net.connect(1000, swSrcRack3, srcNodes.subList(nbNodesRack * 2, nbNodesRack * 3));
net.connect(1000, swSrcRack4, srcNodes.subList(nbNodesRack * 3, nbNodesRack * 4));
net.connect(1000, swSrcRack5, srcNodes.subList(nbNodesRack * 4, nbNodesRack * 5));
net.connect(1000, swSrcRack6, srcNodes.subList(nbNodesRack * 5, nbNodesRack * 6));
net.connect(1000, swSrcRack7, srcNodes.subList(nbNodesRack * 6, nbNodesRack * 7));
net.connect(1000, swSrcRack8, srcNodes.subList(nbNodesRack * 7, nbNodesRack * 8));
net.connect(1000, swDstRack1, dstNodes.subList(0, nbNodesRack));
net.connect(1000, swDstRack2, dstNodes.subList(nbNodesRack, nbNodesRack * 2));
net.connect(1000, swDstRack3, dstNodes.subList(nbNodesRack * 2, nbNodesRack * 3));
net.connect(1000, swDstRack4, dstNodes.subList(nbNodesRack * 3, nbNodesRack * 4));
net.connect(40000, swMain, swSrcRack1, swSrcRack2, swSrcRack3, swSrcRack4, swSrcRack5, swSrcRack6, swSrcRack7, swSrcRack8, swDstRack1, swDstRack2, swDstRack3, swDstRack4);
mo.attach(net);
// net.generateDot(path + "topology.dot", false);
// Set parameters
DefaultParameters ps = new DefaultParameters();
ps.setVerbosity(0);
ps.setTimeLimit(60);
// ps.setMaxEnd(600);
ps.doOptimize(false);
// Migrate all VMs to destination nodes
List<SatConstraint> cstrs = new ArrayList<>();
int vm_num = 0;
for (int i = 0; i < nbDstNodes; i++) {
cstrs.add(new Fence(vms.get(vm_num), Collections.singleton(dstNodes.get(i))));
cstrs.add(new Fence(vms.get(vm_num + 1), Collections.singleton(dstNodes.get(i))));
cstrs.add(new Fence(vms.get(nbVMs - 1 - vm_num), Collections.singleton(dstNodes.get(i))));
cstrs.add(new Fence(vms.get(nbVMs - 2 - vm_num), Collections.singleton(dstNodes.get(i))));
vm_num += 2;
}
// Shutdown source nodes
cstrs.addAll(srcNodes.stream().map(Offline::new).collect(Collectors.toList()));
// Set a custom objective
DefaultChocoScheduler sc = new DefaultChocoScheduler(ps);
Instance i = new Instance(mo, cstrs, new MinMTTRMig());
ReconfigurationPlan p;
try {
p = sc.solve(i);
Assert.assertNotNull(p);
} catch (Exception e) {
e.printStackTrace();
}
// finally {
return sc.getStatistics();
// }
}
use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.
the class MaxOnlineSplitterTest method testSplit.
@Test
public void testSplit() throws SchedulerException {
MaxOnlineSplitter splitter = new MaxOnlineSplitter();
Model mo = new DefaultModel();
Node[] ns = new Node[10];
for (int i = 0; i < ns.length; i++) {
Node n = mo.newNode();
mo.getMapping().addOnlineNode(n);
ns[i] = n;
}
FixedNodeSetsPartitioning cut = new FixedSizePartitioning(5);
Instance origin = new Instance(mo, Collections.emptyList(), new MinMTTR());
List<Instance> instances = cut.split(new DefaultParameters(), origin);
TIntIntHashMap vmIndex = Instances.makeVMIndex(instances);
TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
MaxOnline m1 = new MaxOnline(new HashSet<>(Arrays.asList(ns[0], ns[1], ns[2], ns[3], ns[4])), 3);
// This one is valid as m1 stay in the first partition
Assert.assertTrue(splitter.split(m1, origin, instances, vmIndex, nodeIndex));
boolean found = false;
for (Instance i : instances) {
if (i.getSatConstraints().contains(m1)) {
if (found) {
Assert.fail(m1 + " is already in a partition");
}
found = true;
}
}
// Invalid, the constraint is over 2 partitions
MaxOnline m2 = new MaxOnline(new HashSet<>(Arrays.asList(ns[0], ns[1], ns[5])), 3);
Assert.assertFalse(splitter.split(m2, origin, instances, vmIndex, nodeIndex));
}
use of org.btrplace.scheduler.choco.DefaultParameters 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.DefaultParameters 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);
}
}
}
use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.
the class ForgeVMTest method testBasics.
@Test
public void testBasics() throws SchedulerException {
Model mo = new DefaultModel();
final VM vm1 = mo.newVM();
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));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).build();
ForgeVM ma = (ForgeVM) rp.getVMAction(vm1);
Assert.assertEquals(vm1, ma.getVM());
Assert.assertEquals(ma.getTemplate(), "small");
Assert.assertTrue(ma.getDuration().isInstantiatedTo(7));
Assert.assertFalse(ma.getStart().isInstantiated());
Assert.assertFalse(ma.getEnd().isInstantiated());
Assert.assertTrue(ma.getState().isInstantiatedTo(0));
Assert.assertNull(ma.getCSlice());
Assert.assertNull(ma.getDSlice());
}
Aggregations