Search in sources :

Example 41 with MinMTTR

use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.

the class LonelySplitterTest method simpleTest.

@Test
public void simpleTest() {
    LonelySplitter splitter = new LonelySplitter();
    List<Instance> instances = new ArrayList<>();
    Model m0 = new DefaultModel();
    m0.getMapping().addReadyVM(m0.newVM(1));
    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
    Lonely single = new Lonely(m0.getMapping().getAllVMs());
    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));
    // All the VMs, test the split
    Lonely among = new Lonely(all, false);
    Assert.assertTrue(splitter.split(among, null, instances, index, new TIntIntHashMap()));
    Assert.assertTrue(instances.get(0).getSatConstraints().contains(new Lonely(m0.getMapping().getAllVMs(), false)));
    Assert.assertTrue(instances.get(1).getSatConstraints().contains(new Lonely(m1.getMapping().getAllVMs(), false)));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) VM(org.btrplace.model.VM) Lonely(org.btrplace.model.constraint.Lonely) 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 42 with MinMTTR

use of org.btrplace.model.constraint.MinMTTR 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 43 with MinMTTR

use of org.btrplace.model.constraint.MinMTTR 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 44 with MinMTTR

use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.

the class SpreadSplitterTest method simpleTest.

@Test
public void simpleTest() {
    SpreadSplitter splitter = new SpreadSplitter();
    List<Instance> instances = new ArrayList<>();
    Model m0 = new DefaultModel();
    m0.getMapping().addReadyVM(m0.newVM(1));
    Node n1 = m0.newNode();
    m0.getMapping().addOnlineNode(n1);
    m0.getMapping().addRunningVM(m0.newVM(2), n1);
    Model m1 = new DefaultModel();
    m1.getMapping().addReadyVM(m1.newVM(3));
    Node n2 = m1.newNode();
    Node n3 = m1.newNode();
    m1.getMapping().addOnlineNode(n2);
    m1.getMapping().addOnlineNode(n3);
    m1.getMapping().addSleepingVM(m1.newVM(4), n2);
    m1.getMapping().addRunningVM(m1.newVM(5), n3);
    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
    Spread spreadSingle = new Spread(m0.getMapping().getAllVMs());
    Assert.assertTrue(splitter.split(spreadSingle, null, instances, index, new TIntIntHashMap()));
    Assert.assertTrue(instances.get(0).getSatConstraints().contains(spreadSingle));
    Assert.assertFalse(instances.get(1).getSatConstraints().contains(spreadSingle));
    // All the VMs, test the split
    Spread spreadAmong = new Spread(all, false);
    Assert.assertTrue(splitter.split(spreadAmong, null, instances, index, new TIntIntHashMap()));
    Assert.assertTrue(instances.get(0).getSatConstraints().contains(new Spread(m0.getMapping().getAllVMs(), false)));
    Assert.assertTrue(instances.get(1).getSatConstraints().contains(new Spread(m1.getMapping().getAllVMs(), false)));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) ArrayList(java.util.ArrayList) MinMTTR(org.btrplace.model.constraint.MinMTTR) Spread(org.btrplace.model.constraint.Spread) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 45 with MinMTTR

use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.

the class BanSplitterTest method simpleTest.

@Test
public void simpleTest() {
    BanSplitter splitter = new BanSplitter();
    List<Instance> instances = new ArrayList<>();
    Model origin = new DefaultModel();
    Node n1 = origin.newNode();
    Node n2 = origin.newNode();
    VM vm1 = origin.newVM();
    VM vm2 = origin.newVM();
    VM vm3 = origin.newVM();
    VM vm4 = origin.newVM();
    /**
     * READY: vm1
     * n1 vm2
     * n2 (vm3) vm4
     */
    origin.getMapping().addOnlineNode(n1);
    origin.getMapping().addReadyVM(vm1);
    origin.getMapping().addRunningVM(vm2, n1);
    origin.getMapping().addOnlineNode(n2);
    origin.getMapping().addSleepingVM(vm3, n2);
    origin.getMapping().addRunningVM(vm4, n2);
    Model m0 = new DefaultModel();
    m0.newNode(n1.id());
    m0.newVM(vm1.id());
    m0.newVM(vm2.id());
    m0.getMapping().addOnlineNode(n1);
    m0.getMapping().addReadyVM(vm1);
    m0.getMapping().addRunningVM(vm2, n1);
    Model m1 = new DefaultModel();
    m1.newNode(n2.id());
    m1.newVM(vm3.id());
    m1.newVM(vm4.id());
    m1.getMapping().addOnlineNode(n2);
    m1.getMapping().addSleepingVM(vm3, n2);
    m1.getMapping().addRunningVM(vm4, n2);
    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 vmIndex = Instances.makeVMIndex(instances);
    TIntIntHashMap nodeIndex = Instances.makeNodeIndex(instances);
    // Only VMs & nodes in m0
    Ban single = new Ban(vm1, m0.getMapping().getAllNodes());
    Assert.assertTrue(splitter.split(single, null, instances, vmIndex, nodeIndex));
    Assert.assertTrue(instances.get(0).getSatConstraints().contains(single));
    Assert.assertFalse(instances.get(1).getSatConstraints().contains(single));
    // All the VMs, nodes in m1.
    Ban among = new Ban(vm3, m1.getMapping().getAllNodes());
    Assert.assertTrue(splitter.split(among, null, instances, vmIndex, nodeIndex));
    Assert.assertTrue(instances.get(0).getSatConstraints().contains(new Ban(vm1, m0.getMapping().getAllNodes())));
    Assert.assertTrue(instances.get(1).getSatConstraints().contains(new Ban(vm3, m1.getMapping().getAllNodes())));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Instance(org.btrplace.model.Instance) Node(org.btrplace.model.Node) ArrayList(java.util.ArrayList) MinMTTR(org.btrplace.model.constraint.MinMTTR) Ban(org.btrplace.model.constraint.Ban) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

MinMTTR (org.btrplace.model.constraint.MinMTTR)47 Model (org.btrplace.model.Model)42 Instance (org.btrplace.model.Instance)41 Test (org.testng.annotations.Test)41 DefaultModel (org.btrplace.model.DefaultModel)40 Node (org.btrplace.model.Node)33 VM (org.btrplace.model.VM)33 ArrayList (java.util.ArrayList)22 HashSet (java.util.HashSet)22 TIntIntHashMap (gnu.trove.map.hash.TIntIntHashMap)15 SatConstraint (org.btrplace.model.constraint.SatConstraint)10 Mapping (org.btrplace.model.Mapping)9 Running (org.btrplace.model.constraint.Running)8 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)8 Collection (java.util.Collection)6 Offline (org.btrplace.model.constraint.Offline)5 ShareableResource (org.btrplace.model.view.ShareableResource)5 Spread (org.btrplace.model.constraint.Spread)4 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)4 Ban (org.btrplace.model.constraint.Ban)3