Search in sources :

Example 21 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class ActionTest method testBasics.

@Test
public void testBasics() {
    Action a1 = new MockAction(new VM(1), 1, 3);
    Assert.assertEquals(1, a1.getStart());
    Assert.assertEquals(3, a1.getEnd());
    Assert.assertTrue(a1.getEvents(Action.Hook.PRE).isEmpty());
    Assert.assertTrue(a1.getEvents(Action.Hook.POST).isEmpty());
}
Also used : Action(org.btrplace.plan.event.Action) VM(org.btrplace.model.VM) Test(org.testng.annotations.Test)

Example 22 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class DefaultReconfigurationPlanTest method testDumb.

@Test
public void testDumb() {
    Model mo = new DefaultModel();
    VM v = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    mo.getMapping().addOnlineNode(n1);
    mo.getMapping().addOnlineNode(n2);
    mo.getMapping().addRunningVM(v, n1);
    ReconfigurationPlan p1 = new DefaultReconfigurationPlan(mo);
    Action a1 = new SuspendVM(v, n1, n1, 0, 1);
    Action a2 = new ShutdownNode(n1, 1, 2);
    Action a3 = new ShutdownNode(n2, 1, 2);
    Assert.assertTrue(p1.add(a1));
    Assert.assertTrue(p1.add(a2));
    Assert.assertTrue(p1.add(a3));
    Assert.assertTrue(p1.getActions().contains(a1));
    Assert.assertTrue(p1.getActions().contains(a2));
    Assert.assertTrue(p1.getActions().contains(a3));
}
Also used : Action(org.btrplace.plan.event.Action) SuspendVM(org.btrplace.plan.event.SuspendVM) MigrateVM(org.btrplace.plan.event.MigrateVM) SuspendVM(org.btrplace.plan.event.SuspendVM) ShutdownNode(org.btrplace.plan.event.ShutdownNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Test(org.testng.annotations.Test)

Example 23 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class DependencyTest method testInstantiation.

@Test
public void testInstantiation() {
    Action a = new MockAction(vm, 1, 4);
    Set<Action> d = new HashSet<>();
    d.add(new MockAction(vm, 2, 5));
    d.add(new MockAction(vm, 3, 7));
    Dependency dep = new Dependency(a, d);
    Assert.assertEquals(dep.getAction(), a);
    Assert.assertEquals(dep.getDependencies(), d);
    Assert.assertFalse(dep.toString().contains("null"));
}
Also used : Action(org.btrplace.plan.event.Action) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 24 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class TimedBasedActionComparatorTest method testOverlap1.

@Test
public void testOverlap1() {
    Action a = new MockAction(vm, 0, 4);
    Action b = new MockAction(vm, 2, 4);
    Assert.assertTrue(startCmp.compare(a, b) < 0);
    Assert.assertTrue(stopCmp.compare(a, b) < 0);
}
Also used : Action(org.btrplace.plan.event.Action) Test(org.testng.annotations.Test)

Example 25 with Action

use of org.btrplace.plan.event.Action in project scheduler by btrplace.

the class DefaultReconfigurationPlan method toString.

@Override
public String toString() {
    List<Action> l = new ArrayList<>(actions);
    Collections.sort(l, sorter);
    StringJoiner joiner = new StringJoiner("\n");
    for (Action a : l) {
        joiner.add(String.format("%d:%d %s", a.getStart(), a.getEnd(), a.toString()));
    }
    return joiner.toString();
}
Also used : Action(org.btrplace.plan.event.Action) ArrayList(java.util.ArrayList) StringJoiner(java.util.StringJoiner)

Aggregations

Action (org.btrplace.plan.event.Action)40 Test (org.testng.annotations.Test)25 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)18 MigrateVM (org.btrplace.plan.event.MigrateVM)10 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)10 HashSet (java.util.HashSet)9 Parameters (org.btrplace.scheduler.choco.Parameters)9 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)9 VM (org.btrplace.model.VM)8 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)8 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)8 Model (org.btrplace.model.Model)7 CMinMTTR (org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR)7 ArrayList (java.util.ArrayList)6 SatConstraint (org.btrplace.model.constraint.SatConstraint)6 Node (org.btrplace.model.Node)5 ShareableResource (org.btrplace.model.view.ShareableResource)5 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)5 BootVM (org.btrplace.plan.event.BootVM)4 ShutdownNode (org.btrplace.plan.event.ShutdownNode)4