Search in sources :

Example 21 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation 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)

Example 22 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation 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)

Example 23 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class DeploymentModelUpdater method execute.

/**
 * Execute an deployment event.
 *
 * @param event
 *            one deployment event to be processed
 * @throws NodeLookupException
 *             node lookup failed
 * @throws DBException
 *             on db error
 * @throws InvocationException
 *             on invocation errors
 */
@Override
protected void execute(final PCMDeployedEvent event) throws NodeLookupException, InvocationException, DBException {
    DeploymentLock.lock();
    ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.DEPLOYMENT, ObservationPoint.MODEL_UPDATE_ENTRY);
    this.logger.debug("Send event from {}", this.getInputPort().getPipe().getSourcePort().getOwningStage().getId());
    this.logger.debug("Deployment model update: assemblyContext={} resourceContainer={} service={}", event.getAssemblyContext(), event.getResourceContainer(), event.getService());
    final String allocationContextName = NameFactory.createAllocationContextName(event.getAssemblyContext(), event.getResourceContainer());
    final List<AllocationContext> allocationContext = this.allocationModelResource.findObjectsByTypeAndProperty(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT, "entityName", allocationContextName);
    if (allocationContext.isEmpty()) {
        this.logger.debug("Create allocation context (deploy) {}", event);
        final Allocation allocationModel = this.allocationModelResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
        final AllocationContext newAllocationContext = AllocationFactory.eINSTANCE.createAllocationContext();
        newAllocationContext.setEntityName(allocationContextName);
        newAllocationContext.setAssemblyContext_AllocationContext(event.getAssemblyContext());
        newAllocationContext.setResourceContainer_AllocationContext(event.getResourceContainer());
        allocationModel.getAllocationContexts_Allocation().add(newAllocationContext);
        this.allocationModelResource.updatePartition(allocationModel);
        final AllocationContext storedAllocationContext = this.allocationModelResource.resolve(newAllocationContext);
        /**
         * create correspondence model entry.
         */
        final CorrespondenceModel correspondenceModel = this.correspondenceModelResource.getModelRootNode(CorrespondenceModel.class, CorrespondencePackage.Literals.CORRESPONDENCE_MODEL);
        final Part part = this.findOrCreate(correspondenceModel, allocationModel);
        final AllocationEntry entry = CorrespondenceFactory.eINSTANCE.createAllocationEntry();
        entry.setAllocation(storedAllocationContext);
        entry.setTechnology(event.getTechnology());
        entry.setImplementationId(event.getUrl());
        part.getEntries().add(entry);
        this.correspondenceModelResource.updatePartition(correspondenceModel);
        this.logger.debug("PUSHED CORRESPONDENCE {} {} {}", newAllocationContext.getEntityName(), event.getTechnology().getLiteral(), event.getUrl());
    } else {
        this.logger.error("Deployment failed: Allocation Context {} already exists in allocation model.", allocationContextName);
    }
    // signal deployment update
    ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.DEPLOYMENT, ObservationPoint.MODEL_UPDATE_EXIT);
    DeploymentLock.unlock();
    this.deployedNotifyOutputPort.send(event);
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AllocationEntry(org.iobserve.model.correspondence.AllocationEntry) Allocation(org.palladiosimulator.pcm.allocation.Allocation) Part(org.iobserve.model.correspondence.Part) CorrespondenceModel(org.iobserve.model.correspondence.CorrespondenceModel)

Example 24 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class AllocationDataFactory method createAllocation.

/**
 * Create a new allocation model and link it with {@code system} and {@code resourceEnvironment}
 * model.
 *
 * @param system
 *            system model
 * @param resourceEnvironment
 *            resource environment model
 *
 * @return allocation model
 */
public static Allocation createAllocation(final System system, final ResourceEnvironment resourceEnvironment) {
    final Allocation allocation = AllocationFactory.eINSTANCE.createAllocation();
    allocation.setEntityName("defaultAllocation");
    allocation.setSystem_Allocation(system);
    allocation.setTargetResourceEnvironment_Allocation(resourceEnvironment);
    // Allocation contexts
    final AllocationContext client1AllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.QUERY_ALLOCATION_CONTEXT_1, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT, ResourceEnvironmentDataFactory.QUERY_CONTAINER_1);
    final AllocationContext client2AllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.QUERY_ALLOCATION_CONTEXT_2, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT, ResourceEnvironmentDataFactory.QUERY_CONTAINER_2);
    final AllocationContext businessOrderServerAllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.BUSINESS_ORDER_ALLOCATION_CONTEXT, SystemDataFactory.BUSINESS_ORDER_ASSEMBLY_CONTEXT, ResourceEnvironmentDataFactory.BUSINESS_ORDER_CONTAINER);
    final AllocationContext privateOrderServerAllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.PRIVATE_ORDER_ALLOCATION_CONTEXT, SystemDataFactory.PRIVATE_ORDER_ASSMEBLY_CONTEXT, ResourceEnvironmentDataFactory.PRIVATE_ORDER_CONTAINER);
    final AllocationContext paymentServerAllocationContext = AllocationDataFactory.createAllocationContext(system, resourceEnvironment, AllocationDataFactory.PAYMENT_ALLOCATION_CONTEXT, SystemDataFactory.PAYMENT_ASSEMBLY_CONTEXT, ResourceEnvironmentDataFactory.PAYMENT_CONTAINER);
    allocation.getAllocationContexts_Allocation().add(client1AllocationContext);
    allocation.getAllocationContexts_Allocation().add(client2AllocationContext);
    allocation.getAllocationContexts_Allocation().add(businessOrderServerAllocationContext);
    allocation.getAllocationContexts_Allocation().add(privateOrderServerAllocationContext);
    allocation.getAllocationContexts_Allocation().add(paymentServerAllocationContext);
    return allocation;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Allocation(org.palladiosimulator.pcm.allocation.Allocation)

Example 25 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class AllocationModelProviderTest method createThenReadByName.

/**
 * Writes a model to the graph, reads it from the graph using
 * {@link ModelProvider#findObjectsByTypeAndName(Class, String)} and asserts that it is equal to
 * the one written to the graph.
 *
 * @throws DBException
 */
@Test
public final void createThenReadByName() throws DBException {
    final Neo4JModelResource<Allocation> resource = ModelProviderTestUtils.prepareResource(AllocationModelProviderTest.CREATE_THEN_READ_BY_NAME, this.prefix, this.ePackage);
    resource.storeModelPartition(this.testModel);
    final List<Allocation> readModels = resource.findObjectsByTypeAndProperty(this.clazz, this.eClass, "entityName", this.testModel.getEntityName());
    for (final Allocation readModel : readModels) {
        Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
    }
    resource.getGraphDatabaseService().shutdown();
}
Also used : Allocation(org.palladiosimulator.pcm.allocation.Allocation) Test(org.junit.Test)

Aggregations

Allocation (org.palladiosimulator.pcm.allocation.Allocation)37 Test (org.junit.Test)16 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)10 System (org.palladiosimulator.pcm.system.System)10 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)9 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)7 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)7 File (java.io.File)4 IOException (java.io.IOException)4 PCMModelHandler (org.iobserve.model.PCMModelHandler)4 Repository (org.palladiosimulator.pcm.repository.Repository)4 CorrespondenceModel (org.iobserve.model.correspondence.CorrespondenceModel)3 DBException (org.iobserve.model.persistence.DBException)3 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)3 ArrayList (java.util.ArrayList)2 URI (org.eclipse.emf.common.util.URI)2 EObject (org.eclipse.emf.ecore.EObject)2 ModelImporter (org.iobserve.model.ModelImporter)2 Neo4JModelResource (org.iobserve.model.persistence.neo4j.Neo4JModelResource)2 DataProtectionModel (org.iobserve.model.privacy.DataProtectionModel)2