Search in sources :

Example 1 with AssemblyConnectorPrivacy

use of org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy in project iobserve-analysis by research-iobserve.

the class GraphFactory method createModelGraph.

/*
     * Build Graph Helpers
     */
private ModelGraph createModelGraph() {
    final Map<String, DeploymentNode> servers = new HashMap<>();
    final Map<String, ComponentNode> components = new HashMap<>();
    // Build Servers Nodes
    for (final ResourceContainerPrivacy resContainer : this.resourceContainers.values()) {
        final DeploymentNode server = new DeploymentNode(resContainer.getId(), resContainer.getEntityName(), resContainer.getGeolocation());
        servers.put(resContainer.getId(), server);
    }
    // Build Component Nodes
    for (final AssemblyContext ac : this.assemblyContexts.values()) {
        final DeploymentNode hostServer = servers.get(this.ac2rcMap.get(ac.getId()));
        final DataPrivacyLvl acPrivacyLvl = this.assemblyContextPrivacyLvl.get(ac.getId());
        final ComponentNode component = new ComponentNode(ac.getId(), ac.getEntityName(), acPrivacyLvl, hostServer, ac.getEncapsulatedComponent__AssemblyContext().getId(), this.assemblyID2allocID.get(ac.getId()));
        hostServer.addComponent(component);
        components.put(ac.getId(), component);
    }
    // Set Edges
    for (final AssemblyConnectorPrivacy acp : this.assemblyConnectors.values()) {
        final String provACID = acp.getProvidingAssemblyContext_AssemblyConnector().getId();
        final String reqACID = acp.getRequiringAssemblyContext_AssemblyConnector().getId();
        final ComponentNode provNode = components.get(provACID);
        final ComponentNode reqNode = components.get(reqACID);
        final ComponentEdge edge = new ComponentEdge(acp.getId(), acp.getEntityName(), provNode, reqNode, acp.getPrivacyLevel());
        provNode.addCommunicationEdge(edge);
        reqNode.addCommunicationEdge(edge);
    }
    return new ModelGraph(servers.values(), components.values(), this.modelProvider);
}
Also used : AssemblyConnectorPrivacy(org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy) HashMap(java.util.HashMap) ResourceContainerPrivacy(org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) DataPrivacyLvl(org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl)

Example 2 with AssemblyConnectorPrivacy

use of org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy in project iobserve-analysis by research-iobserve.

the class GraphFactory method extractAssemblyConnectors.

private void extractAssemblyConnectors(final org.palladiosimulator.pcm.system.System sysModel) {
    final EList<Connector> newConnectors = sysModel.getConnectors__ComposedStructure();
    for (final Connector connector : newConnectors) {
        if (connector instanceof AssemblyConnectorPrivacy) {
            final AssemblyConnectorPrivacy acp = (AssemblyConnectorPrivacy) connector;
            this.assemblyConnectors.put(connector.getId(), acp);
        }
    }
}
Also used : Connector(org.palladiosimulator.pcm.core.composition.Connector) AssemblyConnectorPrivacy(org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy)

Example 3 with AssemblyConnectorPrivacy

use of org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy in project iobserve-analysis by research-iobserve.

the class GraphFactory method adaptPrivacyLvl.

private void adaptPrivacyLvl() {
    final Collection<AssemblyConnectorPrivacy> acps = this.assemblyConnectors.values();
    final Set<String> acs = new HashSet<>();
    for (final AssemblyConnectorPrivacy acp : acps) {
        final DataPrivacyLvl assemblyConnectorPrivacyLvl = acp.getPrivacyLevel();
        final String providedACID = acp.getProvidingAssemblyContext_AssemblyConnector().getId();
        final String requiredACID = acp.getRequiringAssemblyContext_AssemblyConnector().getId();
        this.updatePrivacyLvl(acp, assemblyConnectorPrivacyLvl, providedACID);
        this.updatePrivacyLvl(acp, assemblyConnectorPrivacyLvl, requiredACID);
        acs.add(requiredACID);
        acs.add(providedACID);
    }
    if (GraphFactory.LOGGER.isInfoEnabled()) {
        GraphFactory.LOGGER.info("Individual Assembly Contexts found in Assembly Connectors: " + acs.size());
    }
}
Also used : AssemblyConnectorPrivacy(org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy) DataPrivacyLvl(org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl) HashSet(java.util.HashSet)

Example 4 with AssemblyConnectorPrivacy

use of org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy in project iobserve-analysis by research-iobserve.

the class SystemGeneration method createAssemblyConnector.

/*
     * This method creates an assembly connector between the given AssemblyContextes for the given
     * interface.
     */
private AssemblyConnector createAssemblyConnector(final AssemblyContext requiringAC, final AssemblyContext providingAC, final String interfaceID) {
    final AssemblyConnectorPrivacy connector = SystemGeneration.COMPOSITION_PRIVACY_FACTORY.createAssemblyConnectorPrivacy();
    connector.setEntityName(requiringAC.getEntityName() + " -> " + providingAC.getEntityName());
    final java.util.Optional<ProvidedRole> providedRole = providingAC.getEncapsulatedComponent__AssemblyContext().getProvidedRoles_InterfaceProvidingEntity().stream().filter(s -> this.matchingInterface(s, interfaceID)).findFirst();
    final java.util.Optional<RequiredRole> requiredRole = requiringAC.getEncapsulatedComponent__AssemblyContext().getRequiredRoles_InterfaceRequiringEntity().stream().filter(s -> this.matchingInterface(s, interfaceID)).findFirst();
    connector.setProvidingAssemblyContext_AssemblyConnector(providingAC);
    connector.setRequiringAssemblyContext_AssemblyConnector(requiringAC);
    connector.setProvidedRole_AssemblyConnector((OperationProvidedRole) providedRole.get());
    connector.setRequiredRole_AssemblyConnector((OperationRequiredRole) requiredRole.get());
    final float randFloat = ThreadLocalRandom.current().nextFloat();
    if (randFloat < 0.15) {
        connector.setPrivacyLevel(DataPrivacyLvl.PERSONAL);
    } else if (randFloat < 0.50) {
        connector.setPrivacyLevel(DataPrivacyLvl.DEPERSONALIZED);
    } else {
        connector.setPrivacyLevel(DataPrivacyLvl.ANONYMIZED);
    }
    this.system.getConnectors__ComposedStructure().add(connector);
    this.unconnectedAssemblyContextes.remove(requiringAC);
    this.unconnectedAssemblyContextes.remove(providingAC);
    return connector;
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Map(java.util.Map) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) AssemblyConnectorPrivacy(org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy) System(org.palladiosimulator.pcm.system.System) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) LinkedList(java.util.LinkedList) SystemFactoryImpl(org.palladiosimulator.pcm.system.impl.SystemFactoryImpl) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) Logger(org.slf4j.Logger) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) Set(java.util.Set) Connector(org.palladiosimulator.pcm.core.composition.Connector) EList(org.eclipse.emf.common.util.EList) CompositionPrivacyFactory(org.palladiosimulator.pcm.compositionprivacy.CompositionPrivacyFactory) List(java.util.List) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole) DataPrivacyLvl(org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) Repository(org.palladiosimulator.pcm.repository.Repository) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) AssemblyConnectorPrivacy(org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) OperationRequiredRole(org.palladiosimulator.pcm.repository.OperationRequiredRole)

Aggregations

AssemblyConnectorPrivacy (org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy)4 DataPrivacyLvl (org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)2 Connector (org.palladiosimulator.pcm.core.composition.Connector)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 EList (org.eclipse.emf.common.util.EList)1 CompositionPrivacyFactory (org.palladiosimulator.pcm.compositionprivacy.CompositionPrivacyFactory)1 AssemblyConnector (org.palladiosimulator.pcm.core.composition.AssemblyConnector)1 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)1 OperationRequiredRole (org.palladiosimulator.pcm.repository.OperationRequiredRole)1 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)1 Repository (org.palladiosimulator.pcm.repository.Repository)1 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)1