Search in sources :

Example 36 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.

the class HostComponentAllocationGraphFactory method createEdges.

private void createEdges(final Map<String, ComponentNode> components, final ModelGraphRevision revision) {
    for (final AssemblyConnector acp : this.assemblyConnectors.values()) {
        final String provACID = acp.getProvidingAssemblyContext_AssemblyConnector().getId();
        final String reqACID = acp.getRequiringAssemblyContext_AssemblyConnector().getId();
        ComponentNode provNode;
        ComponentNode reqNode;
        for (final AllocationContext provAlloc : this.assCtxt2AllocCtxts.get(provACID)) {
            provNode = components.get(provAlloc.getId());
            for (final AllocationContext reqAlloc : this.assCtxt2AllocCtxts.get(reqACID)) {
                reqNode = components.get(reqAlloc.getId());
                final ComponentEdge edge;
                if (acp instanceof AssemblyConnectorPrivacy) {
                    edge = new ComponentEdge(acp.getId(), acp.getEntityName(), provNode, reqNode, ((AssemblyConnectorPrivacy) acp).getPrivacyLevel(), revision);
                } else {
                    edge = new ComponentEdge(acp.getId(), acp.getEntityName(), provNode, reqNode, null, revision);
                }
                provNode.addCommunicationEdge(edge);
                reqNode.addCommunicationEdge(edge);
            }
        }
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AssemblyConnectorPrivacy(org.palladiosimulator.pcm.compositionprivacy.AssemblyConnectorPrivacy) AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector)

Example 37 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.

the class DebugHelper method listAllocations.

/**
 * List all {@link AllocationContext}s of an {@link Allocation} model.
 *
 * @param caller
 *            caller class
 * @param label
 *            prefix label
 * @param allocation
 *            allocation model
 */
public static void listAllocations(final Class<?> caller, final String label, final Allocation allocation) {
    int i = 1;
    for (final AllocationContext context : allocation.getAllocationContexts_Allocation()) {
        DebugHelper.LOGGER.debug(String.format("%s %s %d %s %s", caller, label, i, context.getEntityName(), context.getAssemblyContext_AllocationContext()));
        i++;
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext)

Example 38 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.

the class DeploymentModelUpdaterTest method testExecutePCMDeployedEvent.

/**
 * Test method for
 * {@link org.iobserve.analysis.deployment.DeploymentModelUpdater#execute(org.iobserve.analysis.deployment.data.PCMDeployedEvent)}.
 *
 * @throws DBException
 */
@Test
public void testExecutePCMDeployedEvent() throws DBException {
    java.lang.System.err.println("AAAAAAAAAAAAAAAAAAAAAAa");
    this.initializationDatabase();
    java.lang.System.err.println("q alloc");
    final Allocation initDbAllocation = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    java.lang.System.err.println("deployer filter");
    final DeploymentModelUpdater deploymentModelUpdater = new DeploymentModelUpdater(this.correspondenceResource, this.allocationResource);
    /**
     * input deployment event
     */
    final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
    final PCMDeployedEvent deploymentEvent = ModelLevelDataFactory.createPCMDeployedEvent(ISOCountryCode.EVIL_EMPIRE, assemblyContext);
    deploymentEvent.setResourceContainer(ResourceEnvironmentDataFactory.findContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.QUERY_CONTAINER_3));
    final List<PCMDeployedEvent> inputEvents = new ArrayList<>();
    inputEvents.add(deploymentEvent);
    StageTester.test(deploymentModelUpdater).and().send(inputEvents).to(deploymentModelUpdater.getInputPort()).start();
    Assert.assertThat(deploymentModelUpdater.getDeployedNotifyOutputPort(), StageTester.produces(deploymentEvent));
    // TODO check is DB contains a deployment
    final Allocation dbAllocation = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    for (final AllocationContext context : dbAllocation.getAllocationContexts_Allocation()) {
        Assert.assertNotEquals("No assembly context for " + context.getEntityName(), context.getAssemblyContext_AllocationContext(), null);
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) DeploymentModelUpdater(org.iobserve.analysis.deployment.DeploymentModelUpdater) Allocation(org.palladiosimulator.pcm.allocation.Allocation) PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) ArrayList(java.util.ArrayList) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) Test(org.junit.Test)

Example 39 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.

the class DeploymentModelUpdater method execute.

/**
 * Execute an deployment event.
 *
 * @param event
 *            one deployment event to be processed
 * @throws NodeLookupException
 *             node lookup failed
 * @throws DBException
 *             on db error
 * @throws InvocationException
 *             on invocation errors
 */
@Override
protected void execute(final PCMDeployedEvent event) throws NodeLookupException, InvocationException, DBException {
    DeploymentLock.lock();
    ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.DEPLOYMENT, ObservationPoint.MODEL_UPDATE_ENTRY);
    this.logger.debug("Send event from {}", this.getInputPort().getPipe().getSourcePort().getOwningStage().getId());
    this.logger.debug("Deployment model update: assemblyContext={} resourceContainer={} service={}", event.getAssemblyContext(), event.getResourceContainer(), event.getService());
    final String allocationContextName = NameFactory.createAllocationContextName(event.getAssemblyContext(), event.getResourceContainer());
    final List<AllocationContext> allocationContext = this.allocationModelResource.findObjectsByTypeAndProperty(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT, "entityName", allocationContextName);
    if (allocationContext.isEmpty()) {
        this.logger.debug("Create allocation context (deploy) {}", event);
        final Allocation allocationModel = this.allocationModelResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
        final AllocationContext newAllocationContext = AllocationFactory.eINSTANCE.createAllocationContext();
        newAllocationContext.setEntityName(allocationContextName);
        newAllocationContext.setAssemblyContext_AllocationContext(event.getAssemblyContext());
        newAllocationContext.setResourceContainer_AllocationContext(event.getResourceContainer());
        allocationModel.getAllocationContexts_Allocation().add(newAllocationContext);
        this.allocationModelResource.updatePartition(allocationModel);
        final AllocationContext storedAllocationContext = this.allocationModelResource.resolve(newAllocationContext);
        /**
         * create correspondence model entry.
         */
        final CorrespondenceModel correspondenceModel = this.correspondenceModelResource.getModelRootNode(CorrespondenceModel.class, CorrespondencePackage.Literals.CORRESPONDENCE_MODEL);
        final Part part = this.findOrCreate(correspondenceModel, allocationModel);
        final AllocationEntry entry = CorrespondenceFactory.eINSTANCE.createAllocationEntry();
        entry.setAllocation(storedAllocationContext);
        entry.setTechnology(event.getTechnology());
        entry.setImplementationId(event.getUrl());
        part.getEntries().add(entry);
        this.correspondenceModelResource.updatePartition(correspondenceModel);
        this.logger.debug("PUSHED CORRESPONDENCE {} {} {}", newAllocationContext.getEntityName(), event.getTechnology().getLiteral(), event.getUrl());
    } else {
        this.logger.error("Deployment failed: Allocation Context {} already exists in allocation model.", allocationContextName);
    }
    // signal deployment update
    ExperimentLoggingUtils.logEvent(event.getTimestamp(), EventTypes.DEPLOYMENT, ObservationPoint.MODEL_UPDATE_EXIT);
    DeploymentLock.unlock();
    this.deployedNotifyOutputPort.send(event);
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AllocationEntry(org.iobserve.model.correspondence.AllocationEntry) Allocation(org.palladiosimulator.pcm.allocation.Allocation) Part(org.iobserve.model.correspondence.Part) CorrespondenceModel(org.iobserve.model.correspondence.CorrespondenceModel)

Example 40 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext in project iobserve-analysis by research-iobserve.

the class ProbeMapper method createMethodsToUpdate.

private void createMethodsToUpdate(final ProbeManagementData element) throws ControlEventCreationFailedException, InvocationException, DBException {
    final Map<AllocationContext, Set<OperationSignature>> methodsToUpdate = element.getMethodsToUpdate();
    if (methodsToUpdate != null && element.getWhitelist() != null) {
        for (final AllocationContext allocation : methodsToUpdate.keySet()) {
            this.logger.debug("AllocationContext to update {}", allocation.getEntityName());
            for (final OperationSignature operationSignature : methodsToUpdate.get(allocation)) {
                try {
                    final String pattern = this.computeAllocationComponentIdentifierPattern(allocation, operationSignature);
                    this.logger.debug("AllocationContext update operation {} -- {}", operationSignature.getEntityName(), pattern);
                    final Map<String, List<String>> parameters = new HashMap<>();
                    parameters.put("whitelist", element.getWhitelist());
                    final TcpUpdateParameterEvent currentEvent = new TcpUpdateParameterEvent(pattern, element.getTriggerTime(), parameters);
                    this.fillTcpControlEvent(currentEvent, allocation);
                    this.outputPort.send(currentEvent);
                } catch (final ControlEventCreationFailedException e) {
                    this.logger.error("Could not construct activation event for: {} {}", operationSignature.toString(), e.getLocalizedMessage());
                }
            }
        }
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) TcpUpdateParameterEvent(org.iobserve.utility.tcp.events.TcpUpdateParameterEvent) Set(java.util.Set) OperationSignature(org.palladiosimulator.pcm.repository.OperationSignature) HashMap(java.util.HashMap) EList(org.eclipse.emf.common.util.EList) List(java.util.List) ControlEventCreationFailedException(org.iobserve.service.privacy.violation.exceptions.ControlEventCreationFailedException)

Aggregations

AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)48 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)16 Set (java.util.Set)11 OperationSignature (org.palladiosimulator.pcm.repository.OperationSignature)11 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)11 HashSet (java.util.HashSet)10 HashMap (java.util.HashMap)9 Allocation (org.palladiosimulator.pcm.allocation.Allocation)9 Test (org.junit.Test)7 LinkedHashSet (java.util.LinkedHashSet)4 ProbeManagementData (org.iobserve.service.privacy.violation.data.ProbeManagementData)4 Edge (org.iobserve.service.privacy.violation.transformation.analysisgraph.Edge)4 DBException (org.iobserve.model.persistence.DBException)3 InvocationException (org.iobserve.model.persistence.neo4j.InvocationException)3 ControlEventCreationFailedException (org.iobserve.service.privacy.violation.exceptions.ControlEventCreationFailedException)3 Vertex (org.iobserve.service.privacy.violation.transformation.analysisgraph.Vertex)3 RepositoryComponent (org.palladiosimulator.pcm.repository.RepositoryComponent)3 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)3 LinkedList (java.util.LinkedList)2 AllocationEntry (org.iobserve.model.correspondence.AllocationEntry)2