Search in sources :

Example 16 with AllocationContext

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

the class ModelProbeController method computeReceivedWarnings.

private Map<AllocationContext, Set<OperationSignature>> computeReceivedWarnings(final List<Edge> edges) {
    final Map<AllocationContext, Set<OperationSignature>> receivedWarnings = new HashMap<>();
    this.logger.debug("Compute received warnings {}", edges.size());
    for (final Edge edge : edges) {
        this.logger.debug("Compute received warnings for edge={}", edge.getName());
        // multiple methods per allocation possible
        final AllocationContext allocation = edge.getSource().getAllocationContext();
        if (allocation != null) {
            this.logger.debug("Compute received warnings for {} {}", allocation.getEntityName(), edge.getOperationSignature().getEntityName());
            Set<OperationSignature> methodSignatures = receivedWarnings.get(allocation);
            // if not present, add new entry
            if (methodSignatures == null) {
                methodSignatures = new HashSet<>();
            }
            if (edge.getOperationSignature() != null) {
                methodSignatures.add(edge.getOperationSignature());
                receivedWarnings.put(allocation, methodSignatures);
            } else {
                this.logger.debug("Received warning without operation signature");
            }
        } else {
            this.logger.debug("Compute received warnings No ALLOCATION for the specified edge {}", edge.getName());
        }
    }
    return receivedWarnings;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) Edge(org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)

Example 17 with AllocationContext

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

the class ModelProbeController method execute.

@Override
protected void execute(final WarningModel element) throws Exception {
    if (element.getWarningEdges() == null || element.getWarningEdges().isEmpty()) {
        this.logger.error("Received warning with empty edge list");
        return;
    } else {
        // ExperimentLoggingUtils.logEvent(element.getEvent().getTimestamp(), EventTypes.NONE,
        // ObservationPoint.COMPUTE_PROBE_CONFIGURATION_ENTRY);
        final Map<AllocationContext, Set<OperationSignature>> receivedWarnings = this.computeReceivedWarnings(element.getWarningEdges());
        final Map<AllocationContext, Set<OperationSignature>> currentWarnings = new HashMap<>(this.currentActiveWarnings);
        final ProbeManagementData probeMethodInformation = this.computeWarningDifferences(currentWarnings, receivedWarnings, element.getEvent());
        this.currentActiveWarnings = this.computeNewWarningMap(currentWarnings, probeMethodInformation.getMethodsToActivate(), probeMethodInformation.getMethodsToDeactivate());
        probeMethodInformation.setProtectedOperations(receivedWarnings);
        probeMethodInformation.setOperationsToUpdate(this.currentActiveWarnings);
        // ExperimentLoggingUtils.logEvent(element.getEvent().getTimestamp(), EventTypes.NONE,
        // ObservationPoint.COMPUTE_PROBE_CONFIGURATION_EXIT);
        this.outputPort.send(probeMethodInformation);
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ProbeManagementData(org.iobserve.service.privacy.violation.data.ProbeManagementData)

Example 18 with AllocationContext

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

the class ModelProbeController method computeWarningDifferences.

private ProbeManagementData computeWarningDifferences(final Map<AllocationContext, Set<OperationSignature>> currentWarnings, final Map<AllocationContext, Set<OperationSignature>> receivedWarnings, final IPCMDeploymentEvent ipcmDeploymentEvent) {
    Map<AllocationContext, Set<OperationSignature>> missingWarnings = new HashMap<>();
    Map<AllocationContext, Set<OperationSignature>> addedWarnings = new HashMap<>();
    missingWarnings = new HashMap<>();
    addedWarnings = new HashMap<>();
    final Map<AllocationContext, Set<OperationSignature>> newAllocationWarnings = new HashMap<>(receivedWarnings);
    // already existing allocations
    for (final AllocationContext allocation : currentWarnings.keySet()) {
        final Set<OperationSignature> newMethodSet = receivedWarnings.get(allocation);
        final Set<OperationSignature> currentMethods = currentWarnings.get(allocation);
        // no new allocation -> all old methods have to be deactivated
        if (newMethodSet == null) {
            missingWarnings.put(allocation, currentMethods);
        } else {
            // current - new = missing methods = deactivate
            final Set<OperationSignature> missingMethods = new HashSet<>(currentMethods);
            missingMethods.removeAll(newMethodSet);
            // new - current = added methods = activate
            final Set<OperationSignature> addedMethods = new HashSet<>(newMethodSet);
            addedMethods.removeAll(currentMethods);
            if (!missingMethods.isEmpty()) {
                missingWarnings.put(allocation, missingMethods);
            }
            if (!addedMethods.isEmpty()) {
                addedWarnings.put(allocation, addedMethods);
            }
        }
        // the remaining entries are completely new warnings and allocations
        newAllocationWarnings.remove(allocation);
    }
    addedWarnings.putAll(newAllocationWarnings);
    final ProbeManagementData result = new ProbeManagementData(addedWarnings, missingWarnings);
    result.setTriggerTime(ipcmDeploymentEvent.getTimestamp());
    return result;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) ProbeManagementData(org.iobserve.service.privacy.violation.data.ProbeManagementData) HashSet(java.util.HashSet)

Example 19 with AllocationContext

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

the class NonAdaptiveModelProbeController method computeAvailableProbes.

/**
 * Compute available probes.
 *
 * @return returns a map of {@link AllocationContext}s and their relevant
 *         {@link OperationSignature}s
 * @throws DBException
 */
private Map<AllocationContext, Set<OperationSignature>> computeAvailableProbes() throws DBException {
    final Repository repositoryModel = this.repositoryResource.getModelRootNode(Repository.class, RepositoryPackage.Literals.REPOSITORY);
    final List<AllocationContext> allocations = this.allocationResource.collectAllObjectsByType(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT);
    final Map<AllocationContext, Set<OperationSignature>> availableProbes = new HashMap<>();
    this.logger.debug("Found " + allocations.size() + " allocation context entries");
    for (final AllocationContext allocation : allocations) {
        final Set<OperationSignature> allocationMethods = new LinkedHashSet<>();
        try {
            final AssemblyContext assemblyContext = this.systemModelResource.resolve(allocation.getAssemblyContext_AllocationContext());
            final RepositoryComponent component = this.repositoryResource.resolve(assemblyContext.getEncapsulatedComponent__AssemblyContext());
            final List<ProvidedRole> providingRoles = component.getProvidedRoles_InterfaceProvidingEntity();
            for (final ProvidedRole providedRole : providingRoles) {
                this.logger.debug("Providing roles: " + providingRoles);
                final String roleName = providedRole.getEntityName();
                for (final Interface iface : repositoryModel.getInterfaces__Repository()) {
                    if (iface instanceof OperationInterface) {
                        if (roleName.contains(iface.getEntityName())) {
                            this.logger.debug("Matching operation interfaces: " + ((OperationInterface) iface).getSignatures__OperationInterface());
                            // found interface
                            allocationMethods.addAll(((OperationInterface) iface).getSignatures__OperationInterface());
                        }
                    }
                }
            }
        } catch (InvocationException | DBException e) {
            this.logger.error("Could not resolve elements of the PCM during the computation of the available probes", e);
        }
        availableProbes.put(allocation, allocationMethods);
    }
    return availableProbes;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DBException(org.iobserve.model.persistence.DBException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashMap(java.util.HashMap) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Repository(org.palladiosimulator.pcm.repository.Repository) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) InvocationException(org.iobserve.model.persistence.neo4j.InvocationException) RepositoryComponent(org.palladiosimulator.pcm.repository.RepositoryComponent) OperationInterface(org.palladiosimulator.pcm.repository.OperationInterface) Interface(org.palladiosimulator.pcm.repository.Interface)

Example 20 with AllocationContext

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

the class WhitelistFilter method computeForbiddenIps.

private Set<String> computeForbiddenIps(final Map<AllocationContext, Set<OperationSignature>> warnedMethods) {
    final Set<AllocationContext> allocationSet = new LinkedHashSet<>();
    allocationSet.addAll(warnedMethods.keySet());
    final Set<String> blacklistSet = new HashSet<>();
    for (final AllocationContext allocation : allocationSet) {
        try {
            blacklistSet.add(this.resourceEnvironmentResource.resolve(allocation.getResourceContainer_AllocationContext()).getEntityName());
        } catch (InvocationException | DBException e) {
            this.logger.error("Could not resolve resource container during the computation of the IP of the black list from: " + allocation, e);
        }
    }
    return blacklistSet;
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) LinkedHashSet(java.util.LinkedHashSet) DBException(org.iobserve.model.persistence.DBException) InvocationException(org.iobserve.model.persistence.neo4j.InvocationException) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

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