use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class UndeploymentVisualizationStage method createData.
/**
** Collects information for deleting a service instance element in the visualization.
*
* @param undeployment
* servlet undeployed event
* @return array that contains a changelog for deleting a service instance
* @throws DBException
*/
private JsonArray createData(final PCMUndeployedEvent undeployment) throws DBException {
final String serverName = undeployment.getService();
final String nodeId = this.resourceEnvironmentModelResource.findObjectsByTypeAndProperty(ResourceContainer.class, ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER, "entityName", serverName).get(0).getId();
final String asmContextName = undeployment.getResourceContainer().getEntityName() + "_" + serverName;
final AssemblyContext assemblyContext = this.systemModelGraphProvider.findObjectsByTypeAndProperty(AssemblyContext.class, CompositionPackage.Literals.ASSEMBLY_CONTEXT, "entityName", asmContextName).get(0);
final JsonObject serviceInstanceObject = ChangelogHelper.delete(this.serviceInstanceService.deleteServiceInstance(assemblyContext, this.systemId, nodeId, this.systemModelGraphProvider));
return Json.createArrayBuilder().add(serviceInstanceObject).build();
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class HostComponentAllocationGraphFactory method extractAllocations.
private void extractAllocations(final Allocation allocationModel) {
final EList<AllocationContext> allocContexts = allocationModel.getAllocationContexts_Allocation();
for (final AllocationContext allocationContext : allocContexts) {
final AssemblyContext assemblyContext = allocationContext.getAssemblyContext_AllocationContext();
final Set<String> acs = new HashSet<>();
this.allocationContexts.put(allocationContext.getId(), allocationContext);
acs.add(allocationContext.getId());
if (HostComponentAllocationGraphFactory.LOGGER.isDebugEnabled()) {
HostComponentAllocationGraphFactory.LOGGER.debug("Individual Allocation Contexts found in Allocation Model: " + acs.size());
}
final String assemblyContextID = assemblyContext.getId();
if (!this.assemblyContexts.containsKey(assemblyContextID)) {
if (HostComponentAllocationGraphFactory.LOGGER.isErrorEnabled()) {
HostComponentAllocationGraphFactory.LOGGER.error("An unknown AssemblyContext (ID: " + assemblyContext.getId() + ") was found during allocation context analysis.\n");
}
} else {
final Set<AllocationContext> allocCtxts;
if (this.assCtxt2AllocCtxts.containsKey(assemblyContextID)) {
allocCtxts = this.assCtxt2AllocCtxts.get(assemblyContextID);
} else {
allocCtxts = new HashSet<>();
}
allocCtxts.add(allocationContext);
this.assCtxt2AllocCtxts.put(assemblyContextID, allocCtxts);
}
}
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class HostComponentAllocationGraphFactory method updatePrivacyLvl.
private void updatePrivacyLvl(final AssemblyConnectorPrivacy acp, final DataPrivacyLvl assemblyConnectorPrivacyLvl, final String assemblyContextID) {
// Check whether the AssemblyContext was found while extracting
final AssemblyContext assemblyContext = this.assemblyContexts.get(assemblyContextID);
if (assemblyContext == null) {
if (HostComponentAllocationGraphFactory.LOGGER.isErrorEnabled()) {
HostComponentAllocationGraphFactory.LOGGER.error("The provided AssemblyContext (ID: " + assemblyContextID + ") form the AssemblyConnectorPrivacy (ID:" + acp.getId() + ") " + "was not found during the AssemblyContextExtraction");
}
this.assemblyContexts.put(assemblyContextID, acp.getProvidingAssemblyContext_AssemblyConnector());
}
// Do the actual job and update the privacy lvl
DataPrivacyLvl currentDataLevelPrivacy = this.assemblyContextPrivacyLvl.get(assemblyContextID);
if (currentDataLevelPrivacy != null) {
currentDataLevelPrivacy = DataPrivacyLvl.get(Math.min(assemblyConnectorPrivacyLvl.getValue(), currentDataLevelPrivacy.getValue()));
} else {
currentDataLevelPrivacy = assemblyConnectorPrivacyLvl;
}
this.assemblyContextPrivacyLvl.put(assemblyContextID, currentDataLevelPrivacy);
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class DeploymentVisualizationStageTest method setUp.
/**
* Initialize test data and stub necessary method calls.
*
* @throws MalformedURLException
* if the creation of the URL fails.
* @throws DBException
*/
@Before
public void setUp() throws MalformedURLException, DBException {
final URL changelogURL = new URL("http://" + DeploymentVisualizationStageTest.OUTPUT_HOSTNAME + ":" + DeploymentVisualizationStageTest.OUTPUT_PORT + "/v1/systems/" + DeploymentVisualizationStageTest.SYSTEM_ID + "/changelogs");
/**
* test resource container
*/
final ResourceContainer testResourceContainer = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
testResourceContainer.setId(DeploymentVisualizationStageTest.TEST_NODE_ID);
this.testResourceContainers.add(testResourceContainer);
/**
* test events
*/
final String urlContext = DeploymentVisualizationStageTest.CONTEXT.replaceAll("\\.", "/");
final String url = "http://" + DeploymentVisualizationStageTest.SERVICE + '/' + urlContext;
final PCMDeployedEvent deployedEvent = new PCMDeployedEvent(EServiceTechnology.SERVLET, DeploymentVisualizationStageTest.SERVICE, null, url, ISOCountryCode.EVIL_EMPIRE, 0);
deployedEvent.setResourceContainer(testResourceContainer);
/**
* input events
*/
this.inputEvents.add(deployedEvent);
/**
* test assembly context
*/
final String asmContextName = "AssemblyContextDataFactory.ASSEMBLY_CONTEXT.getEntityName()" + " : " + DeploymentVisualizationStageTest.SERVICE;
final AssemblyContext testAssemblyContext = CompositionFactory.eINSTANCE.createAssemblyContext();
testAssemblyContext.setId(DeploymentVisualizationStageTest.SYSTEM_ID);
testAssemblyContext.setEntityName(asmContextName);
this.testAssemblyContexts.add(testAssemblyContext);
// stubbing
Mockito.when(this.mockedResourceContainerModelProvider.findObjectsByTypeAndProperty(ResourceContainer.class, ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER, "entityName", DeploymentVisualizationStageTest.SERVICE)).thenReturn(this.testResourceContainers);
// does this make sense?
// Mockito.when(this.mockedCorrespondenceModel.getCorrespondent(DeploymentVisualizationStageTest.CONTEXT))
// .thenReturn(DeploymentVisualizationStageTest.optTestCorrespondent);
Mockito.when(this.mockedAllocationContextModelProvider.findObjectsByTypeAndProperty(AssemblyContext.class, CompositionPackage.Literals.ASSEMBLY_CONTEXT, "entityName", asmContextName)).thenReturn(this.testAssemblyContexts);
this.deploymentVisualizationStage = new DeploymentVisualizationStage(changelogURL, DeploymentVisualizationStageTest.SYSTEM_ID, this.mockedResourceContainerModelProvider, this.mockedAllocationContextModelProvider);
}
use of org.palladiosimulator.pcm.core.composition.AssemblyContext in project iobserve-analysis by research-iobserve.
the class SystemModelFactory method createAssemblyContextsIfAbsent.
/**
* Checks whether an assembly context with the provided name exists, and, in case it is missing,
* a new assembly context is created and added to the system model.
*
* @param system
* system model
* @param name
* name of the assembly context
*
* @return returns the new assembly context
*/
public static AssemblyContext createAssemblyContextsIfAbsent(final System system, final String name) {
final Optional<AssemblyContext> context = SystemModelFactory.getAssemblyContextByName(system, name);
if (!context.isPresent()) {
final AssemblyContext asmContext = CompositionFactory.eINSTANCE.createAssemblyContext();
asmContext.setEntityName(name);
system.getAssemblyContexts__ComposedStructure().add(asmContext);
return asmContext;
} else {
return context.get();
}
}
Aggregations