Search in sources :

Example 1 with ReplicateAction

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

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

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

the class ResourceContainerActionFactory method createReplicateAction.

/**
 * Create replicate action.
 *
 * @param runtimeServer
 *            source server
 * @param reDeploymentServer
 *            target server
 * @return the action
 */
public static ReplicateAction createReplicateAction(final DeploymentNode runtimeServer, final DeploymentNode reDeploymentServer) {
    final SystemadaptationFactory factory = SystemadaptationFactory.eINSTANCE;
    final ReplicateAction action = factory.createReplicateAction();
    ResourceContainerActionFactory.setSourceResourceContainer(action, runtimeServer.getResourceContainerID());
    final Allocation runtimeAllocModel = ActionFactory.getRuntimeModels().getAllocationModel();
    for (final ComponentNode component : runtimeServer.getContainingComponents()) {
        final AllocationContext oldAllocationContext = ActionFactory.getAllocationContext(component.getAllocationContextID(), runtimeAllocModel);
        action.getSourceAllocationContext().add(oldAllocationContext);
    }
    final Allocation reDeplAllocModel = ActionFactory.getRedeploymentModels().getAllocationModel();
    for (final ComponentNode component : reDeploymentServer.getContainingComponents()) {
        final AllocationContext newAllocationContext = ActionFactory.getAllocationContext(component.getAllocationContextID(), reDeplAllocModel);
        action.getSourceAllocationContext().add(newAllocationContext);
    }
    final ResourceEnvironment resEnvModel = ActionFactory.getRedeploymentModels().getResourceEnvironmentModel();
    final ResourceContainer newResourceContainer = ActionFactory.getResourceContainer(reDeploymentServer.getResourceContainerID(), resEnvModel);
    action.setNewResourceContainer(newResourceContainer);
    return action;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) Allocation(org.palladiosimulator.pcm.allocation.Allocation) SystemadaptationFactory(org.iobserve.planning.systemadaptation.SystemadaptationFactory) ComponentNode(org.iobserve.analysis.data.graph.ComponentNode) ReplicateAction(org.iobserve.planning.systemadaptation.ReplicateAction) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 4 with ReplicateAction

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

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

the class AssemblyContextActionFactory method generateReplicateAction.

/**
 * Create an replication action.
 *
 * @param runtimeNode
 *            node to be replicated
 * @param reDeploymentNode
 *            target node of replication
 * @return returns the replication action
 */
public static ReplicateAction generateReplicateAction(final ComponentNode runtimeNode, final ComponentNode reDeploymentNode) {
    final ReplicateAction action = SystemadaptationFactory.eINSTANCE.createReplicateAction();
    final Allocation runtimeAllocation = ActionFactory.getRuntimeModels().getAllocationModel();
    final Allocation redeploymentAllocation = ActionFactory.getRedeploymentModels().getAllocationModel();
    final System redeploymentSystem = ActionFactory.getRedeploymentModels().getSystemModel();
    AssemblyContextActionFactory.initializeAssemblyContextAction(action, reDeploymentNode, redeploymentAllocation, redeploymentSystem);
    action.setSourceAllocationContext(ActionFactory.getAllocationContext(runtimeNode.getAllocationContextID(), runtimeAllocation));
    return action;
}
Also used : Allocation(org.palladiosimulator.pcm.allocation.Allocation) ReplicateAction(org.iobserve.planning.systemadaptation.ReplicateAction) System(org.palladiosimulator.pcm.system.System)

Aggregations

ReplicateAction (org.iobserve.planning.systemadaptation.ReplicateAction)5 ComponentNode (org.iobserve.adaptation.data.graph.ComponentNode)2 SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)2 Test (org.junit.Test)2 Allocation (org.palladiosimulator.pcm.allocation.Allocation)2 AdaptationData (org.iobserve.adaptation.data.AdaptationData)1 ConnectComponentAction (org.iobserve.adaptation.executionplan.ConnectComponentAction)1 DeployComponentAction (org.iobserve.adaptation.executionplan.DeployComponentAction)1 ExecutionPlan (org.iobserve.adaptation.executionplan.ExecutionPlan)1 MigrateComponentStateAction (org.iobserve.adaptation.executionplan.MigrateComponentStateAction)1 ComponentNode (org.iobserve.analysis.data.graph.ComponentNode)1 AllocateAction (org.iobserve.planning.systemadaptation.AllocateAction)1 ChangeRepositoryComponentAction (org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)1 DeallocateAction (org.iobserve.planning.systemadaptation.DeallocateAction)1 DereplicateAction (org.iobserve.planning.systemadaptation.DereplicateAction)1 MigrateAction (org.iobserve.planning.systemadaptation.MigrateAction)1 SystemadaptationFactory (org.iobserve.planning.systemadaptation.SystemadaptationFactory)1 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)1 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)1 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)1