Search in sources :

Example 1 with InvocationException

use of org.iobserve.model.persistence.neo4j.InvocationException 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 2 with InvocationException

use of org.iobserve.model.persistence.neo4j.InvocationException 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)

Example 3 with InvocationException

use of org.iobserve.model.persistence.neo4j.InvocationException in project iobserve-analysis by research-iobserve.

the class WhitelistFilter method computeAvailableIps.

private Set<String> computeAvailableIps() throws DBException {
    final List<AllocationContext> allocations = this.allocationResource.collectAllObjectsByType(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT);
    final Set<String> availableIps = new LinkedHashSet<>();
    for (final AllocationContext allocation : allocations) {
        try {
            availableIps.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 from: " + allocation, e);
        }
    }
    return availableIps;
}
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)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)3 DBException (org.iobserve.model.persistence.DBException)3 InvocationException (org.iobserve.model.persistence.neo4j.InvocationException)3 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)3 HashSet (java.util.HashSet)2 HashMap (java.util.HashMap)1 Set (java.util.Set)1 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)1 Interface (org.palladiosimulator.pcm.repository.Interface)1 OperationInterface (org.palladiosimulator.pcm.repository.OperationInterface)1 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)1 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)1 Repository (org.palladiosimulator.pcm.repository.Repository)1 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)1