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;
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations