Search in sources :

Example 1 with DeallocateAction

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

the class AtomicActionComputationTest method testDeallocateAction2AtomicActions.

/**
 * deallocate action conversion to atomic actions.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testDeallocateAction2AtomicActions() throws Exception {
    final SystemAdaptation systemAdaptationModel = SystemadaptationFactory.eINSTANCE.createSystemAdaptation();
    final ExecutionPlan executionPlan;
    final DeploymentNode runtimeNode;
    final DeallocateAction deallocateAction;
    // Deallocation specific setup ((simulated by an allocation in the runtime model)
    this.runtimeModel.allocateResourceContainerR3();
    this.initializeModelGraphs();
    runtimeNode = this.findDeploymentNodeByID(this.runtimeModel.getRc3().getId(), this.runtimeModelGraph.getServers());
    deallocateAction = ResourceContainerActionFactory.createDeallocateAction(runtimeNode);
    systemAdaptationModel.getActions().add(deallocateAction);
    // Execute stage
    executionPlan = this.executeStage(systemAdaptationModel);
    // Basic verification
    Assert.assertThat(executionPlan.getActions().size(), Matchers.is(2));
    Assert.assertTrue(executionPlan.getActions().get(0) instanceof DisconnectNodeAction);
    Assert.assertTrue(executionPlan.getActions().get(1) instanceof DeallocateNodeAction);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) DeallocateNodeAction(org.iobserve.adaptation.executionplan.DeallocateNodeAction) DeploymentNode(org.iobserve.adaptation.data.graph.DeploymentNode) DeallocateAction(org.iobserve.planning.systemadaptation.DeallocateAction) DisconnectNodeAction(org.iobserve.adaptation.executionplan.DisconnectNodeAction) Test(org.junit.Test)

Example 2 with DeallocateAction

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

the class ComposedActionComputationTest method testDeallocateRule.

/**
 * Test whether the de-allocation rule succeeds.
 *
 * @throws Exception
 *             on internal errors
 */
@Test
public void testDeallocateRule() throws Exception {
    final AdaptationData adaptationData;
    final DeploymentNode runtimeNode;
    final SystemAdaptation actualOutput;
    final DeallocateAction actualAction;
    final DeallocateAction expectedAction;
    // Perform deallocation (simulated by an allocation in the runtime model)
    this.runtimeModel.allocateResourceContainerR3();
    adaptationData = this.createAdaptationData();
    // Create expected output
    runtimeNode = this.findDeploymentNodeByID(this.runtimeModel.getRc3().getId(), adaptationData.getRuntimeGraph().getServers());
    expectedAction = ResourceContainerActionFactory.createDeallocateAction(runtimeNode);
    // Execute stage
    actualOutput = this.executeStage(adaptationData);
    Assert.assertThat(actualOutput.getActions().size(), Matchers.is(1));
    Assert.assertTrue(actualOutput.getActions().get(0) instanceof DeallocateAction);
    actualAction = (DeallocateAction) 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) DeallocateAction(org.iobserve.planning.systemadaptation.DeallocateAction) AdaptationData(org.iobserve.adaptation.data.AdaptationData) Test(org.junit.Test)

Example 3 with DeallocateAction

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

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

the class AdaptationCalculation method compareServers.

private void compareServers(final Set<DeploymentNode> servers) {
    for (final DeploymentNode reDeplServer : servers) {
        if (reDeplServer.getContainingComponents().size() == 0) {
            // If the server dosn't contain any components => IGNORE
            continue;
        }
        final DeploymentNode runServer = this.runtimeDeploymentNodes.get(reDeplServer.getResourceContainerID());
        if (runServer == null) {
            // It is an so far unused server!
            final AllocateAction action = ResourceContainerActionFactory.createAllocateAction(reDeplServer);
            this.rcActions.add(action);
        } else {
            // Server was and is still in use
            this.runtimeDeploymentNodes.remove(runServer.getResourceContainerID(), runServer);
        }
    }
    for (final DeploymentNode runServer : this.runtimeDeploymentNodes.values()) {
        // AssemblyContext does not exist anymore in redeployment model!
        final DeallocateAction action = ResourceContainerActionFactory.createDeallocateAction(runServer);
        this.rcActions.add(action);
    }
}
Also used : DeploymentNode(org.iobserve.adaptation.data.graph.DeploymentNode) DeallocateAction(org.iobserve.planning.systemadaptation.DeallocateAction) AllocateAction(org.iobserve.planning.systemadaptation.AllocateAction)

Example 5 with DeallocateAction

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

Aggregations

DeallocateAction (org.iobserve.planning.systemadaptation.DeallocateAction)7 DeploymentNode (org.iobserve.adaptation.data.graph.DeploymentNode)3 AllocateAction (org.iobserve.planning.systemadaptation.AllocateAction)3 ChangeRepositoryComponentAction (org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)2 MigrateAction (org.iobserve.planning.systemadaptation.MigrateAction)2 SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)2 Test (org.junit.Test)2 AdaptationData (org.iobserve.adaptation.data.AdaptationData)1 DeallocateNodeAction (org.iobserve.adaptation.executionplan.DeallocateNodeAction)1 DisconnectNodeAction (org.iobserve.adaptation.executionplan.DisconnectNodeAction)1 ExecutionPlan (org.iobserve.adaptation.executionplan.ExecutionPlan)1 AcquireAction (org.iobserve.planning.systemadaptation.AcquireAction)1 DereplicateAction (org.iobserve.planning.systemadaptation.DereplicateAction)1 ReplicateAction (org.iobserve.planning.systemadaptation.ReplicateAction)1 SystemadaptationFactory (org.iobserve.planning.systemadaptation.SystemadaptationFactory)1 TerminateAction (org.iobserve.planning.systemadaptation.TerminateAction)1 Allocation (org.palladiosimulator.pcm.allocation.Allocation)1 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)1