Search in sources :

Example 31 with Instance

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

the class OfflineSplitterTest method simpleTest.

@Test
public void simpleTest() {
    OfflineSplitter splitter = new OfflineSplitter();
    List<Instance> instances = new ArrayList<>();
    Model m0 = new DefaultModel();
    Node n = m0.newNode();
    m0.getMapping().addOfflineNode(n);
    m0.getMapping().addOfflineNode(m0.newNode(1));
    Model m1 = new DefaultModel();
    m1.getMapping().addOfflineNode(m1.newNode(2));
    m1.getMapping().addOfflineNode(m1.newNode(3));
    instances.add(new Instance(m0, new ArrayList<>(), new MinMTTR()));
    instances.add(new Instance(m1, new ArrayList<>(), new MinMTTR()));
    Set<Node> all = new HashSet<>(m0.getMapping().getAllNodes());
    all.addAll(m1.getMapping().getAllNodes());
    TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
    // Only nodes in m0
    Offline oSimple = new Offline(n);
    Assert.assertTrue(splitter.split(oSimple, null, instances, new TIntIntHashMap(), nodeIndex));
    Assert.assertTrue(instances.get(0).getSatConstraints().contains(oSimple));
    Assert.assertFalse(instances.get(1).getSatConstraints().contains(oSimple));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) ArrayList(java.util.ArrayList) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR) Offline(org.btrplace.model.constraint.Offline) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 32 with Instance

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

the class PreserveSplitterTest method simpleTest.

@Test
public void simpleTest() {
    PreserveSplitter splitter = new PreserveSplitter();
    List<Instance> instances = new ArrayList<>();
    Model m0 = new DefaultModel();
    VM v = m0.newVM(1);
    m0.getMapping().addReadyVM(v);
    m0.getMapping().addRunningVM(m0.newVM(2), m0.newNode(1));
    Model m1 = new DefaultModel();
    m1.getMapping().addReadyVM(m1.newVM(3));
    m1.getMapping().addSleepingVM(m1.newVM(4), m1.newNode(2));
    m1.getMapping().addRunningVM(m1.newVM(5), m1.newNode(3));
    instances.add(new Instance(m0, new ArrayList<>(), new MinMTTR()));
    instances.add(new Instance(m1, new ArrayList<>(), new MinMTTR()));
    TIntIntHashMap index = Instances.makeVMIndex(instances);
    Set<VM> all = new HashSet<>(m0.getMapping().getAllVMs());
    all.addAll(m1.getMapping().getAllVMs());
    // Only VMs in m0
    Preserve single = new Preserve(v, "foo", 3);
    Assert.assertTrue(splitter.split(single, null, instances, index, new TIntIntHashMap()));
    Assert.assertTrue(instances.get(0).getSatConstraints().contains(single));
    Assert.assertFalse(instances.get(1).getSatConstraints().contains(single));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) VM(org.btrplace.model.VM) ArrayList(java.util.ArrayList) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) Preserve(org.btrplace.model.constraint.Preserve) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 33 with Instance

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

the class ReadySplitterTest method simpleTest.

@Test
public void simpleTest() {
    ReadySplitter splitter = new ReadySplitter();
    List<Instance> instances = new ArrayList<>();
    Model m0 = new DefaultModel();
    VM v = m0.newVM(1);
    m0.getMapping().addReadyVM(v);
    m0.getMapping().addRunningVM(m0.newVM(2), m0.newNode(1));
    Model m1 = new DefaultModel();
    m1.getMapping().addReadyVM(m1.newVM(3));
    m1.getMapping().addSleepingVM(m1.newVM(4), m1.newNode(2));
    m1.getMapping().addRunningVM(m1.newVM(5), m1.newNode(3));
    instances.add(new Instance(m0, new ArrayList<>(), new MinMTTR()));
    instances.add(new Instance(m1, new ArrayList<>(), new MinMTTR()));
    Set<VM> all = new HashSet<>(m0.getMapping().getAllVMs());
    all.addAll(m1.getMapping().getAllVMs());
    TIntIntHashMap index = Instances.makeVMIndex(instances);
    // Only VMs in m0
    Ready single = new Ready(v);
    Assert.assertTrue(splitter.split(single, null, instances, index, new TIntIntHashMap()));
    Assert.assertTrue(instances.get(0).getSatConstraints().contains(single));
    Assert.assertFalse(instances.get(1).getSatConstraints().contains(single));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Ready(org.btrplace.model.constraint.Ready) Instance(org.btrplace.model.Instance) VM(org.btrplace.model.VM) ArrayList(java.util.ArrayList) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 34 with Instance

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

the class RootSplitterTest method simpleTest.

@Test
public void simpleTest() {
    RootSplitter splitter = new RootSplitter();
    List<Instance> instances = new ArrayList<>();
    Model m0 = new DefaultModel();
    VM v = m0.newVM(1);
    m0.getMapping().addReadyVM(v);
    m0.getMapping().addRunningVM(m0.newVM(2), m0.newNode(1));
    Model m1 = new DefaultModel();
    m1.getMapping().addReadyVM(m1.newVM(3));
    m1.getMapping().addSleepingVM(m1.newVM(4), m1.newNode(2));
    m1.getMapping().addRunningVM(m1.newVM(5), m1.newNode(3));
    instances.add(new Instance(m0, new ArrayList<>(), new MinMTTR()));
    instances.add(new Instance(m1, new ArrayList<>(), new MinMTTR()));
    Set<VM> all = new HashSet<>(m0.getMapping().getAllVMs());
    all.addAll(m1.getMapping().getAllVMs());
    TIntIntHashMap index = Instances.makeVMIndex(instances);
    // Only VMs in m0
    Root single = new Root(v);
    Assert.assertTrue(splitter.split(single, null, instances, index, new TIntIntHashMap()));
    Assert.assertTrue(instances.get(0).getSatConstraints().contains(single));
    Assert.assertFalse(instances.get(1).getSatConstraints().contains(single));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Root(org.btrplace.model.constraint.Root) Instance(org.btrplace.model.Instance) VM(org.btrplace.model.VM) ArrayList(java.util.ArrayList) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) MinMTTR(org.btrplace.model.constraint.MinMTTR) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

Instance (org.btrplace.model.Instance)34 Test (org.testng.annotations.Test)24 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)20 Model (org.btrplace.model.Model)19 ArrayList (java.util.ArrayList)17 DefaultModel (org.btrplace.model.DefaultModel)14 MinMTTR (org.btrplace.model.constraint.MinMTTR)13 TIntIntHashMap (gnu.trove.map.hash.TIntIntHashMap)12 Node (org.btrplace.model.Node)12 VM (org.btrplace.model.VM)12 StringReader (java.io.StringReader)10 HashSet (java.util.HashSet)10 SatConstraint (org.btrplace.model.constraint.SatConstraint)8 List (java.util.List)5 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)5 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)4 File (java.io.File)3 MinMigrations (org.btrplace.model.constraint.MinMigrations)3 Spread (org.btrplace.model.constraint.Spread)3 MigrateVM (org.btrplace.plan.event.MigrateVM)3