Search in sources :

Example 11 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method testAllocateRule.

/**
 * Test whether the allocation rule succeeds.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testAllocateRule() throws Exception {
    final AdaptationData adaptationData;
    final DeploymentNode redeploymentNode;
    final SystemAdaptation actualOutput;
    final AllocateAction actualAction;
    final AllocateAction expectedAction;
    // Perform allocation
    this.redeploymentModel.allocateResourceContainerR3();
    adaptationData = this.createAdaptationData();
    // Create expected output
    redeploymentNode = this.findDeploymentNodeByID(this.redeploymentModel.getRc3().getId(), adaptationData.getReDeploymentGraph().getServers());
    expectedAction = ResourceContainerActionFactory.createAllocateAction(redeploymentNode);
    // Execute stage
    actualOutput = this.executeStage(adaptationData);
    Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
    Assert.assertTrue(actualOutput.getActions().get(0) instanceof AllocateAction);
    actualAction = (AllocateAction) actualOutput.getActions().get(0);
    Assert.assertThat(actualAction.getTargetResourceContainer(), Matchers.is(expectedAction.getTargetResourceContainer()));
    Assert.assertThat(actualAction.getTargetLinkingResources(), Matchers.is(expectedAction.getTargetLinkingResources()));
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) DeploymentNode(org.iobserve.adaptation.data.graph.DeploymentNode) AllocateAction(org.iobserve.planning.systemadaptation.AllocateAction) AdaptationData(org.iobserve.adaptation.data.AdaptationData) Test(org.junit.Test)

Example 12 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method testMigrationRule.

/**
 * Test migration rule.
 *
 * @throws Exception
 *             on internal error
 */
@Test
public void testMigrationRule() throws Exception {
    final AdaptationData adaptationData;
    final ComponentNode runtimeNode;
    final ComponentNode redeploymentNode;
    final SystemAdaptation actualOutput;
    final MigrateAction actualAction;
    final MigrateAction expectedAction;
    // Perform migration
    this.redeploymentModel.migrateCompBToRc2();
    adaptationData = this.createAdaptationData();
    // Create expected output
    runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), adaptationData.getRuntimeGraph().getComponents());
    redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc1().getId(), adaptationData.getReDeploymentGraph().getComponents());
    expectedAction = AssemblyContextActionFactory.generateMigrateAction(runtimeNode, redeploymentNode);
    // Execute stage
    actualOutput = this.executeStage(adaptationData);
    Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
    Assert.assertTrue(actualOutput.getActions().get(0) instanceof MigrateAction);
    actualAction = (MigrateAction) actualOutput.getActions().get(0);
    Assert.assertThat(actualAction.getTargetAllocationContext(), Matchers.is(expectedAction.getTargetAllocationContext()));
    Assert.assertThat(actualAction.getTargetProvidingAllocationContexts(), Matchers.is(expectedAction.getTargetProvidingAllocationContexts()));
    Assert.assertThat(actualAction.getTargetRequiringAllocationContexts(), Matchers.is(expectedAction.getTargetRequiringAllocationContexts()));
    Assert.assertThat(actualAction.getSourceAllocationContext(), Matchers.is(expectedAction.getSourceAllocationContext()));
    Assert.assertThat(actualAction.getSourceProvidingAllocationContexts(), Matchers.is(expectedAction.getSourceProvidingAllocationContexts()));
    Assert.assertThat(actualAction.getSourceRequiringAllocationContexts(), Matchers.is(expectedAction.getSourceRequiringAllocationContexts()));
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) AdaptationData(org.iobserve.adaptation.data.AdaptationData) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) MigrateAction(org.iobserve.planning.systemadaptation.MigrateAction) Test(org.junit.Test)

Example 13 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method testReplicationRule.

/**
 * test replication rule.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testReplicationRule() throws Exception {
    final AdaptationData adaptationData;
    final ComponentNode runtimeNode;
    final ComponentNode redeploymentNode;
    final SystemAdaptation actualOutput;
    final ReplicateAction actualAction;
    final ReplicateAction expectedAction;
    // Perform replication
    this.redeploymentModel.replicateCompBToRc2();
    adaptationData = this.createAdaptationData();
    // Create expected output
    runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), adaptationData.getRuntimeGraph().getComponents());
    redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc2().getId(), adaptationData.getReDeploymentGraph().getComponents());
    expectedAction = AssemblyContextActionFactory.generateReplicateAction(runtimeNode, redeploymentNode);
    // Execute stage
    actualOutput = this.executeStage(adaptationData);
    Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
    Assert.assertTrue(actualOutput.getActions().get(0) instanceof ReplicateAction);
    actualAction = (ReplicateAction) actualOutput.getActions().get(0);
    Assert.assertThat(actualAction.getTargetAllocationContext(), Matchers.is(expectedAction.getTargetAllocationContext()));
    Assert.assertThat(actualAction.getTargetProvidingAllocationContexts(), Matchers.is(expectedAction.getTargetProvidingAllocationContexts()));
    Assert.assertThat(actualAction.getTargetRequiringAllocationContexts(), Matchers.is(expectedAction.getTargetRequiringAllocationContexts()));
    Assert.assertThat(actualAction.getSourceAllocationContext(), Matchers.is(expectedAction.getSourceAllocationContext()));
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) AdaptationData(org.iobserve.adaptation.data.AdaptationData) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) ReplicateAction(org.iobserve.planning.systemadaptation.ReplicateAction) Test(org.junit.Test)

Example 14 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method executeStage.

private SystemAdaptation executeStage(final AdaptationData adaptationData) {
    final InitialElementProducer<AdaptationData> producer = new InitialElementProducer<>(adaptationData);
    final ComposedActionComputation composedActionComputation = new ComposedActionComputation();
    final CollectorSink<SystemAdaptation> collector = new CollectorSink<>();
    final ComposedActionComputationTestConfig configuration = new ComposedActionComputationTestConfig(producer, this.actionFactoryInitializer, composedActionComputation, collector);
    final Execution<ComposedActionComputationTestConfig> execution = new Execution<>(configuration);
    execution.executeBlocking();
    return collector.getElements().get(0);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) InitialElementProducer(teetime.stage.InitialElementProducer) Execution(teetime.framework.Execution) CollectorSink(teetime.stage.CollectorSink) AdaptationData(org.iobserve.adaptation.data.AdaptationData) ComposedActionComputation(org.iobserve.adaptation.stages.ComposedActionComputation)

Example 15 with SystemAdaptation

use of org.iobserve.planning.systemadaptation.SystemAdaptation in project iobserve-analysis by research-iobserve.

the class ComposedActionComputation method execute.

@Override
protected void execute(final AdaptationData adaptationData) throws Exception {
    final HostComponentAllocationGraph runtimeGraph = adaptationData.getRuntimeGraph();
    final HostComponentAllocationGraph redeploymentGraph = adaptationData.getReDeploymentGraph();
    final List<Command<?>> workingMemoryInserts = new ArrayList<>();
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    // Add system adaptation model (its list of actions will be filled with by the rule engine)
    workingMemoryInserts.add(this.kieCommands.newInsert(systemAdaptationModel));
    // Add component nodes and deployment nodes of runtime and redeployment model graph
    this.addToWorkingMemoryInserts(workingMemoryInserts, runtimeGraph.getComponents());
    this.addToWorkingMemoryInserts(workingMemoryInserts, runtimeGraph.getServers());
    this.addToWorkingMemoryInserts(workingMemoryInserts, redeploymentGraph.getComponents());
    this.addToWorkingMemoryInserts(workingMemoryInserts, redeploymentGraph.getServers());
    // Execute rule engine which will add actions to composedAdaptationActions
    this.kSession.execute(this.kieCommands.newBatchExecution(workingMemoryInserts));
    this.outputPort.send(systemAdaptationModel);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) HostComponentAllocationGraph(org.iobserve.adaptation.data.graph.HostComponentAllocationGraph) Command(org.kie.api.command.Command) ArrayList(java.util.ArrayList)

Aggregations

SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)16 Test (org.junit.Test)12 ComponentNode (org.iobserve.adaptation.data.graph.ComponentNode)8 AdaptationData (org.iobserve.adaptation.data.AdaptationData)7 ExecutionPlan (org.iobserve.adaptation.executionplan.ExecutionPlan)7 DeploymentNode (org.iobserve.adaptation.data.graph.DeploymentNode)4 BlockRequestsToComponentAction (org.iobserve.adaptation.executionplan.BlockRequestsToComponentAction)3 ConnectComponentAction (org.iobserve.adaptation.executionplan.ConnectComponentAction)3 DeployComponentAction (org.iobserve.adaptation.executionplan.DeployComponentAction)3 DisconnectComponentAction (org.iobserve.adaptation.executionplan.DisconnectComponentAction)3 FinishComponentAction (org.iobserve.adaptation.executionplan.FinishComponentAction)3 MigrateComponentStateAction (org.iobserve.adaptation.executionplan.MigrateComponentStateAction)3 UndeployComponentAction (org.iobserve.adaptation.executionplan.UndeployComponentAction)3 AllocateAction (org.iobserve.planning.systemadaptation.AllocateAction)2 ChangeRepositoryComponentAction (org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)2 DeallocateAction (org.iobserve.planning.systemadaptation.DeallocateAction)2 DereplicateAction (org.iobserve.planning.systemadaptation.DereplicateAction)2 MigrateAction (org.iobserve.planning.systemadaptation.MigrateAction)2 ReplicateAction (org.iobserve.planning.systemadaptation.ReplicateAction)2 Execution (teetime.framework.Execution)2