Search in sources :

Example 6 with AllocationContext

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

the class AllocationModelProviderTest method createThenUpdateThenReadUpdated.

@Override
@Test
public void createThenUpdateThenReadUpdated() throws NodeLookupException, DBException {
    final Neo4JModelResource<Allocation> resource = ModelProviderTestUtils.prepareResource(AllocationModelProviderTest.CREATE_THEN_UPDATE_THEN_READ_UPDATED, this.prefix, this.ePackage);
    final AllocationContext businessOrderServerAllocationContext = AllocationDataFactory.findAllocationContext(this.testModel, AllocationDataFactory.BUSINESS_ORDER_ALLOCATION_CONTEXT);
    final AllocationContext privateOrderServerAllocationContext = AllocationDataFactory.findAllocationContext(this.testModel, AllocationDataFactory.PRIVATE_ORDER_ALLOCATION_CONTEXT);
    resource.storeModelPartition(this.testModel);
    // Update the model by allocating new separate servers for business and private orders
    final ResourceContainer businessOrderServer = ResourceEnvironmentDataFactory.cloneContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.BUSINESS_ORDER_CONTAINER, "additionalBusinessOrderServer");
    final ResourceContainer privateOrderServer = ResourceEnvironmentDataFactory.cloneContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.PRIVATE_ORDER_CONTAINER, "additionalPrivateOrderServer");
    this.resourceEnvironment.getResourceContainer_ResourceEnvironment().add(businessOrderServer);
    this.resourceEnvironment.getResourceContainer_ResourceEnvironment().add(privateOrderServer);
    businessOrderServerAllocationContext.setResourceContainer_AllocationContext(businessOrderServer);
    privateOrderServerAllocationContext.setResourceContainer_AllocationContext(privateOrderServer);
    resource.updatePartition(this.testModel);
    final Allocation readModel = resource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
    resource.getGraphDatabaseService().shutdown();
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 7 with AllocationContext

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

the class AllocationDataFactory method createAllocationContext.

private static AllocationContext createAllocationContext(final System system, final ResourceEnvironment resourceEnvironment, final String allocation, final String assemblyContextName, final String containerName) {
    final AllocationContext context = AllocationFactory.eINSTANCE.createAllocationContext();
    final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(system, assemblyContextName);
    final ResourceContainer container = ResourceEnvironmentDataFactory.findContainer(resourceEnvironment, containerName);
    context.setEntityName(allocation);
    context.setAssemblyContext_AllocationContext(assemblyContext);
    context.setResourceContainer_AllocationContext(container);
    return context;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 8 with AllocationContext

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

the class UndeploymentModelUpdater method execute.

/**
 * This method is triggered for every undeployment event.
 *
 * @param event
 *            undeployment event
 * @throws DBException
 *             on db errors
 */
@Override
protected void execute(final PCMUndeployedEvent event) throws DBException {
    DeploymentLock.lock();
    ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.UNDEPLOYMENT, ObservationPoint.MODEL_UPDATE_ENTRY);
    this.logger.debug("Undeployment assemblyContext={} resourceContainer={}", event.getAssemblyContext(), event.getResourceContainer());
    final String allocationContextName = NameFactory.createAllocationContextName(event.getAssemblyContext(), event.getResourceContainer());
    final List<AllocationContext> allocationContexts = this.allocationModelResource.findObjectsByTypeAndProperty(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT, "entityName", allocationContextName);
    if (allocationContexts.size() == 1) {
        final AllocationContext allocationContext = allocationContexts.get(0);
        this.allocationModelResource.deleteObject(allocationContext);
        ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.UNDEPLOYMENT, ObservationPoint.MODEL_UPDATE_EXIT);
        DeploymentLock.unlock();
        this.outputPort.send(event);
    } else if (allocationContexts.size() > 1) {
        ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.UNDEPLOYMENT, ObservationPoint.MODEL_UPDATE_EXIT);
        this.logger.error("Undeployment failed: More than one allocation found for allocation {}", allocationContextName);
        DeploymentLock.unlock();
    } else {
        ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.UNDEPLOYMENT, ObservationPoint.MODEL_UPDATE_EXIT);
        this.logger.error("Undeployment failed: No allocation found for allocation {}", allocationContextName);
        DeploymentLock.unlock();
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext)

Example 9 with AllocationContext

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

the class PCMNeo4JTest method testUpdate.

/**
 * Test whether updates work as suggested.
 *
 * @throws NodeLookupException
 *             on node lookup errors
 * @throws DBException
 *             on db errors
 */
@Test
public void testUpdate() throws NodeLookupException, DBException {
    /**
     * store model in database.
     */
    this.repositoryResource.storeModelPartition(this.repository);
    this.resourceEnvironmentResource.storeModelPartition(this.resourceEnvironment);
    this.systemResource.storeModelPartition(this.system);
    this.allocationResource.storeModelPartition(this.allocation);
    final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
    final ResourceContainer container = ResourceEnvironmentDataFactory.findContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.QUERY_CONTAINER_3);
    final Allocation allocationModel = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    final AllocationContext newAllocationContext = AllocationFactory.eINSTANCE.createAllocationContext();
    newAllocationContext.setEntityName(AllocationDataFactory.QUERY_ALLOCATION_CONTEXT_3);
    newAllocationContext.setAssemblyContext_AllocationContext(assemblyContext);
    newAllocationContext.setResourceContainer_AllocationContext(container);
    allocationModel.getAllocationContexts_Allocation().add(newAllocationContext);
    this.allocationResource.updatePartition(allocationModel);
    for (final AllocationContext context : this.allocationResource.collectAllObjectsByType(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT)) {
    // NOCS
    // TODO
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Allocation(org.palladiosimulator.pcm.allocation.Allocation) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 10 with AllocationContext

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

the class HostComponentAllocationGraphFactory method createComponentNodes.

private Map<String, ComponentNode> createComponentNodes(final Map<String, DeploymentNode> servers, final ModelGraphRevision revision) {
    final Map<String, ComponentNode> components = new HashMap<>();
    for (final AllocationContext allocationContext : this.allocationContexts.values()) {
        final DeploymentNode hostServer = servers.get(allocationContext.getResourceContainer_AllocationContext().getId());
        final String assemblyContextID = allocationContext.getAssemblyContext_AllocationContext().getId();
        final AssemblyContext assemblyContext = this.assemblyContexts.get(assemblyContextID);
        final DataPrivacyLvl acPrivacyLvl = this.assemblyContextPrivacyLvl.get(assemblyContextID);
        final ComponentNode component = new ComponentNode(assemblyContextID, assemblyContext.getEntityName(), acPrivacyLvl, hostServer, assemblyContext.getEncapsulatedComponent__AssemblyContext().getId(), allocationContext.getId(), revision);
        hostServer.addComponent(component);
        components.put(allocationContext.getId(), component);
    }
    return components;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) HashMap(java.util.HashMap) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) DataPrivacyLvl(org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl)

Aggregations

AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)48 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)16 Set (java.util.Set)11 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)11 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)11 HashSet (java.util.HashSet)10 HashMap (java.util.HashMap)9 Allocation (org.palladiosimulator.pcm.allocation.Allocation)9 Test (org.junit.Test)7 LinkedHashSet (java.util.LinkedHashSet)4 ProbeManagementData (org.iobserve.service.privacy.violation.data.ProbeManagementData)4 Edge (org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)4 DBException (org.iobserve.model.persistence.DBException)3 InvocationException (org.iobserve.model.persistence.neo4j.InvocationException)3 ControlEventCreationFailedException (org.iobserve.service.privacy.violation.exceptions.ControlEventCreationFailedException)3 Vertex (org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex)3 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)3 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)3 LinkedList (java.util.LinkedList)2 AllocationEntry (org.iobserve.model.correspondence.AllocationEntry)2