use of org.iobserve.model.persistence.DBException 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;
}
use of org.iobserve.model.persistence.DBException 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;
}
use of org.iobserve.model.persistence.DBException in project iobserve-analysis by research-iobserve.
the class AnalysisMain method createTeetimeConfiguration.
@Override
protected AnalysisConfiguration createTeetimeConfiguration() throws ConfigurationException {
/**
* Configure model handling.
*/
if (this.parameterConfiguration.isPcmFeature()) {
try {
final ModelImporter modelHandler = new ModelImporter(this.parameterConfiguration.getModelInitDirectory());
/**
* initialize neo4j graphs.
*/
final Neo4JModelResource<CorrespondenceModel> correspondenceModelResource = new Neo4JModelResource<>(CorrespondencePackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "correspondence"));
correspondenceModelResource.storeModelPartition(modelHandler.getCorrespondenceModel());
final Neo4JModelResource<Repository> repositoryModelResource = new Neo4JModelResource<>(RepositoryPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "repository"));
repositoryModelResource.storeModelPartition(modelHandler.getRepositoryModel());
final Neo4JModelResource<ResourceEnvironment> resourceEnvironmentModelResource = new Neo4JModelResource<>(ResourceenvironmentPackage.eINSTANCE, // add
new File(this.parameterConfiguration.getModelDatabaseDirectory(), "resourceenvironment"));
resourceEnvironmentModelResource.storeModelPartition(modelHandler.getResourceEnvironmentModel());
final Neo4JModelResource<System> systemModelResource = new Neo4JModelResource<>(SystemPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "system"));
systemModelResource.storeModelPartition(modelHandler.getSystemModel());
final Neo4JModelResource<Allocation> allocationModelResource = new Neo4JModelResource<>(AllocationPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "allocation"));
allocationModelResource.storeModelPartition(modelHandler.getAllocationModel());
final Neo4JModelResource<UsageModel> usageModelResource = new Neo4JModelResource<>(UsagemodelPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "usageModel"));
usageModelResource.storeModelPartition(modelHandler.getUsageModel());
final Neo4JModelResource<DataProtectionModel> privacyModelResource = new Neo4JModelResource<>(PrivacyPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "privacy"));
privacyModelResource.storeModelPartition(modelHandler.getPrivacyModel());
// get systemId
final System systemModel = systemModelResource.getModelRootNode(System.class, SystemPackage.Literals.SYSTEM);
this.kiekerConfiguration.setProperty(ConfigurationKeys.SYSTEM_ID, systemModel.getId());
return new AnalysisConfiguration(this.kiekerConfiguration, repositoryModelResource, resourceEnvironmentModelResource, systemModelResource, allocationModelResource, usageModelResource, correspondenceModelResource);
} catch (final IOException e) {
// TODO should be replaced by logger
// NOPMD
java.lang.System.err.println("Cannot load all models " + e.getLocalizedMessage());
// required
return null;
} catch (final DBException e) {
// TODO should be replaced by logger
// NOPMD
java.lang.System.err.println("Cannot store all models in DB " + e.getLocalizedMessage());
// required
return null;
}
} else {
return new AnalysisConfiguration(this.kiekerConfiguration);
}
}
use of org.iobserve.model.persistence.DBException in project iobserve-analysis by research-iobserve.
the class NetworkLink method execute.
/**
* Execute this filter.
*
* @param event
* event to use
* @throws NodeLookupException
* @throws DBException
* on db errors
*/
@Override
protected void execute(final TraceMetadata event) throws NodeLookupException, DBException {
final ResourceEnvironment resourceEnvironment = this.resourceEnvironmentModelResource.getAndLockModelRootNode(ResourceEnvironment.class, ResourceenvironmentPackage.Literals.RESOURCE_ENVIRONMENT);
final System system = this.systemModelResource.getModelRootNode(System.class, SystemPackage.Literals.SYSTEM);
final Allocation allocation = this.allocationModelResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
NetworkLink.collectUnLinkedResourceContainer(resourceEnvironment).stream().forEach(unLinkedResCont -> {
NetworkLink.getAsmContextDeployedOnContainer(allocation, unLinkedResCont).stream().map(asmCtx -> NetworkLink.getConnectedAsmCtx(system, asmCtx)).map(listAsmCtxToConnect -> NetworkLink.collectResourceContainer(allocation, listAsmCtxToConnect)).map(listResContToConnectTo -> NetworkLink.getLinkingResources(resourceEnvironment, listResContToConnectTo)).flatMap(l -> l.stream()).collect(Collectors.toList()).stream().forEach(link -> link.getConnectedResourceContainers_LinkingResource().add(unLinkedResCont));
});
this.resourceEnvironmentModelResource.updatePartition(resourceEnvironment);
}
use of org.iobserve.model.persistence.DBException in project iobserve-analysis by research-iobserve.
the class MemoryModelResource method deleteObject.
@SuppressWarnings("unchecked")
@Override
public <T> void deleteObject(final EObject object) throws DBException {
final EObject container = object.eContainer();
final EStructuralFeature feature = object.eContainingFeature();
if (feature.isMany()) {
if (!((EList<EObject>) container.eGet(feature)).remove(object)) {
throw new DBException("Object does not exist in database.");
}
} else {
container.eSet(feature, null);
}
}
Aggregations