Search in sources :

Example 26 with Node

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

the class MaxOnlineTest method testInstantiation.

@Test
public void testInstantiation() {
    Model mo = new DefaultModel();
    Set<Node> s = new HashSet<>(Arrays.asList(mo.newNode(), mo.newNode()));
    MaxOnline o = new MaxOnline(s, 3);
    Assert.assertNotNull(o.getChecker());
    Assert.assertEquals(o.getInvolvedNodes(), s);
    Assert.assertTrue(o.getInvolvedVMs().isEmpty());
    Assert.assertNotNull(o.toString());
    Assert.assertFalse(o.isContinuous());
    Assert.assertTrue(o.setContinuous(true));
    Assert.assertTrue(o.isContinuous());
    Assert.assertTrue(o.setContinuous(false));
    Assert.assertTrue(o.equals(new MaxOnline(s, 3)));
    Assert.assertEquals(o.hashCode(), new MaxOnline(s, 3, false).hashCode());
    Assert.assertFalse(o.equals(new MaxOnline(s, 4)));
    Assert.assertFalse(o.equals(new MaxOnline(Collections.singleton(mo.newNode()), 3)));
    Assert.assertFalse(o.equals(new MaxOnline(s, 3, true)));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 27 with Node

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

the class OverbookTest method testEquals.

@Test
public void testEquals() {
    Model mo = new DefaultModel();
    Node n = mo.newNode();
    Overbook s = new Overbook(n, "foo", 3);
    Assert.assertTrue(s.equals(s));
    Overbook o2 = new Overbook(n, "foo", 3);
    Assert.assertTrue(o2.equals(s));
    Assert.assertEquals(o2.hashCode(), s.hashCode());
    Assert.assertFalse(new Overbook(n, "bar", 3).equals(s));
    Assert.assertFalse(new Overbook(n, "foo", 2).equals(s));
    Assert.assertFalse(new Overbook(mo.newNode(), "foo", 3).equals(s));
    Assert.assertNotEquals(new Overbook(mo.newNode(), "foo", 3, true), new Overbook(mo.newNode(), "foo", 3, false));
    Assert.assertNotEquals(new Overbook(mo.newNode(), "foo", 3, true).hashCode(), new Overbook(mo.newNode(), "foo", 3, false).hashCode());
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 28 with Node

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

the class OverbookTest method testContinuousIsSatisfied.

@Test
public void testContinuousIsSatisfied() {
    Model mo = new DefaultModel();
    List<VM> vms = Util.newVMs(mo, 10);
    Node n0 = mo.newNode();
    Node n1 = mo.newNode();
    Model i = new DefaultModel();
    Mapping cfg = i.getMapping();
    cfg.addOnlineNode(n0);
    cfg.addOnlineNode(n1);
    ShareableResource rc = new ShareableResource("cpu");
    rc.setCapacity(n0, 1);
    rc.setCapacity(n1, 4);
    rc.setConsumption(vms.get(0), 2);
    rc.setConsumption(vms.get(1), 2);
    rc.setConsumption(vms.get(2), 4);
    cfg.addRunningVM(vms.get(0), n0);
    cfg.addRunningVM(vms.get(1), n1);
    cfg.addRunningVM(vms.get(2), n1);
    cfg.addRunningVM(vms.get(3), n1);
    i.attach(rc);
    Overbook o = new Overbook(n1, "cpu", 2);
    o.setContinuous(true);
    ReconfigurationPlan p = new DefaultReconfigurationPlan(i);
    Assert.assertEquals(o.isSatisfied(p), true);
    p.add(new Allocate(vms.get(0), n0, "cpu", 1, 2, 5));
    Assert.assertEquals(o.isSatisfied(p), true);
    p.add(new Allocate(vms.get(1), n1, "cpu", 5, 2, 5));
    Assert.assertEquals(o.isSatisfied(p), false);
    p.add(new Allocate(vms.get(2), n1, "cpu", 2, 0, 1));
    Assert.assertEquals(o.isSatisfied(p), true);
    p.add(new Allocate(vms.get(3), n1, "cpu", 3, 4, 6));
    Assert.assertEquals(o.isSatisfied(p), false);
    p.add(new ShutdownVM(vms.get(2), n1, 2, 3));
    Assert.assertEquals(o.isSatisfied(p), true);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) VM(org.btrplace.model.VM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Node(org.btrplace.model.Node) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Mapping(org.btrplace.model.Mapping) ShareableResource(org.btrplace.model.view.ShareableResource) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Allocate(org.btrplace.plan.event.Allocate) Test(org.testng.annotations.Test)

Example 29 with Node

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

the class QuarantineTest method testQuarantines.

@Test
public void testQuarantines() {
    Model mo = new DefaultModel();
    List<Node> ns = Util.newNodes(mo, 5);
    List<Quarantine> qs = Quarantine.newQuarantine(ns);
    Assert.assertEquals(qs.size(), ns.size());
    qs.stream().forEach((q) -> {
        Assert.assertTrue(ns.containsAll(q.getInvolvedNodes()));
        Assert.assertTrue(q.isContinuous());
    });
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 30 with Node

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

the class QuarantineTest method testEqualsHashCode.

@Test
public void testEqualsHashCode() {
    Model mo = new DefaultModel();
    Node n = mo.newNode();
    Quarantine q = new Quarantine(n);
    Assert.assertTrue(q.equals(q));
    Assert.assertTrue(q.equals(new Quarantine(n)));
    Assert.assertEquals(q.hashCode(), new Quarantine(n).hashCode());
    Assert.assertFalse(q.equals(new Quarantine(mo.newNode())));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Aggregations

Node (org.btrplace.model.Node)382 DefaultModel (org.btrplace.model.DefaultModel)278 Model (org.btrplace.model.Model)276 VM (org.btrplace.model.VM)262 Test (org.testng.annotations.Test)259 Mapping (org.btrplace.model.Mapping)187 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)142 HashSet (java.util.HashSet)95 SatConstraint (org.btrplace.model.constraint.SatConstraint)87 ArrayList (java.util.ArrayList)86 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)82 MigrateVM (org.btrplace.plan.event.MigrateVM)72 ShareableResource (org.btrplace.model.view.ShareableResource)71 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)64 ShutdownNode (org.btrplace.plan.event.ShutdownNode)52 Instance (org.btrplace.model.Instance)43 BootNode (org.btrplace.plan.event.BootNode)41 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)40 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)36 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)36