Search in sources :

Example 1 with PCMUndeployedEvent

use of org.iobserve.analysis.deployment.data.PCMUndeployedEvent in project iobserve-analysis by research-iobserve.

the class UndeploymentVisualizationStageTest method setUp.

/**
 * Initialize test data and stub necessary method calls.
 *
 * @throws MalformedURLException
 *             if the creation of the URL fails.
 */
@Before
public void setUp() throws MalformedURLException {
    final URL changelogURL = new URL("http://" + UndeploymentVisualizationStageTest.OUTPUT_HOSTNAME + ":" + UndeploymentVisualizationStageTest.OUTPUT_PORT + "/v1/systems/" + UndeploymentVisualizationStageTest.SYSTEM_ID + "/changelogs");
    this.undeploymentVisualizationStage = new UndeploymentVisualizationStage(changelogURL, UndeploymentVisualizationStageTest.SYSTEM_ID, this.mockedResourceContainerModelProvider, this.mockedAssemblyContextModelProvider, this.mockedSystemModelGraphProvider);
    /**
     * test correspondent
     */
    UndeploymentVisualizationStageTest.testCorrespondent = CorrespondentFactory.newInstance("test.org.pcm.entity", "testPcmEntityId", "testPcmOperationName", "testPcmOperationId");
    UndeploymentVisualizationStageTest.optTestCorrespondent = Optional.of(UndeploymentVisualizationStageTest.testCorrespondent);
    /**
     * test events
     */
    final String urlContext = UndeploymentVisualizationStageTest.CONTEXT.replaceAll("\\.", "/");
    final String url = "http://" + UndeploymentVisualizationStageTest.SERVICE + '/' + urlContext;
    final PCMUndeployedEvent undeployedEvent = new PCMUndeployedEvent(UndeploymentVisualizationStageTest.SERVICE, UndeploymentVisualizationStageTest.testCorrespondent);
    undeployedEvent.setResourceContainer(this.testResourceContainer);
    /**
     * input events
     */
    this.inputEvents.add(undeployedEvent);
    /**
     * test resource container
     */
    this.testResourceContainer = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
    this.testResourceContainer.setId(UndeploymentVisualizationStageTest.TEST_NODE_ID);
    this.testResourceContainers.add(this.testResourceContainer);
    /**
     * test assembly context
     */
    final AssemblyContext testAssemblyContext = CompositionFactory.eINSTANCE.createAssemblyContext();
    testAssemblyContext.setId("test_serviceId");
    testAssemblyContext.setEntityName("test_serviceName");
    this.testAssemblyContexts.add(testAssemblyContext);
    // stubbing
    Mockito.when(this.mockedResourceContainerModelProvider.readOnlyComponentByName(ResourceContainer.class, UndeploymentVisualizationStageTest.SERVICE)).thenReturn(this.testResourceContainers);
    Mockito.when(this.mockedCorrespondenceModel.getCorrespondent(UndeploymentVisualizationStageTest.CONTEXT)).thenReturn(UndeploymentVisualizationStageTest.optTestCorrespondent);
    final String asmContextName = UndeploymentVisualizationStageTest.testCorrespondent.getPcmEntityName() + "_" + UndeploymentVisualizationStageTest.SERVICE;
    Mockito.when(this.mockedAssemblyContextModelProvider.readOnlyComponentByName(AssemblyContext.class, asmContextName)).thenReturn(this.testAssemblyContexts);
}
Also used : PCMUndeployedEvent(org.iobserve.analysis.deployment.data.PCMUndeployedEvent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) URL(java.net.URL) Before(org.junit.Before)

Example 2 with PCMUndeployedEvent

use of org.iobserve.analysis.deployment.data.PCMUndeployedEvent in project iobserve-analysis by research-iobserve.

the class UndeployPCMMapperStage method performMapping.

private void performMapping(final String service, final String context, final long observedTime) throws InvocationException, DBException {
    DeploymentLock.lock();
    final List<AssemblyEntry> assemblyEntry = this.correspondenceModelResource.findObjectsByTypeAndProperty(AssemblyEntry.class, CorrespondencePackage.Literals.ASSEMBLY_ENTRY, "implementationId", context);
    final List<ResourceContainer> resourceContainers = this.resourceEnvironmentResource.findObjectsByTypeAndProperty(ResourceContainer.class, ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER, "entityName", service);
    if (!resourceContainers.isEmpty()) {
        if (assemblyEntry.size() == 1) {
            final ResourceContainer resourceContainer = resourceContainers.get(0);
            final AssemblyContext assemblyContext = this.systemModelResource.resolve(assemblyEntry.get(0).getAssembly());
            this.outputPort.send(new PCMUndeployedEvent(service, assemblyContext, resourceContainer, observedTime));
        } else if (assemblyEntry.isEmpty()) {
            this.logger.error("Undeplyoment failed: No corresponding assembly context {} found on {}.", context, service);
        } else if (assemblyEntry.size() > 1) {
            this.logger.error("Undeplyoment failed: Multiple corresponding assembly contexts {} found on {}.", context, service);
        }
    } else {
        this.logger.warn("Undeplyoment issue: No resource container found {}.", service);
    }
    DeploymentLock.unlock();
}
Also used : AssemblyEntry(org.iobserve.model.correspondence.AssemblyEntry) PCMUndeployedEvent(org.iobserve.analysis.deployment.data.PCMUndeployedEvent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 3 with PCMUndeployedEvent

use of org.iobserve.analysis.deployment.data.PCMUndeployedEvent in project iobserve-analysis by research-iobserve.

the class PrivacyWarner method execute.

@Override
protected void execute() throws Exception {
    final Warnings warnings = new Warnings();
    final PCMDeployedEvent deployedEvent = this.deployedInputPort.receive();
    final PCMUndeployedEvent undeployedEvent = this.undeployedInputPort.receive();
    if (deployedEvent != null) {
    // TODO generate warnings after the last deployment
    } else if (undeployedEvent != null) {
    // TODO generate warnings after the last undeployment
    }
    this.probesOutputPort.send(warnings);
    this.warningsOutputPort.send(warnings);
}
Also used : PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) PCMUndeployedEvent(org.iobserve.analysis.deployment.data.PCMUndeployedEvent) Warnings(org.iobserve.stages.data.Warnings)

Example 4 with PCMUndeployedEvent

use of org.iobserve.analysis.deployment.data.PCMUndeployedEvent in project iobserve-analysis by research-iobserve.

the class UndeployPCMMapper method servletMapper.

private void servletMapper(final ServletUndeployedEvent event) {
    final String service = event.getService();
    final String context = event.getContext();
    final Correspondent correspondent = this.correspondence.getCorrespondent(context).get();
    if (this.correspondence.getCorrespondent(context) != null) {
        this.outputPort.send(new PCMUndeployedEvent(service, correspondent));
    } else {
        UndeployPCMMapper.LOGGER.info("No correspondent found for {}.", service);
    }
}
Also used : Correspondent(org.iobserve.model.correspondence.Correspondent) PCMUndeployedEvent(org.iobserve.analysis.deployment.data.PCMUndeployedEvent)

Example 5 with PCMUndeployedEvent

use of org.iobserve.analysis.deployment.data.PCMUndeployedEvent in project iobserve-analysis by research-iobserve.

the class UndeployPCMMapper method ejbMapper.

private void ejbMapper(final EJBUndeployedEvent event) {
    final String service = event.getService();
    final String context = event.getContext();
    final Correspondent correspondent = this.correspondence.getCorrespondent(context).get();
    if (this.correspondence.getCorrespondent(context) != null) {
        this.outputPort.send(new PCMUndeployedEvent(service, correspondent));
    } else {
        UndeployPCMMapper.LOGGER.info("No correspondent found for {}.", service);
    }
}
Also used : Correspondent(org.iobserve.model.correspondence.Correspondent) PCMUndeployedEvent(org.iobserve.analysis.deployment.data.PCMUndeployedEvent)

Aggregations

PCMUndeployedEvent (org.iobserve.analysis.deployment.data.PCMUndeployedEvent)7 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)3 URL (java.net.URL)2 PCMDeployedEvent (org.iobserve.analysis.deployment.data.PCMDeployedEvent)2 Correspondent (org.iobserve.model.correspondence.Correspondent)2 Before (org.junit.Before)2 UndeploymentVisualizationStage (org.iobserve.analysis.service.updater.UndeploymentVisualizationStage)1 AssemblyEntry (org.iobserve.model.correspondence.AssemblyEntry)1 Warnings (org.iobserve.stages.data.Warnings)1 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)1