Search in sources :

Example 1 with ResourceContainerPrivacy

use of org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy 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 ResourceContainerPrivacy

use of org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy in project iobserve-analysis by research-iobserve.

the class ResourceEnvironmentGeneration method craeteResourceEnvironment.

public ResourceEnvironment craeteResourceEnvironment(final int resourceContainerCount) {
    for (int i = 0; i < resourceContainerCount; i++) {
        final String prefix = Integer.toString(i);
        final ResourceContainerPrivacy resContainer = this.createResourceContainer(prefix);
        this.resourceEnvironment.getResourceContainer_ResourceEnvironment().add(resContainer);
    }
    return this.resourceEnvironment;
}
Also used : ResourceContainerPrivacy(org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy)

Example 3 with ResourceContainerPrivacy

use of org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy in project iobserve-analysis by research-iobserve.

the class ResourceEnvironmentGeneration method addResourceContainers.

public void addResourceContainers(final int resourceContainerCount, final String postPrefix) {
    for (int i = 0; i < resourceContainerCount; i++) {
        final String prefix = Integer.toString(i);
        final ResourceContainerPrivacy resContainer = this.createResourceContainer(prefix + "_" + postPrefix);
        this.resourceEnvironment.getResourceContainer_ResourceEnvironment().add(resContainer);
    }
}
Also used : ResourceContainerPrivacy(org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy)

Example 4 with ResourceContainerPrivacy

use of org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy in project iobserve-analysis by research-iobserve.

the class GeoLocation method execute.

@Override
protected void execute(final PCMDeployedEvent element) throws Exception {
    // TODO this might be better implemented using query functions addressing RescourceContainer
    final ResourceEnvironment resourceEnvironment = this.resourceEnvironmentModelProvider.readRootComponent(ResourceEnvironment.class);
    final EList<ResourceContainer> resContainers = resourceEnvironment.getResourceContainer_ResourceEnvironment();
    for (final ResourceContainer resContainer : resContainers) {
        if (resContainer.getEntityName().equals(element.getService()) && resContainer instanceof ResourceContainerPrivacy) {
            final ResourceContainerPrivacy resContainerPrivacy = (ResourceContainerPrivacy) resContainer;
            final int geolocation = resContainerPrivacy.getGeolocation();
            if (geolocation != element.getCountryCode()) {
                resContainerPrivacy.setGeolocation(element.getCountryCode());
                this.outputPort.send(element);
            }
            break;
        }
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ResourceContainerPrivacy(org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 5 with ResourceContainerPrivacy

use of org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy in project iobserve-analysis by research-iobserve.

the class ResourceEnvironmentModelFactory method createResourceContainer.

/**
 * Create a {@link ResourceContainer} with the given name, without checking if it already
 * exists. Use {@link #createResourceContainerIfAbsent(String)} instead if you wont create the
 * container if it is already available.
 *
 * @param model
 *            resource environment model
 * @param name
 *            name of the new container
 * @return builder
 */
public static ResourceContainer createResourceContainer(final ResourceEnvironment model, final String name) {
    final ResourceContainerPrivacy resContainer = ResourceenvironmentPrivacyFactory.eINSTANCE.createResourceContainerPrivacy();
    resContainer.setEntityName(name);
    model.getResourceContainer_ResourceEnvironment().add(resContainer);
    return resContainer;
}
Also used : ResourceContainerPrivacy(org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy)

Aggregations

ResourceContainerPrivacy (org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy)6 HashMap (java.util.HashMap)1 AssemblyConnectorPrivacy (org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy)1 DataPrivacyLvl (org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl)1 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)1 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)1 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)1