Search in sources :

Example 41 with ChocoScheduler

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

the class FixedSizePartitioningTest method basicTesting.

@Test
public void basicTesting() {
    FixedSizePartitioning f = new FixedSizePartitioning(1000);
    f.setWorkersCount(5);
    Assert.assertEquals(f.getWorkersCount(), 5);
    Assert.assertEquals(f.getSize(), 1000);
    ChocoScheduler cra = new DefaultChocoScheduler();
    cra.setInstanceSolver(f);
    Assert.assertEquals(cra.getInstanceSolver(), f);
    f.setSize(300);
    Assert.assertEquals(f.getSize(), 300);
    Assert.assertEquals(f.randomPickUp(), false);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) Test(org.testng.annotations.Test)

Example 42 with ChocoScheduler

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

the class CNetworkTest method testWithSwitchCapacity.

@Test
public void testWithSwitchCapacity() {
    Model mo = new DefaultModel();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    VM v = mo.newVM();
    mo.getMapping().on(n1, n2).run(n1, v);
    ShareableResource mem = new ShareableResource("mem", 10000, 5000);
    Network net = new Network();
    mo.attach(net);
    mo.attach(mem);
    mo.getAttributes().put(v, "memUsed", 10000);
    Switch sw = net.newSwitch(1000);
    net.connect(2000, sw, n1, n2);
    ChocoScheduler s = new DefaultChocoScheduler();
    ReconfigurationPlan p = s.solve(mo, Collections.singletonList(new Fence(v, n2)));
    Assert.assertNotNull(p);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Switch(org.btrplace.model.view.network.Switch) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) MigrateVM(org.btrplace.plan.event.MigrateVM) Network(org.btrplace.model.view.network.Network) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Fence(org.btrplace.model.constraint.Fence) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 43 with ChocoScheduler

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

the class CShareableResourceTest method testMaintainResourceUsage.

@Test
public void testMaintainResourceUsage() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    mo.getMapping().on(n1).run(n1, vm1, vm2);
    ShareableResource rc = new ShareableResource("foo");
    rc.setConsumption(vm1, 5);
    rc.setConsumption(vm2, 7);
    rc.setCapacity(n1, 25);
    mo.attach(rc);
    ChocoScheduler s = new DefaultChocoScheduler();
    ReconfigurationPlan p = s.solve(mo, new ArrayList<>());
    Assert.assertNotNull(p);
    // And on the resulting plan.
    Model res = p.getResult();
    ShareableResource resRc = ShareableResource.get(res, rc.getResourceIdentifier());
    Assert.assertEquals(resRc.getConsumption(vm1), 5);
    Assert.assertEquals(resRc.getConsumption(vm2), 7);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) ShareableResource(org.btrplace.model.view.ShareableResource) Test(org.testng.annotations.Test)

Example 44 with ChocoScheduler

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

the class CShareableResourceTest method testIssue170.

@Test
public void testIssue170() {
    String buf = "{\"model\": {\"mapping\": {\"readyVMs\": [],\"onlineNodes\": {\"0\": {\"sleepingVMs\": [],\"runningVMs\": []},\"1\": {\"sleepingVMs\": [],\"runningVMs\": []},\"2\": {\"sleepingVMs\": [],\"runningVMs\": [15, 14, 13, 12,11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]},\"3\": {\"sleepingVMs\": [],\"runningVMs\": []}},\"offlineNodes\": []},\"attributes\": {\"nodes\": {},\"vms\": {\"11\": {\"migrate\": 1},\"12\": {\"migrate\": 1},\"13\": {\"migrate\": 1},\"14\": {\"migrate\": 1},\"15\": {\"migrate\": 1},\"0\": {\"migrate\": 1},\"1\": {\"migrate\": 1},\"2\": {\"migrate\": 1},\"3\": {\"migrate\": 1},\"4\": {\"migrate\": 1},\"5\": {\"migrate\": 1},\"6\": {\"migrate\": 2},\"7\": {\"migrate\": 1},\"8\": {\"migrate\": 1},\"9\": {\"migrate\": 1},\"10\": {\"migrate\": 1}}},\"views\": [{\"defConsumption\": 0,\"nodes\": {\"0\": 239094,\"1\": 111355,\"2\": 239725,\"3\": 110774},\"rcId\": \"memory\",\"id\": \"shareableResource\",\"defCapacity\": 0,\"vms\": {\"11\": 1082,\"12\": 1082,\"13\": 1082,\"14\": 1082,\"15\": 1082,\"0\": 1082,\"1\": 1082,\"2\": 1082,\"3\": 1082,\"4\": 1082,\"5\": 1082,\"6\": 1082,\"7\": 1082,\"8\": 1082,\"9\": 1082,\"10\": 1082}}, {\"defConsumption\": 0,\"nodes\": {\"0\": 63913,\"1\": 61663,\"2\": 67200,\"3\": 61620},\"rcId\": \"cpu\",\"id\": \"shareableResource\",\"defCapacity\": 0,\"vms\": {\"11\": 1271,\"12\": 1263,\"13\": 1257,\"14\": 1243,\"15\": 1253,\"0\": 1252,\"1\": 1238,\"2\": 1236,\"3\": 1253,\"4\": 1257,\"5\": 1244,\"6\": 1255,\"7\": 1251,\"8\": 1244,\"9\": 1240,\"10\": 1246}}, {\"defConsumption\": 0,\"nodes\": {\"0\": 7498,\"1\": 6854,\"2\": 7560,\"3\": 7560},\"rcId\": \"controller_cpu\",\"id\": \"shareableResource\",\"defCapacity\": 0,\"vms\": {\"11\": 431,\"12\": 435,\"13\": 432,\"14\": 423,\"15\": 430,\"0\": 430,\"1\": 420,\"2\": 425,\"3\": 430,\"4\": 429,\"5\": 425,\"6\": 431,\"7\": 429,\"8\": 424,\"9\": 426,\"10\": 428}}]},\"constraints\": [{\"rc\": \"cpu\",\"amount\": 26912,\"nodes\": [0],\"continuous\": false,\"id\": \"resourceCapacity\"}, {\"rc\": \"controller_cpu\",\"amount\": 5608,\"nodes\": [0],\"continuous\": false,\"id\": \"resourceCapacity\"}, {\"rc\": \"cpu\",\"amount\": 25093,\"nodes\": [1],\"continuous\": false,\"id\": \"resourceCapacity\"}, {\"rc\": \"controller_cpu\",\"amount\": 4964,\"nodes\": [1],\"continuous\": false,\"id\": \"resourceCapacity\"}, {\"rc\": \"cpu\",\"amount\": 29568,\"nodes\": [2],\"continuous\": false,\"id\": \"resourceCapacity\"}, {\"rc\": \"controller_cpu\",\"amount\": 5670,\"nodes\": [2],\"continuous\": false,\"id\": \"resourceCapacity\"}, {\"rc\": \"controller_cpu\",\"amount\": 516,\"vm\": 0,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 505,\"vm\": 1,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 510,\"vm\": 2,\"id\": \"preserve\"},{\"rc\": \"controller_cpu\",\"amount\": 516,\"vm\": 3,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 515,\"vm\": 4,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 510,\"vm\": 5,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 517,\"vm\": 6,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 515,\"vm\": 7,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 509,\"vm\": 8,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 511,\"vm\": 9,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 514,\"vm\": 10,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 517,\"vm\": 11,\"id\": \"preserve\"},{\"rc\": \"controller_cpu\",\"amount\": 522,\"vm\": 12,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 519,\"vm\": 13,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 508,\"vm\": 14,\"id\": \"preserve\"}, {\"rc\": \"controller_cpu\",\"amount\": 516,\"vm\": 15,\"id\": \"preserve\"}, {\"rc\": \"cpu\",\"amount\": 25059,\"nodes\": [3],\"continuous\": false,\"id\": \"resourceCapacity\"}, {\"rc\": \"controller_cpu\",\"amount\": 5670,\"nodes\": [3],\"continuous\": false,\"id\": \"resourceCapacity\"}],\"objective\": {\"id\": \"minimizeMigrations\"}}";
    Instance i = JSON.readInstance(new StringReader(buf));
    ChocoScheduler s = new DefaultChocoScheduler();
    ReconfigurationPlan plan = s.solve(i);
    Assert.assertNotNull(plan);
}
Also used : DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) Instance(org.btrplace.model.Instance) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) StringReader(java.io.StringReader) Test(org.testng.annotations.Test)

Example 45 with ChocoScheduler

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

the class CShareableResourceTest method testRealNodeUsage.

/**
 * Place some VMs and check realNodeUsage is updated accordingly
 */
@Test
public void testRealNodeUsage() throws SchedulerException {
    Model mo = new DefaultModel();
    Mapping ma = mo.getMapping();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    ma.addOnlineNode(n1);
    ma.addOnlineNode(n2);
    ma.addRunningVM(vm1, n1);
    ma.addRunningVM(vm2, n1);
    ShareableResource rc = new ShareableResource("foo", 0, 0);
    rc.setConsumption(vm1, 2);
    rc.setConsumption(vm2, 3);
    rc.setCapacity(n1, 5);
    rc.setCapacity(n2, 3);
    mo.attach(rc);
    ChocoScheduler s = new DefaultChocoScheduler();
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(new Fence(vm1, n1));
    cstrs.add(new Fence(vm2, n2));
    ReconfigurationPlan p = s.solve(mo, cstrs);
    Assert.assertNotNull(p);
    Model res = p.getResult();
    rc = (ShareableResource.get(res, "foo"));
    // rcm.getVirtualUsage(0).isInstantiatedTo(2));
    Assert.assertEquals(2, rc.getConsumption(vm1));
    // rcm.getVirtualUsage(1).isInstantiatedTo(3));
    Assert.assertEquals(3, rc.getConsumption(vm2));
}
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) Mapping(org.btrplace.model.Mapping) ShareableResource(org.btrplace.model.view.ShareableResource) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Aggregations

ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)82 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)82 Test (org.testng.annotations.Test)76 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)73 ShareableResource (org.btrplace.model.view.ShareableResource)30 SatConstraint (org.btrplace.model.constraint.SatConstraint)28 ArrayList (java.util.ArrayList)25 DefaultModel (org.btrplace.model.DefaultModel)17 Model (org.btrplace.model.Model)17 Node (org.btrplace.model.Node)17 VM (org.btrplace.model.VM)16 BootVM (org.btrplace.plan.event.BootVM)12 ShutdownVM (org.btrplace.plan.event.ShutdownVM)12 MigrateVM (org.btrplace.plan.event.MigrateVM)10 Fence (org.btrplace.model.constraint.Fence)9 Preserve (org.btrplace.model.constraint.Preserve)8 org.btrplace.model.constraint (org.btrplace.model.constraint)7 MaxOnline (org.btrplace.model.constraint.MaxOnline)6 org.btrplace.model (org.btrplace.model)5 SchedulerException (org.btrplace.scheduler.SchedulerException)5