Search in sources :

Example 1 with Switch

use of org.btrplace.model.view.network.Switch 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();
// }
}
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 2 with Switch

use of org.btrplace.model.view.network.Switch in project scheduler by btrplace.

the class AdvancedMigScheduling method run.

@Override
public void run() {
    Model mo = makeModel();
    // Create, define, and attach CPU and Mem resource decorators for nodes and VMs
    int memSrc = 8;
    int cpuSrc = 4;
    int memDst = 16;
    int cpuDst = 8;
    ShareableResource rcMem = new ShareableResource("mem", 0, 8);
    ShareableResource rcCPU = new ShareableResource("cpu", 0, 4);
    // VMs resources consumption
    // Nodes resources capacity
    rcMem.setCapacity(srcNode1, memSrc).setCapacity(srcNode2, memSrc).setCapacity(srcNode3, memSrc).setCapacity(srcNode4, memSrc).setCapacity(dstNode1, memDst).setCapacity(dstNode2, memDst);
    rcCPU.setCapacity(srcNode1, cpuSrc).setCapacity(srcNode2, cpuSrc).setCapacity(srcNode3, cpuSrc).setCapacity(srcNode4, cpuSrc).setCapacity(dstNode1, cpuDst).setCapacity(dstNode2, cpuDst);
    mo.attach(rcMem);
    mo.attach(rcCPU);
    // Set VM attributes 'hot dirty page size', 'hot dirty page duration', and 'cold dirty pages rate'
    // to simulate a memory intensive workload equivalent to "stress --vm 1000 --bytes 50K"
    int vmHds = 56;
    int vmHdd = 2;
    double vmCdr = 22.6;
    // vm0 is an 'idle' VM (with no special memory activity) but still consumes 2 GiB of memory
    mo.getAttributes().put(vm0, "memUsed", 2000);
    // vm1 is an 'idle' VM (with no special memory activity) but still consumes 4 GiB of memory
    mo.getAttributes().put(vm1, "memUsed", 3000);
    // vm2 consumes 4 GiB memory and has a memory intensive workload
    mo.getAttributes().put(vm2, "memUsed", 4000);
    mo.getAttributes().put(vm2, "hotDirtySize", vmHds);
    mo.getAttributes().put(vm2, "hotDirtyDuration", vmHdd);
    mo.getAttributes().put(vm2, "coldDirtyRate", vmCdr);
    // vm3 consumes 6 GiB memory and has a memory intensive workload
    mo.getAttributes().put(vm3, "memUsed", 5000);
    mo.getAttributes().put(vm3, "hotDirtySize", vmHds);
    mo.getAttributes().put(vm3, "hotDirtyDuration", vmHdd);
    mo.getAttributes().put(vm3, "coldDirtyRate", vmCdr);
    // Attach a network view
    Network net = new Network();
    mo.attach(net);
    Switch swMain = net.newSwitch(30000);
    net.connect(10000, swMain, srcNode1, srcNode2, srcNode3, srcNode4);
    // The destination nodes have twice the bandwidth of source nodes
    net.connect(20000, swMain, dstNode1, dstNode2);
    // Create constraints
    List<SatConstraint> cstrs = new ArrayList<>();
    // We want to boot the destination nodes
    cstrs.addAll(Online.newOnline(Arrays.asList(dstNode1, dstNode2)));
    // We want to shutdown the source nodes
    cstrs.addAll(Offline.newOffline(Arrays.asList(srcNode1, srcNode2, srcNode3, srcNode4)));
    // Try to solve as is, and show the computed plan
    solve(mo, cstrs);
    /**
     ******* Add some migrations scheduling constraints ********
     */
    // We want vm0 and vm1 migrations to terminate at the same time
    cstrs.add(new Sync(vm0, vm1));
    // We want to serialize the migrations of vm1, vm2, and vm3
    cstrs.add(new Serialize(new HashSet<>(Arrays.asList(vm1, vm2, vm3))));
    // We want vm0 migration terminate before vm2 start to migrate
    cstrs.add(new Precedence(vm1, vm2));
    // We want vm3 migration terminate before 10s
    cstrs.add(new Deadline(vm3, "+0:0:10"));
    // Try to solve, and show the computed plan
    solve(mo, cstrs);
}
Also used : Serialize(org.btrplace.model.constraint.migration.Serialize) SatConstraint(org.btrplace.model.constraint.SatConstraint) Deadline(org.btrplace.model.constraint.migration.Deadline) ArrayList(java.util.ArrayList) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) Switch(org.btrplace.model.view.network.Switch) Network(org.btrplace.model.view.network.Network) Sync(org.btrplace.model.constraint.migration.Sync) Precedence(org.btrplace.model.constraint.migration.Precedence) HashSet(java.util.HashSet)

Example 3 with Switch

use of org.btrplace.model.view.network.Switch in project scheduler by btrplace.

the class NetworkConverter method physicalElementToJSON.

/**
 * Convert a PhysicalElement to a JSON object.
 *
 * @param pe the physical element to convert
 * @return  the JSON object
 * @throws IllegalArgumentException if the physical element is not supported
 */
public JSONObject physicalElementToJSON(PhysicalElement pe) {
    JSONObject o = new JSONObject();
    if (pe instanceof Node) {
        o.put("type", NODE_LABEL);
        o.put("id", ((Node) pe).id());
    } else if (pe instanceof Switch) {
        o.put("type", SWITCH_LABEL);
        o.put("id", ((Switch) pe).id());
    } else {
        throw new IllegalArgumentException("Unsupported physical element '" + pe.getClass().toString() + "'");
    }
    return o;
}
Also used : JSONObject(net.minidev.json.JSONObject) Switch(org.btrplace.model.view.network.Switch) Node(org.btrplace.model.Node) JSONs.requiredNode(org.btrplace.json.JSONs.requiredNode)

Example 4 with Switch

use of org.btrplace.model.view.network.Switch in project scheduler by btrplace.

the class CDeadlineTest method testKo.

@Test
public void testKo() throws SchedulerException {
    // New default model
    Model mo = new DefaultModel();
    Mapping ma = mo.getMapping();
    // Create and boot 2 source nodes and 1 destination node
    Node srcNode1 = mo.newNode(), srcNode2 = mo.newNode(), dstNode = mo.newNode();
    ma.addOnlineNode(srcNode1);
    ma.addOnlineNode(srcNode2);
    ma.addOnlineNode(dstNode);
    // Attach a network view
    Network net = new Network();
    mo.attach(net);
    // Connect the nodes through a main non-blocking switch with 1 Gbit/s links
    Switch swMain = net.newSwitch();
    net.connect(1000, swMain, srcNode1, srcNode2);
    net.connect(1000, swMain, dstNode);
    // Create and host 1 VM per source node
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    ma.addRunningVM(vm1, srcNode1);
    ma.addRunningVM(vm2, srcNode2);
    // Attach CPU and Mem resource views and assign nodes capacity and VMs consumption
    int mem_vm = 8, cpu_vm = 4, mem_src = 8, cpu_src = 4, mem_dst = 16, cpu_dst = 8;
    ShareableResource rcMem = new ShareableResource("mem", 0, 0), rcCPU = new ShareableResource("cpu", 0, 0);
    mo.attach(rcMem);
    mo.attach(rcCPU);
    // VMs
    rcMem.setConsumption(vm1, mem_vm).setConsumption(vm2, mem_vm);
    rcCPU.setConsumption(vm1, cpu_vm).setConsumption(vm2, cpu_vm);
    // Nodes
    rcMem.setCapacity(srcNode1, mem_src).setCapacity(srcNode2, mem_src).setCapacity(dstNode, mem_dst);
    rcCPU.setCapacity(srcNode1, cpu_src).setCapacity(srcNode2, cpu_src).setCapacity(dstNode, cpu_dst);
    // Set VM attributes 'memory used', 'hot dirty page size', 'hot dirty page duration' and 'cold dirty pages rate'
    int vm_mu = 6000, vm_mds = 46, vm_mdd = 2;
    double vm_cdr = 23.6;
    // vm1 is an 'idle' VM (with no special memory activity) but still consumes 6 GiB of memory
    mo.getAttributes().put(vm1, "memUsed", vm_mu);
    // vm2 consumes 6 GiB memory and has a memory intensive workload equivalent to "stress --vm 1000 --bytes 50K"
    // VM with a workload
    mo.getAttributes().put(vm2, "memUsed", vm_mu);
    mo.getAttributes().put(vm2, "hotDirtySize", vm_mds);
    mo.getAttributes().put(vm2, "hotDirtyDuration", vm_mdd);
    mo.getAttributes().put(vm2, "coldDirtyRate", vm_cdr);
    // Create constraints
    List<SatConstraint> cstrs = new ArrayList<>();
    // Placement constraints, we want to shutdown the source nodes to force the migration to destination nodes
    cstrs.add(new Offline(srcNode1));
    cstrs.add(new Offline(srcNode2));
    // SET A TOO SHORT DEADLINE FOR THE MIGRATION OF VM2
    // 30s
    Deadline dead = new Deadline(vm2, "+00:00:30");
    cstrs.add(dead);
    // Try to solve it using the Min Max Time To Repair Migration scheduling oriented objective
    ReconfigurationPlan p = new DefaultChocoScheduler().solve(mo, cstrs, new MinMTTRMig());
    Assert.assertNull(p);
}
Also used : SatConstraint(org.btrplace.model.constraint.SatConstraint) Deadline(org.btrplace.model.constraint.migration.Deadline) 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) MinMTTRMig(org.btrplace.model.constraint.migration.MinMTTRMig) Switch(org.btrplace.model.view.network.Switch) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Network(org.btrplace.model.view.network.Network) MigrateVM(org.btrplace.plan.event.MigrateVM) Test(org.testng.annotations.Test)

Example 5 with Switch

use of org.btrplace.model.view.network.Switch in project scheduler by btrplace.

the class NetworkTest method defaultTest.

/**
 * Test the instantiation and the creation of the objects using the default routing implementation.
 */
@Test
public void defaultTest() {
    Model mo = new DefaultModel();
    Network net = new Network();
    Switch s = net.newSwitch(1000);
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    net.connect(2000, s, n1, n2);
    Assert.assertNull(Network.get(mo));
    mo.attach(net);
    Assert.assertEquals(Network.get(mo), net);
    Assert.assertTrue(net.getSwitches().size() == 1);
    Assert.assertEquals(net.getSwitches().get(0), s);
    Assert.assertTrue(s.getCapacity() == 1000);
    Assert.assertTrue(net.getLinks().size() == 2);
    Assert.assertTrue(net.getLinks().size() == 2);
    for (Link l : net.getLinks()) {
        Assert.assertTrue(l.getCapacity() == 2000);
        Assert.assertTrue(l.getSwitch().equals(s) || l.getElement() instanceof Switch);
    }
    Assert.assertTrue(net.getRouting().getPath(n1, n2).size() == 2);
    Assert.assertTrue(net.getRouting().getPath(n1, n2).containsAll(net.getLinks()));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Switch(org.btrplace.model.view.network.Switch) Network(org.btrplace.model.view.network.Network) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Link(org.btrplace.model.view.network.Link) Test(org.testng.annotations.Test)

Aggregations

Switch (org.btrplace.model.view.network.Switch)21 Network (org.btrplace.model.view.network.Network)19 ArrayList (java.util.ArrayList)14 SatConstraint (org.btrplace.model.constraint.SatConstraint)13 ShareableResource (org.btrplace.model.view.ShareableResource)13 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)13 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)13 Test (org.testng.annotations.Test)12 Offline (org.btrplace.model.constraint.Offline)11 MinMTTRMig (org.btrplace.model.constraint.migration.MinMTTRMig)11 MigrateVM (org.btrplace.plan.event.MigrateVM)8 Node (org.btrplace.model.Node)7 Fence (org.btrplace.model.constraint.Fence)6 SchedulerException (org.btrplace.scheduler.SchedulerException)6 DefaultModel (org.btrplace.model.DefaultModel)4 Model (org.btrplace.model.Model)4 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)4 JSONObject (net.minidev.json.JSONObject)3 Deadline (org.btrplace.model.constraint.migration.Deadline)3 Sync (org.btrplace.model.constraint.migration.Sync)3