Search in sources :

Example 1 with DereplicateAction

use of org.iobserve.planning.systemadaptation.DereplicateAction 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 2 with DereplicateAction

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

the class AdaptationPlanning method printAction.

private String printAction(final ComposedAction action) {
    final StringBuilder sb = new StringBuilder(200);
    if (action instanceof AllocateAction) {
        final AllocateAction allocate = (AllocateAction) action;
        sb.append("Allocate:\t").append(allocate.getTargetResourceContainer().getEntityName());
        sb.append("\tID: ").append(allocate.getTargetResourceContainer().getId());
    } else if (action instanceof DeallocateAction) {
        final DeallocateAction deallocate = (DeallocateAction) action;
        sb.append("Deallocate:\t").append(deallocate.getTargetResourceContainer().getEntityName());
        sb.append("\tID: ").append(deallocate.getTargetResourceContainer().getId());
    } else if (action instanceof ReplicateAction) {
        final ReplicateAction replicate = (ReplicateAction) action;
        sb.append("Replicate:\t").append(replicate.getSourceAllocationContext().getAssemblyContext_AllocationContext().getEntityName());
        sb.append("\tID: ").append(replicate.getSourceAllocationContext().getAssemblyContext_AllocationContext().getId());
        sb.append("\t ------- ");
        sb.append("\t->\t").append(replicate.getTargetAllocationContext().getEntityName());
    } else if (action instanceof MigrateAction) {
        final MigrateAction migrate = (MigrateAction) action;
        sb.append("Migrate:\t").append(migrate.getSourceAllocationContext().getAssemblyContext_AllocationContext().getEntityName());
        sb.append("\tID: ").append(migrate.getSourceAllocationContext().getAssemblyContext_AllocationContext().getId());
        sb.append('\t').append(migrate.getSourceAllocationContext().getResourceContainer_AllocationContext().getEntityName());
        sb.append("\t->\t").append(migrate.getTargetAllocationContext().getResourceContainer_AllocationContext().getEntityName());
    } else if (action instanceof ChangeRepositoryComponentAction) {
        final ChangeRepositoryComponentAction change = (ChangeRepositoryComponentAction) action;
        sb.append("ChangeComp:\t").append(change.getTargetAllocationContext().getAssemblyContext_AllocationContext().getEntityName());
        sb.append("\tID: ").append(change.getTargetAllocationContext().getAssemblyContext_AllocationContext().getId());
        sb.append('\t').append(change.getSourceAllocationContext().getAssemblyContext_AllocationContext().getEncapsulatedComponent__AssemblyContext().getEntityName());
        sb.append("\t->\t").append(change.getTargetAllocationContext().getAssemblyContext_AllocationContext().getEncapsulatedComponent__AssemblyContext().getEntityName());
    } else if (action instanceof DereplicateAction) {
        final DereplicateAction dereplicate = (DereplicateAction) action;
        sb.append("Dereplicate:\t").append(dereplicate.getTargetAllocationContext().getAssemblyContext_AllocationContext().getEntityName());
        sb.append("\tID: ").append(dereplicate.getTargetAllocationContext().getAssemblyContext_AllocationContext().getId());
    } else {
        sb.append("UNKOWN:\t" + " ------------------------------------ ");
        sb.append("\tID: " + " ------------------------------------ ");
    }
    return sb.toString();
}
Also used : DereplicateAction(org.iobserve.planning.systemadaptation.DereplicateAction) DeallocateAction(org.iobserve.planning.systemadaptation.DeallocateAction) AllocateAction(org.iobserve.planning.systemadaptation.AllocateAction) ReplicateAction(org.iobserve.planning.systemadaptation.ReplicateAction) MigrateAction(org.iobserve.planning.systemadaptation.MigrateAction) ChangeRepositoryComponentAction(org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)

Example 3 with DereplicateAction

use of org.iobserve.planning.systemadaptation.DereplicateAction 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)

Example 4 with DereplicateAction

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

the class AssemblyContextActionFactory method generateDereplicateAction.

/**
 * Create a dereplication action.
 *
 * @param runtimeNode
 *            node to be deallocated
 * @return returns the dereplication action
 */
public static DereplicateAction generateDereplicateAction(final ComponentNode runtimeNode) {
    final DereplicateAction action = SystemadaptationFactory.eINSTANCE.createDereplicateAction();
    final Allocation runtimeAllocation = ActionFactory.getRuntimeModels().getAllocationModel();
    final System runtimeSystem = ActionFactory.getRuntimeModels().getSystemModel();
    AssemblyContextActionFactory.initializeAssemblyContextAction(action, runtimeNode, runtimeAllocation, runtimeSystem);
    return action;
}
Also used : DereplicateAction(org.iobserve.planning.systemadaptation.DereplicateAction) Allocation(org.palladiosimulator.pcm.allocation.Allocation) System(org.palladiosimulator.pcm.system.System)

Aggregations

DereplicateAction (org.iobserve.planning.systemadaptation.DereplicateAction)4 ComponentNode (org.iobserve.adaptation.data.graph.ComponentNode)2 SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)2 Test (org.junit.Test)2 AdaptationData (org.iobserve.adaptation.data.AdaptationData)1 BlockRequestsToComponentAction (org.iobserve.adaptation.executionplan.BlockRequestsToComponentAction)1 DisconnectComponentAction (org.iobserve.adaptation.executionplan.DisconnectComponentAction)1 ExecutionPlan (org.iobserve.adaptation.executionplan.ExecutionPlan)1 FinishComponentAction (org.iobserve.adaptation.executionplan.FinishComponentAction)1 UndeployComponentAction (org.iobserve.adaptation.executionplan.UndeployComponentAction)1 AllocateAction (org.iobserve.planning.systemadaptation.AllocateAction)1 ChangeRepositoryComponentAction (org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)1 DeallocateAction (org.iobserve.planning.systemadaptation.DeallocateAction)1 MigrateAction (org.iobserve.planning.systemadaptation.MigrateAction)1 ReplicateAction (org.iobserve.planning.systemadaptation.ReplicateAction)1 Allocation (org.palladiosimulator.pcm.allocation.Allocation)1 System (org.palladiosimulator.pcm.system.System)1