Search in sources :

Example 41 with AssemblyContext

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();
}
Also used : JsonObject(javax.json.JsonObject) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Example 42 with AssemblyContext

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);
        }
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) HashSet(java.util.HashSet)

Example 43 with AssemblyContext

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);
}
Also used : AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) DataPrivacyLvl(org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl)

Example 44 with AssemblyContext

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);
}
Also used : PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) DeploymentVisualizationStage(org.iobserve.analysis.service.updater.DeploymentVisualizationStage) URL(java.net.URL) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Before(org.junit.Before)

Example 45 with AssemblyContext

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();
    }
}
Also used : AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Aggregations

AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)64 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)16 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)11 ArrayList (java.util.ArrayList)9 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)9 AssemblyConnector (org.palladiosimulator.pcm.core.composition.AssemblyConnector)8 System (org.palladiosimulator.pcm.system.System)8 Test (org.junit.Test)7 Connector (org.palladiosimulator.pcm.core.composition.Connector)7 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)6 HashSet (java.util.HashSet)5 EObject (org.eclipse.emf.ecore.EObject)5 Allocation (org.palladiosimulator.pcm.allocation.Allocation)5 DataPrivacyLvl (org.palladiosimulator.pcm.compositionprivacy.DataPrivacyLvl)5 OperationRequiredRole (org.palladiosimulator.pcm.repository.OperationRequiredRole)5 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)5 HashMap (java.util.HashMap)4 AssemblyEntry (org.iobserve.model.correspondence.AssemblyEntry)4 RequiredRole (org.palladiosimulator.pcm.repository.RequiredRole)4 URL (java.net.URL)3