Search in sources :

Example 56 with Node

use of org.btrplace.model.Node 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());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) ArrayList(java.util.ArrayList) ShareableResource(org.btrplace.model.view.ShareableResource) SatConstraint(org.btrplace.model.constraint.SatConstraint) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) MaxOnline(org.btrplace.model.constraint.MaxOnline) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel)

Example 57 with Node

use of org.btrplace.model.Node in project scheduler by btrplace.

the class JSONs method nodesFromJSON.

/**
 * Convert an array of VM identifiers to a set of VMs.
 * This operation uses a cache of previously converted set of nodes.
 * @param mo the associated model to browse
 * @param a the json array
 * @return the set of nodes
 */
public static List<Node> nodesFromJSON(Model mo, JSONArray a) throws JSONConverterException {
    String json = a.toJSONString();
    List<Node> s = nodesCache.get(json);
    if (s != null) {
        return s;
    }
    s = new ArrayList<>(a.size());
    for (Object o : a) {
        s.add(getNode(mo, (int) o));
    }
    nodesCache.put(json, s);
    return s;
}
Also used : Node(org.btrplace.model.Node) JSONObject(net.minidev.json.JSONObject)

Example 58 with Node

use of org.btrplace.model.Node in project scheduler by btrplace.

the class ReconfigurationPlanFuzzer method setInitialState.

private void setInitialState(ReconfigurationPlan p, VM v) {
    Mapping map = p.getOrigin().getMapping();
    Set<Node> onlines = map.getOnlineNodes();
    if (onlines.isEmpty()) {
        map.addReadyVM(v);
        return;
    }
    // CDF to consider the distribution
    int n = rnd.nextInt(srcReadyVMs + srcRunningVMs + srcSleepingVMs);
    if (n < srcReadyVMs) {
        map.addReadyVM(v);
    } else if (n < srcReadyVMs + srcRunningVMs) {
        map.addRunningVM(v, pick(onlines));
    } else {
        map.addSleepingVM(v, pick(onlines));
    }
}
Also used : Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Mapping(org.btrplace.model.Mapping)

Example 59 with Node

use of org.btrplace.model.Node in project scheduler by btrplace.

the class ReconfigurationSimulator method visit.

@Override
public Object visit(KillVM a) {
    if (start) {
        co.getMapping().state(a.getVM(), VMStateType.Type.TERMINATED);
        return null;
    }
    Node n = a.getNode();
    if (n != null) {
        co.getMapping().unhost(n, a.getVM());
        co.getMapping().desactivate(a.getVM());
        co.getMapping().state(a.getVM(), VMStateType.Type.TERMINATED);
    }
    return null;
}
Also used : Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode)

Example 60 with Node

use of org.btrplace.model.Node in project scheduler by btrplace.

the class FixedSizePartitioning method randomPartitions.

private List<Collection<Node>> randomPartitions(long seed, Mapping map) {
    Random rnd = new Random(seed);
    List<Node> unselectedNodes = new ArrayList<>(map.getNbNodes());
    unselectedNodes.addAll(map.getOnlineNodes());
    unselectedNodes.addAll(map.getOfflineNodes());
    List<Collection<Node>> partOfNodes = new ArrayList<>();
    Set<Node> curPartition = new HashSet<>(partSize);
    partOfNodes.add(curPartition);
    while (!unselectedNodes.isEmpty()) {
        Node n = unselectedNodes.remove(rnd.nextInt(unselectedNodes.size()));
        if (curPartition.size() == partSize) {
            curPartition = new HashSet<>(partSize);
            partOfNodes.add(curPartition);
        }
        curPartition.add(n);
    }
    return partOfNodes;
}
Also used : Node(org.btrplace.model.Node)

Aggregations

Node (org.btrplace.model.Node)188 VM (org.btrplace.model.VM)110 Model (org.btrplace.model.Model)92 DefaultModel (org.btrplace.model.DefaultModel)91 Test (org.testng.annotations.Test)85 Mapping (org.btrplace.model.Mapping)68 HashSet (java.util.HashSet)48 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)43 SatConstraint (org.btrplace.model.constraint.SatConstraint)35 ArrayList (java.util.ArrayList)34 IntVar (org.chocosolver.solver.variables.IntVar)29 ShareableResource (org.btrplace.model.view.ShareableResource)28 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)23 MigrateVM (org.btrplace.plan.event.MigrateVM)22 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)19 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)19 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)19 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)18 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)16 BootVM (org.btrplace.scheduler.choco.transition.BootVM)16