Search in sources :

Example 1 with ProbeManagementData

use of org.iobserve.service.privacy.violation.data.ProbeManagementData in project iobserve-analysis by research-iobserve.

the class ModelProbeControllerTest method testEmptyWarningList.

@Test
public void testEmptyWarningList() {
    final WarningModel warnings = new WarningModel();
    warnings.setWarningEdges(null);
    final List<WarningModel> input1 = new LinkedList<>();
    input1.add(warnings);
    final List<ProbeManagementData> output = new LinkedList<>();
    this.modelProbeController = new ModelProbeController();
    StageTester.test(this.modelProbeController).and().send(input1).to(this.modelProbeController.getInputPort()).receive(output).from(this.modelProbeController.getOutputPort()).start();
    Assert.assertTrue(output.isEmpty());
}
Also used : ModelProbeController(org.iobserve.service.privacy.violation.filter.ModelProbeController) ProbeManagementData(org.iobserve.service.privacy.violation.data.ProbeManagementData) WarningModel(org.iobserve.service.privacy.violation.data.WarningModel) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 2 with ProbeManagementData

use of org.iobserve.service.privacy.violation.data.ProbeManagementData in project iobserve-analysis by research-iobserve.

the class ModelProbeControllerTest method testNullWarningList.

@Test
public void testNullWarningList() {
    final WarningModel warnings = new WarningModel();
    warnings.setWarningEdges(null);
    final List<WarningModel> input1 = new LinkedList<>();
    input1.add(warnings);
    final List<ProbeManagementData> output = new LinkedList<>();
    this.modelProbeController = new ModelProbeController();
    StageTester.test(this.modelProbeController).and().send(input1).to(this.modelProbeController.getInputPort()).receive(output).from(this.modelProbeController.getOutputPort()).start();
    Assert.assertTrue(output.isEmpty());
}
Also used : ModelProbeController(org.iobserve.service.privacy.violation.filter.ModelProbeController) ProbeManagementData(org.iobserve.service.privacy.violation.data.ProbeManagementData) WarningModel(org.iobserve.service.privacy.violation.data.WarningModel) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 3 with ProbeManagementData

use of org.iobserve.service.privacy.violation.data.ProbeManagementData in project iobserve-analysis by research-iobserve.

the class ProbeMapperTest method receiveEmptyDataTest.

@Test
public void receiveEmptyDataTest() {
    this.probeMapper = new ProbeMapper(Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class));
    final ProbeManagementData data = new ProbeManagementData(new HashMap<AllocationContext, Set<OperationSignature>>(), new HashMap<AllocationContext, Set<OperationSignature>>());
    final List<ProbeManagementData> input = new LinkedList<>();
    input.add(data);
    final List<AbstractTcpControlEvent> output = new LinkedList<>();
    StageTester.test(this.probeMapper).and().send(input).to(this.probeMapper.getInputPort()).receive(output).from(this.probeMapper.getOutputPort()).start();
    Assert.assertTrue(output.isEmpty());
}
Also used : ProbeMapper(org.iobserve.service.privacy.violation.filter.ProbeMapper) AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AbstractTcpControlEvent(org.iobserve.utility.tcp.events.AbstractTcpControlEvent) Set(java.util.Set) ProbeManagementData(org.iobserve.service.privacy.violation.data.ProbeManagementData) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 4 with ProbeManagementData

use of org.iobserve.service.privacy.violation.data.ProbeManagementData 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 5 with ProbeManagementData

use of org.iobserve.service.privacy.violation.data.ProbeManagementData 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)

Aggregations

ProbeManagementData (org.iobserve.service.privacy.violation.data.ProbeManagementData)8 LinkedList (java.util.LinkedList)5 Test (org.junit.Test)5 Set (java.util.Set)4 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 WarningModel (org.iobserve.service.privacy.violation.data.WarningModel)3 ModelProbeController (org.iobserve.service.privacy.violation.filter.ModelProbeController)3 ProbeMapper (org.iobserve.service.privacy.violation.filter.ProbeMapper)2 AbstractTcpControlEvent (org.iobserve.utility.tcp.events.AbstractTcpControlEvent)2 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)2 Edge (org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)1 Vertex (org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex)1