Search in sources :

Example 1 with ComponentNode

use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.

the class AdaptationCalculation method compareComponents.

private void compareComponents(final Set<ComponentNode> components) {
    for (final ComponentNode reDeplComp : components) {
        final ComponentNode runComp = this.runtimeComponentNodes.get(reDeplComp.getAssemblyContextID());
        if (runComp == null) {
            // Replicate, since ID does not yet exits
            final AssemblyContextAction action = AssemblyContextActionFactory.generateReplicateAction(runComp, reDeplComp);
            this.acActions.add(action);
        } else if (!runComp.equals(reDeplComp)) {
            // Components differ, so check what actions need to be done!
            if (!runComp.getRepositoryComponentID().equals(reDeplComp.getRepositoryComponentID())) {
                // AssemblyContexts contain different RepositoryComponents
                final AssemblyContextAction action = AssemblyContextActionFactory.generateChangeRepositoryComponentAction(runComp, reDeplComp);
                this.acActions.add(action);
            }
            if (!runComp.getHostServer().getResourceContainerID().equals(reDeplComp.getHostServer().getResourceContainerID())) {
                // AssemblyContexts are hosted on different Servers
                final AssemblyContextAction action = AssemblyContextActionFactory.generateMigrateAction(runComp, reDeplComp);
                this.acActions.add(action);
            }
        }
        this.runtimeComponentNodes.remove(reDeplComp.getAssemblyContextID(), runComp);
    }
    for (final ComponentNode runComp : this.runtimeComponentNodes.values()) {
        // AssemblyContext does not exist anymore in redeployment model!
        final AssemblyContextAction action = AssemblyContextActionFactory.generateDereplicateAction(runComp);
        this.acActions.add(action);
    }
}
Also used : ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) AssemblyContextAction(org.iobserve.planning.systemadaptation.AssemblyContextAction)

Example 2 with ComponentNode

use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.

the class AtomicActionComputationTest method testReplicateAction2AtomicActions.

/**
 * replicate action conversion to atomic actions.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testReplicateAction2AtomicActions() throws Exception {
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    final ExecutionPlan executionPlan;
    final ComponentNode runtimeNode;
    final ComponentNode redeploymentNode;
    final ReplicateAction replicateAction;
    // Replication specific setup
    this.redeploymentModel.replicateCompBToRc2();
    this.initializeModelGraphs();
    runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), this.runtimeModelGraph.getComponents());
    redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc2().getId(), this.redeploymentModelGraph.getComponents());
    replicateAction = AssemblyContextActionFactory.generateReplicateAction(runtimeNode, redeploymentNode);
    systemAdaptationModel.getActions().add(replicateAction);
    // Execute stage
    executionPlan = this.executeStage(systemAdaptationModel);
    // Basic verification
    Assert.assertThat(executionPlan.getActions().size(), Matchers.is(3));
    Assert.assertTrue(executionPlan.getActions().get(0) instanceof DeployComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(1) instanceof MigrateComponentStateAction);
    Assert.assertTrue(executionPlan.getActions().get(2) instanceof ConnectComponentAction);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) MigrateComponentStateAction(org.iobserve.adaptation.executionplan.MigrateComponentStateAction) ConnectComponentAction(org.iobserve.adaptation.executionplan.ConnectComponentAction) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) ReplicateAction(org.iobserve.planning.systemadaptation.ReplicateAction) DeployComponentAction(org.iobserve.adaptation.executionplan.DeployComponentAction) Test(org.junit.Test)

Example 3 with ComponentNode

use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method testChangeRepositoryRule.

/**
 * Test change repository rule.
 *
 * @throws Exception
 *             on internal errors.
 */
@Test
public void testChangeRepositoryRule() throws Exception {
    final AdaptationData adaptationData;
    final ComponentNode runtimeNode;
    final ComponentNode redeploymentNode;
    final SystemAdaptation actualOutput;
    final ChangeRepositoryComponentAction actualAction;
    final ChangeRepositoryComponentAction expectedAction;
    // Perform change of component
    this.redeploymentModel.changeRepositoryCompBxToCompBy();
    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.generateChangeRepositoryComponentAction(runtimeNode, redeploymentNode);
    // Execute stage
    actualOutput = this.executeStage(adaptationData);
    Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
    Assert.assertTrue(actualOutput.getActions().get(0) instanceof ChangeRepositoryComponentAction);
    actualAction = (ChangeRepositoryComponentAction) 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) ChangeRepositoryComponentAction(org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction) Test(org.junit.Test)

Example 4 with ComponentNode

use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method testDereplicationRule.

/**
 * Test de-replication.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testDereplicationRule() throws Exception {
    final AdaptationData adaptationData;
    final ComponentNode runtimeNode;
    final SystemAdaptation actualOutput;
    final DereplicateAction actualAction;
    final DereplicateAction expectedAction;
    // Perform dereplication (simulated by replicating a component in the runtime model)
    this.runtimeModel.replicateCompBToRc2();
    adaptationData = this.createAdaptationData();
    // Create expected output
    runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc2().getId(), adaptationData.getRuntimeGraph().getComponents());
    expectedAction = AssemblyContextActionFactory.generateDereplicateAction(runtimeNode);
    // Execute stage
    actualOutput = this.executeStage(adaptationData);
    Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
    Assert.assertTrue(actualOutput.getActions().get(0) instanceof DereplicateAction);
    actualAction = (DereplicateAction) 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()));
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) DereplicateAction(org.iobserve.planning.systemadaptation.DereplicateAction) AdaptationData(org.iobserve.adaptation.data.AdaptationData) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) Test(org.junit.Test)

Example 5 with ComponentNode

use of org.iobserve.adaptation.data.graph.ComponentNode in project iobserve-analysis by research-iobserve.

the class AtomicActionComputationTest method testDereplicateAction2AtomicActions.

/**
 * dereplicate action conversion to atomic actions.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testDereplicateAction2AtomicActions() throws Exception {
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    final ExecutionPlan executionPlan;
    final ComponentNode runtimeNode;
    final DereplicateAction dereplicateAction;
    // Dereplication specific setup (simulated by replicating a component in the runtime model)
    this.runtimeModel.replicateCompBToRc2();
    this.initializeModelGraphs();
    runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), this.runtimeModelGraph.getComponents());
    dereplicateAction = AssemblyContextActionFactory.generateDereplicateAction(runtimeNode);
    systemAdaptationModel.getActions().add(dereplicateAction);
    // Execute stage
    executionPlan = this.executeStage(systemAdaptationModel);
    // Basic verification
    Assert.assertThat(executionPlan.getActions().size(), Matchers.is(4));
    Assert.assertTrue(executionPlan.getActions().get(0) instanceof BlockRequestsToComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(1) instanceof FinishComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(2) instanceof DisconnectComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(3) instanceof UndeployComponentAction);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) UndeployComponentAction(org.iobserve.adaptation.executionplan.UndeployComponentAction) DereplicateAction(org.iobserve.planning.systemadaptation.DereplicateAction) BlockRequestsToComponentAction(org.iobserve.adaptation.executionplan.BlockRequestsToComponentAction) FinishComponentAction(org.iobserve.adaptation.executionplan.FinishComponentAction) DisconnectComponentAction(org.iobserve.adaptation.executionplan.DisconnectComponentAction) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) Test(org.junit.Test)

Aggregations

ComponentNode (org.iobserve.adaptation.data.graph.ComponentNode)9 SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)8 Test (org.junit.Test)8 AdaptationData (org.iobserve.adaptation.data.AdaptationData)4 ExecutionPlan (org.iobserve.adaptation.executionplan.ExecutionPlan)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 ChangeRepositoryComponentAction (org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)2 DereplicateAction (org.iobserve.planning.systemadaptation.DereplicateAction)2 MigrateAction (org.iobserve.planning.systemadaptation.MigrateAction)2 ReplicateAction (org.iobserve.planning.systemadaptation.ReplicateAction)2 AssemblyContextAction (org.iobserve.planning.systemadaptation.AssemblyContextAction)1