Search in sources :

Example 11 with AllocationContext

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

the class EntryEventMapperStage method computePcmEntryCallEvent.

private void computePcmEntryCallEvent(final ComponentEntry componentEntry, final OperationEntry operationEntry, final AllocationEntry allocationEntry, final EntryCallEvent event) throws DBException {
    /**
     * retrieve PCM model elements from mapping.
     */
    final AllocationContext allocationContext = this.allocationResource.findObjectByTypeAndId(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT, ModelGraphFactory.getIdentification(allocationEntry.getAllocation()));
    final OperationSignature operationSignature = this.repositoryResource.findAndLockObjectById(OperationSignature.class, RepositoryPackage.Literals.OPERATION_SIGNATURE, ModelGraphFactory.getIdentification(operationEntry.getOperation()));
    final RepositoryComponent component = this.repositoryResource.findObjectByTypeAndId(RepositoryComponent.class, RepositoryPackage.Literals.REPOSITORY_COMPONENT, ModelGraphFactory.getIdentification(componentEntry.getComponent()));
    /**
     * assembly is inferred from allocation.
     */
    final AssemblyContext assemblyContext = this.assemblyResource.findObjectByTypeAndId(AssemblyContext.class, CompositionPackage.Literals.ASSEMBLY_CONTEXT, ModelGraphFactory.getIdentification(allocationContext.getAssemblyContext_AllocationContext()));
    /**
     * assemble event.
     */
    final PCMEntryCallEvent mappedEvent = new PCMEntryCallEvent(event.getEntryTime(), event.getExitTime(), component, operationSignature, assemblyContext, allocationContext);
    this.outputPort.send(mappedEvent);
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) PCMEntryCallEvent(org.iobserve.service.privacy.violation.data.PCMEntryCallEvent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent)

Example 12 with AllocationContext

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

the class ProbeMapper method createMethodsToActivate.

private void createMethodsToActivate(final ProbeManagementData element) throws ControlEventCreationFailedException, InvocationException, DBException {
    final Map<AllocationContext, Set<OperationSignature>> methodsToActivate = element.getMethodsToActivate();
    if (methodsToActivate != null) {
        this.logger.debug("methods to activate");
        for (final AllocationContext allocation : methodsToActivate.keySet()) {
            this.logger.debug("AllocationContext to activate {}", allocation.getEntityName());
            for (final OperationSignature operationSignature : methodsToActivate.get(allocation)) {
                this.logger.debug("AllocationContext activate operation {}", operationSignature.getEntityName());
                try {
                    final String pattern = this.computeAllocationComponentIdentifierPattern(allocation, operationSignature);
                    this.logger.debug("AllocationContext activate operation {} -- {}", operationSignature.getEntityName(), pattern);
                    final TcpActivationControlEvent currentEvent = this.createActivationEvent(pattern, element.getTriggerTime(), element.getWhitelist());
                    this.fillTcpControlEvent(currentEvent, allocation);
                    this.outputPort.send(currentEvent);
                } catch (final ControlEventCreationFailedException e) {
                    this.logger.error("Could not construct activation event for: " + operationSignature.toString(), e);
                }
            }
        }
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) TcpActivationControlEvent(org.iobserve.utility.tcp.events.TcpActivationControlEvent) Set(java.util.Set) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) ControlEventCreationFailedException(org.iobserve.service.privacy.violation.exceptions.ControlEventCreationFailedException)

Example 13 with AllocationContext

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

the class ProbeMapper method findAllocationEntry.

/**
 * Find the corresponding AllocationEntry for an AllocationContext.
 *
 * @param allocation
 *            the allocation context
 * @return returns the AllocationEntry
 * @throws InvocationException
 * @throws DBException
 */
private AllocationEntry findAllocationEntry(final AllocationContext allocation) throws InvocationException, DBException {
    final List<AllocationEntry> allocations = this.correspondenceResource.collectAllObjectsByType(AllocationEntry.class, CorrespondencePackage.Literals.ALLOCATION_ENTRY);
    for (final AllocationEntry entry : allocations) {
        final AllocationContext entryAllocation = this.allocationResource.resolve(entry.getAllocation());
        this.logger.debug("XXXXX entry id {} name {} / ac id {} name {}", entryAllocation.getId(), entryAllocation.getEntityName(), allocation.getId(), allocation.getEntityName());
        if (entryAllocation.getId().equals(allocation.getId())) {
            return entry;
        }
    }
    throw new InternalError("Correspondence entry missing for " + allocation.getEntityName());
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AllocationEntry(org.iobserve.model.correspondence.AllocationEntry)

Example 14 with AllocationContext

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

the class DataProtectionWarner method print.

private void print(final PrivacyGraph graph) {
    java.lang.System.out.println("Graph-Name " + graph.getName());
    java.lang.System.out.println("Vertices");
    for (final Entry<String, Vertex> entry : graph.getVertices().entrySet()) {
        final String entityName;
        final AllocationContext context = entry.getValue().getAllocationContext();
        if (context != null) {
            entityName = context.getEntityName();
        } else {
            entityName = "<missing allocation context>";
        }
        java.lang.System.out.println("\t" + entry.getKey() + " = " + entry.getValue().getName() + " : " + entityName);
    }
    java.lang.System.out.println("Edges");
    for (final Edge value : graph.getEdges()) {
        final String entityName;
        final OperationSignature context = value.getOperationSignature();
        if (context != null) {
            entityName = context.getEntityName();
        } else {
            entityName = "<missing operation signature>";
        }
        java.lang.System.out.println("\t" + entityName + " " + value.getSource().getName() + " -> " + value.getTarget().getName());
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)

Example 15 with AllocationContext

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

the class DataProtectionWarner method addDeployedComponents.

/**
 * Adding deployment info.
 *
 * @param privacyGraph
 *            the graph containing privacy information
 * @throws DBException
 * @throws InvocationException
 */
private void addDeployedComponents(final PrivacyGraph privacyGraph) throws InvocationException, DBException {
    DeploymentLock.lock();
    for (final AllocationContext allocationContext : this.allocationRootElement.getAllocationContexts_Allocation()) {
        final AssemblyContext proxyAssemblyContext = allocationContext.getAssemblyContext_AllocationContext();
        final AssemblyContext assemblyContext = this.systemModelResource.resolve(proxyAssemblyContext);
        final RepositoryComponent proxyComponent = assemblyContext.getEncapsulatedComponent__AssemblyContext();
        final BasicComponent basicComponent = (BasicComponent) this.repositoryResource.resolve(proxyComponent);
        /**
         * Creating component vertices. *
         */
        // TODO name should be allocation name or assembly name + instance count
        final Vertex vertex = new Vertex(basicComponent.getEntityName(), this.computeStereotype(basicComponent));
        vertex.setAllocationContext(allocationContext);
        privacyGraph.addVertex(vertex);
        this.vertices.put(basicComponent.getId(), vertex);
        final ResourceContainer resourceContainer = this.resourceEnvironmentResource.resolve(allocationContext.getResourceContainer_AllocationContext());
        final GeoLocation geo = this.geolocations.get(resourceContainer.getId());
        if (geo == null) {
            this.logger.info("Geolocation infomation not available {}", resourceContainer.getId());
        } else {
            final Vertex vGeo = new Vertex(geo.getIsocode().getName(), EStereoType.GEOLOCATION);
            if (!this.vertices.containsKey(geo.getIsocode().getName())) {
                // New Geolocation
                privacyGraph.addVertex(vGeo);
                privacyGraph.addEdge(vGeo, vertex);
                this.vertices.put(geo.getIsocode().getName(), vGeo);
            } else {
                // Existing Geolocation
                privacyGraph.addEdge(this.vertices.get(geo.getIsocode().getName()), vertex);
            }
        }
    }
    DeploymentLock.unlock();
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Vertex(org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) GeoLocation(org.iobserve.model.privacy.GeoLocation) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

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