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