Search in sources :

Example 1 with MigrateAction

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

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

the class AssemblyContextActionFactory method generateMigrateAction.

/**
 * Create a migration action.
 *
 * @param runtimeNode
 *            source node
 * @param reDeploymentNode
 *            target node
 * @return returns the migration action
 */
public static MigrateAction generateMigrateAction(final ComponentNode runtimeNode, final ComponentNode reDeploymentNode) {
    final MigrateAction action = SystemadaptationFactory.eINSTANCE.createMigrateAction();
    final Allocation runtimeAllocation = ActionFactory.getRuntimeModels().getAllocationModel();
    final Allocation redeploymentAllocation = ActionFactory.getRedeploymentModels().getAllocationModel();
    final System runtimeSystem = ActionFactory.getRuntimeModels().getSystemModel();
    final System redeploymentSystem = ActionFactory.getRedeploymentModels().getSystemModel();
    AssemblyContextActionFactory.initializeAssemblyContextAction(action, reDeploymentNode, redeploymentAllocation, redeploymentSystem);
    action.setSourceAllocationContext(ActionFactory.getAllocationContext(runtimeNode.getAllocationContextID(), runtimeAllocation));
    // source providing allocation contexts
    ActionFactory.getProvidingAssemblyContexts(runtimeNode.getAssemblyContextID(), runtimeSystem).forEach(ac -> action.getSourceProvidingAllocationContexts().add(ActionFactory.getAllocationContextContainingAssemblyContext(ac.getId(), runtimeAllocation)));
    // source requiring allocation contexts
    ActionFactory.getRequiringAssemblyContexts(runtimeNode.getAssemblyContextID(), runtimeSystem).forEach(ac -> action.getSourceRequiringAllocationContexts().add(ActionFactory.getAllocationContextContainingAssemblyContext(ac.getId(), runtimeAllocation)));
    return action;
}
Also used : Allocation(org.palladiosimulator.pcm.allocation.Allocation) System(org.palladiosimulator.pcm.system.System) MigrateAction(org.iobserve.planning.systemadaptation.MigrateAction)

Example 3 with MigrateAction

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

the class AdaptationPlanning method printAction.

private String printAction(final Action action) {
    final StringBuilder sb = new StringBuilder(200);
    if (action instanceof AcquireAction) {
        final AcquireAction acquire = (AcquireAction) action;
        sb.append("Acquire:\t").append(acquire.getSourceResourceContainer().getEntityName());
        sb.append("\tID: ").append(acquire.getSourceResourceContainer().getId());
    } else if (action instanceof TerminateAction) {
        final TerminateAction terminate = (TerminateAction) action;
        sb.append("Terminate:\t").append(terminate.getSourceResourceContainer().getEntityName());
        sb.append("\tID: ").append(terminate.getSourceResourceContainer().getId());
    } else if (action instanceof AllocateAction) {
        final AllocateAction allocate = (AllocateAction) action;
        sb.append("Allocate:\t").append(allocate.getSourceAssemblyContext().getEntityName());
        sb.append("\tID: ").append(allocate.getSourceAssemblyContext().getId());
        sb.append("\t ------- ");
        sb.append("\t->\t").append(allocate.getNewAllocationContext().getEntityName());
    } else if (action instanceof MigrateAction) {
        final MigrateAction migrate = (MigrateAction) action;
        sb.append("Migrate:\t").append(migrate.getSourceAssemblyContext().getEntityName());
        sb.append("\tID: ").append(migrate.getSourceAssemblyContext().getId());
        sb.append('\t').append(migrate.getSourceAllocationContext().getResourceContainer_AllocationContext().getEntityName());
        sb.append("\t->\t").append(migrate.getNewAllocationContext().getResourceContainer_AllocationContext().getEntityName());
    } else if (action instanceof ChangeRepositoryComponentAction) {
        final ChangeRepositoryComponentAction change = (ChangeRepositoryComponentAction) action;
        sb.append("ChangeComp:\t").append(change.getSourceAssemblyContext().getEntityName());
        sb.append("\tID: ").append(change.getSourceAssemblyContext().getId());
        sb.append('\t').append(change.getSourceAssemblyContext().getEncapsulatedComponent__AssemblyContext().getEntityName());
        sb.append("\t->\t").append(change.getNewRepositoryComponent().getEntityName());
    } else if (action instanceof DeallocateAction) {
        final DeallocateAction deAllocate = (DeallocateAction) action;
        sb.append("Deallocate:\t").append(deAllocate.getSourceAssemblyContext().getEntityName());
        sb.append("\tID: ").append(deAllocate.getSourceAssemblyContext().getId());
    } else {
        sb.append("UNKOWN:\t" + " ------------------------------------ ");
        sb.append("\tID: " + " ------------------------------------ ");
    }
    return sb.toString();
}
Also used : AcquireAction(org.iobserve.planning.systemadaptation.AcquireAction) TerminateAction(org.iobserve.planning.systemadaptation.TerminateAction) DeallocateAction(org.iobserve.planning.systemadaptation.DeallocateAction) AllocateAction(org.iobserve.planning.systemadaptation.AllocateAction) MigrateAction(org.iobserve.planning.systemadaptation.MigrateAction) ChangeRepositoryComponentAction(org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)

Example 4 with MigrateAction

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

the class AtomicActionComputationTest method testMigrateAction2AtomicActions.

/**
 * migrate action conversion to atomic actions.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testMigrateAction2AtomicActions() throws Exception {
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    final ExecutionPlan executionPlan;
    final ComponentNode runtimeNode;
    final ComponentNode redeploymentNode;
    final MigrateAction migrateAction;
    // Migration specific setup
    this.redeploymentModel.migrateCompBToRc2();
    this.initializeModelGraphs();
    runtimeNode = this.findComponentNodeByID(this.runtimeModel.getAlcxtBRc1().getId(), this.runtimeModelGraph.getComponents());
    redeploymentNode = this.findComponentNodeByID(this.redeploymentModel.getAlcxtBRc1().getId(), this.redeploymentModelGraph.getComponents());
    migrateAction = AssemblyContextActionFactory.generateMigrateAction(runtimeNode, redeploymentNode);
    systemAdaptationModel.getActions().add(migrateAction);
    // Execute stage
    executionPlan = this.executeStage(systemAdaptationModel);
    // Basic verification
    Assert.assertThat(executionPlan.getActions().size(), Matchers.is(7));
    Assert.assertTrue(executionPlan.getActions().get(0) instanceof DeployComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(1) instanceof MigrateComponentStateAction);
    Assert.assertTrue(executionPlan.getActions().get(2) instanceof ConnectComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(3) instanceof BlockRequestsToComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(4) instanceof FinishComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(5) instanceof DisconnectComponentAction);
    Assert.assertTrue(executionPlan.getActions().get(6) instanceof UndeployComponentAction);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) UndeployComponentAction(org.iobserve.adaptation.executionplan.UndeployComponentAction) BlockRequestsToComponentAction(org.iobserve.adaptation.executionplan.BlockRequestsToComponentAction) MigrateComponentStateAction(org.iobserve.adaptation.executionplan.MigrateComponentStateAction) ConnectComponentAction(org.iobserve.adaptation.executionplan.ConnectComponentAction) FinishComponentAction(org.iobserve.adaptation.executionplan.FinishComponentAction) DisconnectComponentAction(org.iobserve.adaptation.executionplan.DisconnectComponentAction) ComponentNode(org.iobserve.adaptation.data.graph.ComponentNode) MigrateAction(org.iobserve.planning.systemadaptation.MigrateAction) DeployComponentAction(org.iobserve.adaptation.executionplan.DeployComponentAction) Test(org.junit.Test)

Example 5 with MigrateAction

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

Aggregations

MigrateAction (org.iobserve.planning.systemadaptation.MigrateAction)5 ComponentNode (org.iobserve.adaptation.data.graph.ComponentNode)2 AllocateAction (org.iobserve.planning.systemadaptation.AllocateAction)2 ChangeRepositoryComponentAction (org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)2 DeallocateAction (org.iobserve.planning.systemadaptation.DeallocateAction)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 ConnectComponentAction (org.iobserve.adaptation.executionplan.ConnectComponentAction)1 DeployComponentAction (org.iobserve.adaptation.executionplan.DeployComponentAction)1 DisconnectComponentAction (org.iobserve.adaptation.executionplan.DisconnectComponentAction)1 ExecutionPlan (org.iobserve.adaptation.executionplan.ExecutionPlan)1 FinishComponentAction (org.iobserve.adaptation.executionplan.FinishComponentAction)1 MigrateComponentStateAction (org.iobserve.adaptation.executionplan.MigrateComponentStateAction)1 UndeployComponentAction (org.iobserve.adaptation.executionplan.UndeployComponentAction)1 AcquireAction (org.iobserve.planning.systemadaptation.AcquireAction)1 DereplicateAction (org.iobserve.planning.systemadaptation.DereplicateAction)1 ReplicateAction (org.iobserve.planning.systemadaptation.ReplicateAction)1 TerminateAction (org.iobserve.planning.systemadaptation.TerminateAction)1