Search in sources :

Example 36 with DefaultParameters

use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.

the class ShutdownableNodeTest method testShutdownBeforeVMsLeave.

@Test
public void testShutdownBeforeVMsLeave() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    final VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    map.addOnlineNode(n1);
    map.addRunningVM(vm1, n1);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(ShutdownVM.class, new ConstantActionDuration<>(2));
    dev.register(ShutdownNode.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).setParams(ps).build();
    ShutdownableNode ma1 = (ShutdownableNode) rp.getNodeAction(n1);
    ma1.getState().instantiateTo(0, Cause.Null);
    ma1.getHostingEnd().instantiateTo(0, Cause.Null);
    rp.getEnd().updateUpperBound(10, Cause.Null);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNull(p);
}
Also used : Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) ShutdownVM(org.btrplace.plan.event.ShutdownVM) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) Test(org.testng.annotations.Test)

Example 37 with DefaultParameters

use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.

the class ShutdownableNodeTest method testScheduledShutdown.

@Test
public void testScheduledShutdown() throws SchedulerException, ContradictionException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();
    final VM vm1 = mo.newVM();
    Node n1 = mo.newNode();
    map.addOnlineNode(n1);
    map.addRunningVM(vm1, n1);
    Parameters ps = new DefaultParameters();
    DurationEvaluators dev = ps.getDurationEvaluators();
    dev.register(ShutdownVM.class, new ConstantActionDuration<>(2));
    dev.register(ShutdownNode.class, new ConstantActionDuration<>(5));
    ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).build();
    ShutdownableNode ma = (ShutdownableNode) rp.getNodeAction(n1);
    ma.getState().instantiateTo(0, Cause.Null);
    ReconfigurationPlan p = rp.solve(0, false);
    Assert.assertNotNull(p);
    Assert.assertEquals(ma.getState().getValue(), 0);
    Assert.assertEquals(ma.getDuration().getValue(), 5);
    Assert.assertEquals(ma.getStart().getValue(), 2);
    Assert.assertEquals(ma.getEnd().getValue(), 7);
    Assert.assertEquals(ma.getHostingStart().getValue(), 0);
    Assert.assertEquals(ma.getHostingEnd().getValue(), 2);
    Model res = p.getResult();
    Assert.assertTrue(res.getMapping().getOfflineNodes().contains(n1));
}
Also used : Parameters(org.btrplace.scheduler.choco.Parameters) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ReconfigurationProblem(org.btrplace.scheduler.choco.ReconfigurationProblem) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) ShutdownVM(org.btrplace.plan.event.ShutdownVM) DurationEvaluators(org.btrplace.scheduler.choco.duration.DurationEvaluators) DefaultReconfigurationProblemBuilder(org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder) Test(org.testng.annotations.Test)

Example 38 with DefaultParameters

use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.

the class UCC15 method decommissioning_100gb.

public SolvingStatistics decommissioning_100gb() throws SchedulerException {
    // Set nb of nodes and vms
    int nbNodesRack = 24;
    int nbSrcNodes = nbNodesRack * 20;
    int nbDstNodes = nbNodesRack * 10;
    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", 1);
    /*~2 minutes to boot*/
    }
    for (Node n : srcNodes) {
        mo.getAttributes().put(n, "shutdown", 1);
    /*~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 swSrcRack9 = net.newSwitch();
    Switch swSrcRack10 = net.newSwitch();
    Switch swSrcRack11 = net.newSwitch();
    Switch swSrcRack12 = net.newSwitch();
    Switch swSrcRack13 = net.newSwitch();
    Switch swSrcRack14 = net.newSwitch();
    Switch swSrcRack15 = net.newSwitch();
    Switch swSrcRack16 = net.newSwitch();
    Switch swSrcRack17 = net.newSwitch();
    Switch swSrcRack18 = net.newSwitch();
    Switch swSrcRack19 = net.newSwitch();
    Switch swSrcRack20 = net.newSwitch();
    Switch swDstRack1 = net.newSwitch();
    Switch swDstRack2 = net.newSwitch();
    Switch swDstRack3 = net.newSwitch();
    Switch swDstRack4 = net.newSwitch();
    Switch swDstRack5 = net.newSwitch();
    Switch swDstRack6 = net.newSwitch();
    Switch swDstRack7 = net.newSwitch();
    Switch swDstRack8 = net.newSwitch();
    Switch swDstRack9 = net.newSwitch();
    Switch swDstRack10 = 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, swSrcRack9, srcNodes.subList(nbNodesRack * 8, nbNodesRack * 9));
    net.connect(1000, swSrcRack10, srcNodes.subList(nbNodesRack * 9, nbNodesRack * 10));
    net.connect(1000, swSrcRack11, srcNodes.subList(nbNodesRack * 10, nbNodesRack * 11));
    net.connect(1000, swSrcRack12, srcNodes.subList(nbNodesRack * 11, nbNodesRack * 12));
    net.connect(1000, swSrcRack13, srcNodes.subList(nbNodesRack * 12, nbNodesRack * 13));
    net.connect(1000, swSrcRack14, srcNodes.subList(nbNodesRack * 13, nbNodesRack * 14));
    net.connect(1000, swSrcRack15, srcNodes.subList(nbNodesRack * 14, nbNodesRack * 15));
    net.connect(1000, swSrcRack16, srcNodes.subList(nbNodesRack * 15, nbNodesRack * 16));
    net.connect(1000, swSrcRack17, srcNodes.subList(nbNodesRack * 16, nbNodesRack * 17));
    net.connect(1000, swSrcRack18, srcNodes.subList(nbNodesRack * 17, nbNodesRack * 18));
    net.connect(1000, swSrcRack19, srcNodes.subList(nbNodesRack * 18, nbNodesRack * 19));
    net.connect(1000, swSrcRack20, srcNodes.subList(nbNodesRack * 19, nbNodesRack * 20));
    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(1000, swDstRack5, dstNodes.subList(nbNodesRack * 4, nbNodesRack * 5));
    net.connect(1000, swDstRack6, dstNodes.subList(nbNodesRack * 5, nbNodesRack * 6));
    net.connect(1000, swDstRack7, dstNodes.subList(nbNodesRack * 6, nbNodesRack * 7));
    net.connect(1000, swDstRack8, dstNodes.subList(nbNodesRack * 7, nbNodesRack * 8));
    net.connect(1000, swDstRack9, dstNodes.subList(nbNodesRack * 8, nbNodesRack * 9));
    net.connect(1000, swDstRack10, dstNodes.subList(nbNodesRack * 9, nbNodesRack * 10));
    net.connect(100000, swMain, swSrcRack1, swSrcRack2, swSrcRack3, swSrcRack4, swSrcRack5, swSrcRack6, swSrcRack7, swSrcRack8, swSrcRack9, swSrcRack10, swSrcRack11, swSrcRack12, swSrcRack13, swSrcRack14, swSrcRack15, swSrcRack16, swSrcRack17, swSrcRack18, swSrcRack19, swSrcRack20, swDstRack1, swDstRack2, swDstRack3, swDstRack4, swDstRack5, swDstRack6, swDstRack7, swDstRack8, swDstRack9, swDstRack10);
    mo.attach(net);
    // net.generateDot(path + "topology.dot", false);
    // Set parameters
    DefaultParameters ps = new DefaultParameters();
    ps.setVerbosity(0);
    ps.setTimeLimit(0);
    // 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);
        System.out.println(sc.getStatistics());
        Assert.assertNotNull(p);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // finally {
    return sc.getStatistics();
// }
}
Also used : SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Offline(org.btrplace.model.constraint.Offline) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) SchedulerException(org.btrplace.scheduler.SchedulerException) MinMTTRMig(org.btrplace.model.constraint.migration.MinMTTRMig) Switch(org.btrplace.model.view.network.Switch) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Network(org.btrplace.model.view.network.Network) Fence(org.btrplace.model.constraint.Fence)

Example 39 with DefaultParameters

use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.

the class UCC15 method decommissioning_10gb.

public SolvingStatistics decommissioning_10gb() throws SchedulerException {
    // Set nb of nodes and vms
    int nbNodesRack = 24;
    int nbSrcNodes = nbNodesRack * 2;
    int nbDstNodes = nbNodesRack * 1;
    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);
    /*~17 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 swDstRack1 = 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, swDstRack1, dstNodes.subList(0, nbNodesRack));
    net.connect(10000, swMain, swSrcRack1, swSrcRack2, swDstRack1);
    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();
// }
}
Also used : SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Offline(org.btrplace.model.constraint.Offline) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) SchedulerException(org.btrplace.scheduler.SchedulerException) MinMTTRMig(org.btrplace.model.constraint.migration.MinMTTRMig) Switch(org.btrplace.model.view.network.Switch) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Network(org.btrplace.model.view.network.Network) Fence(org.btrplace.model.constraint.Fence)

Example 40 with DefaultParameters

use of org.btrplace.scheduler.choco.DefaultParameters in project scheduler by btrplace.

the class UCC15 method decommissioning_20gb.

public SolvingStatistics decommissioning_20gb() throws SchedulerException {
    // Set nb of nodes and vms
    int nbNodesRack = 24;
    int nbSrcNodes = nbNodesRack * 4;
    int nbDstNodes = nbNodesRack * 2;
    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 swDstRack1 = net.newSwitch();
    Switch swDstRack2 = 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, swDstRack1, dstNodes.subList(0, nbNodesRack));
    net.connect(1000, swDstRack2, dstNodes.subList(nbNodesRack, nbNodesRack * 2));
    net.connect(20000, swMain, swSrcRack1, swSrcRack2, swSrcRack3, swSrcRack4, swDstRack1, swDstRack2);
    mo.attach(net);
    // net.generateDot(path + "topology.dot", false);
    // Set parameters
    DefaultParameters ps = new DefaultParameters();
    ps.setVerbosity(0);
    ps.setTimeLimit(10);
    // 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();
// }
}
Also used : SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) Offline(org.btrplace.model.constraint.Offline) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) SchedulerException(org.btrplace.scheduler.SchedulerException) MinMTTRMig(org.btrplace.model.constraint.migration.MinMTTRMig) Switch(org.btrplace.model.view.network.Switch) DefaultParameters(org.btrplace.scheduler.choco.DefaultParameters) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Network(org.btrplace.model.view.network.Network) Fence(org.btrplace.model.constraint.Fence)

Aggregations

DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)40 Test (org.testng.annotations.Test)35 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)32 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)30 Parameters (org.btrplace.scheduler.choco.Parameters)29 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)29 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)28 CMinMTTR (org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR)14 DefaultModel (org.btrplace.model.DefaultModel)11 Model (org.btrplace.model.Model)11 Node (org.btrplace.model.Node)10 ShutdownNode (org.btrplace.plan.event.ShutdownNode)10 HashSet (java.util.HashSet)9 Mapping (org.btrplace.model.Mapping)9 VM (org.btrplace.model.VM)9 BootNode (org.btrplace.plan.event.BootNode)9 Action (org.btrplace.plan.event.Action)8 MigrateVM (org.btrplace.plan.event.MigrateVM)8 ShareableResource (org.btrplace.model.view.ShareableResource)6 ArrayList (java.util.ArrayList)5