Search in sources :

Example 66 with Model

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

the class SyncConverterTest method testViables.

@Test
public void testViables() throws JSONConverterException {
    Model mo = new DefaultModel();
    ConstraintsConverter conv = new ConstraintsConverter();
    conv.register(new SyncConverter());
    Sync sync = new Sync(mo.newVM(), mo.newVM());
    Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(sync)).toString(), sync.toString());
    System.out.println(conv.toJSON(sync));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) ConstraintsConverter(org.btrplace.json.model.constraint.ConstraintsConverter) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Sync(org.btrplace.model.constraint.migration.Sync) Test(org.testng.annotations.Test)

Example 67 with Model

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

the class NamingServiceConverterTest method test.

@Test
public void test() throws JSONConverterException {
    NamingService<VM> ns = NamingService.newVMNS();
    Model mo = new DefaultModel();
    for (int i = 0; i < 10; i++) {
        VM v = mo.newVM();
        ns.register(v, "VM " + i);
    }
    NamingServiceConverter nsc = new NamingServiceConverter();
    JSONObject o = nsc.toJSON(ns);
    System.out.println(o);
    @SuppressWarnings("unchecked") NamingService<VM> ns2 = (NamingService<VM>) nsc.fromJSON(mo, o);
    Assert.assertEquals(ns, ns2);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) JSONObject(net.minidev.json.JSONObject) NamingService(org.btrplace.model.view.NamingService) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 68 with Model

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

the class CQuarantineTest method testWithNoSolution2.

/**
 * A VM try to leave the quarantine zone.
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testWithNoSolution2() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2, vm3).run(n3, vm4);
    Quarantine q = new Quarantine(n2);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(q);
    cstrs.add(new Fence(vm1, Collections.singleton(n2)));
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(p);
}
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) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Quarantine(org.btrplace.model.constraint.Quarantine) ArrayList(java.util.ArrayList) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Example 69 with Model

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

the class CQuarantineTest method testWithNoSolution1.

/**
 * A VM try to come into the quarantine zone.
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testWithNoSolution1() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2, vm3).run(n3, vm4);
    Quarantine q = new Quarantine(n1);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(q);
    cstrs.add(new Fence(vm4, Collections.singleton(n1)));
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(p);
}
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) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Quarantine(org.btrplace.model.constraint.Quarantine) ArrayList(java.util.ArrayList) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Example 70 with Model

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

the class ChocoMapperTest method testMap.

@Test(dependsOnMethods = { "testInstantiate" })
public void testMap() {
    Model mo = new DefaultModel();
    ChocoMapper map = ChocoMapper.newBundle();
    Spread s = new Spread(Collections.singleton(mo.newVM()));
    ChocoConstraint c = map.get(s);
    Assert.assertTrue(c.getClass().equals(CSpread.class));
    map.unMapConstraint(Spread.class);
    map.mapConstraint(Spread.class, CSpread.class);
    c = map.get(s);
    Assert.assertTrue(c.getClass().equals(CSpread.class));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Spread(org.btrplace.model.constraint.Spread) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Aggregations

Model (org.btrplace.model.Model)171 DefaultModel (org.btrplace.model.DefaultModel)157 Test (org.testng.annotations.Test)145 Node (org.btrplace.model.Node)91 VM (org.btrplace.model.VM)89 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)46 Mapping (org.btrplace.model.Mapping)41 HashSet (java.util.HashSet)39 ArrayList (java.util.ArrayList)30 SatConstraint (org.btrplace.model.constraint.SatConstraint)29 ShareableResource (org.btrplace.model.view.ShareableResource)27 Instance (org.btrplace.model.Instance)19 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)19 MigrateVM (org.btrplace.plan.event.MigrateVM)18 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)18 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)17 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)17 MinMTTR (org.btrplace.model.constraint.MinMTTR)16 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)16 BootVM (org.btrplace.scheduler.choco.transition.BootVM)16