Search in sources :

Example 31 with AllocationContext

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

the class AllocationModelProviderTest method createThenReadContaining.

@Override
@Test
public void createThenReadContaining() {
    final ModelProvider<Allocation> modelProvider = new ModelProvider<>(AllocationModelProviderTest.graph);
    final Allocation writtenModel = new TestModelBuilder().getAllocation();
    final Allocation readModel;
    final AllocationContext writtenContext = writtenModel.getAllocationContexts_Allocation().get(0);
    modelProvider.createComponent(writtenModel);
    readModel = (Allocation) modelProvider.readOnlyContainingComponentById(AllocationContext.class, writtenContext.getId());
    Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Allocation(org.palladiosimulator.pcm.allocation.Allocation) Test(org.junit.Test)

Example 32 with AllocationContext

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

the class AllocationModelProviderTest method createThenUpdateThenReadUpdated.

@Override
@Test
public void createThenUpdateThenReadUpdated() {
    final ModelProvider<Allocation> modelProvider = new ModelProvider<>(AllocationModelProviderTest.graph);
    final TestModelBuilder testModelBuilder = new TestModelBuilder();
    final Allocation writtenModel = testModelBuilder.getAllocation();
    final AllocationContext businessOrderServerAllocationContext = testModelBuilder.getBusinessOrderServerAllocationContext();
    final AllocationContext privateOrderServerAllocationContext = testModelBuilder.getPrivateOrderServerAllocationContext();
    final Allocation readModel;
    modelProvider.createComponent(writtenModel);
    // Update the model by allocating new separate servers for business and private orders
    final ResourceEnvironment resourceEnvironment = testModelBuilder.getResourceEnvironment();
    final ResourceContainer businessOrderServer = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
    businessOrderServer.setEntityName("businessOrderServer");
    businessOrderServer.setResourceEnvironment_ResourceContainer(testModelBuilder.getResourceEnvironment());
    businessOrderServer.getActiveResourceSpecifications_ResourceContainer().add(testModelBuilder.getOrderServerSpecification());
    final ResourceContainer privateOrderServer = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
    privateOrderServer.setEntityName("privateOrderServer");
    privateOrderServer.setResourceEnvironment_ResourceContainer(testModelBuilder.getResourceEnvironment());
    privateOrderServer.getActiveResourceSpecifications_ResourceContainer().add(testModelBuilder.getOrderServerSpecification());
    resourceEnvironment.getResourceContainer_ResourceEnvironment().add(businessOrderServer);
    resourceEnvironment.getResourceContainer_ResourceEnvironment().add(privateOrderServer);
    businessOrderServerAllocationContext.setResourceContainer_AllocationContext(businessOrderServer);
    privateOrderServerAllocationContext.setResourceContainer_AllocationContext(privateOrderServer);
    modelProvider.updateComponent(Allocation.class, writtenModel);
    readModel = modelProvider.readOnlyRootComponent(Allocation.class);
    Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 33 with AllocationContext

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

the class ModelProcessing method rebuildEnvironment.

private void rebuildEnvironment() throws ModelHandlingErrorException {
    for (final AllocationGroup allocationGroup : this.originalAllocationGroups.getAllocationGroups()) {
        final AllocationContext representingContext = allocationGroup.getRepresentingContext();
        // Set assembly context from allocation group to the context from the processed model
        final AssemblyContext representedAsmCtx = this.systemModel.getAssemblyContexts__ComposedStructure().stream().filter(ctx -> representingContext.getAssemblyContext_AllocationContext().getId().equals(ctx.getId())).findFirst().orElse(null);
        if (representedAsmCtx == null) {
            throw new RuntimeException("There was something wrong with the system model. Please check your models.");
        }
        representingContext.setAssemblyContext_AllocationContext(representedAsmCtx);
        this.createResourcesAndReplicationDegrees(this.decisionModel, allocationGroup);
        this.allocationModel.getAllocationContexts_Allocation().add(representingContext);
    }
    for (final AllocationGroup allocationGroup : this.originalAllocationGroups.getAllocationGroups()) {
        final String allocationDegreeName = String.format("%s_AllocationDegree", allocationGroup.getName());
        DesignDecisionModelFactory.createAllocationDegree(this.decisionModel, allocationDegreeName, allocationGroup.getRepresentingContext(), this.resourceEnvironmentModel.getResourceContainer_ResourceEnvironment());
    }
    ModelHelper.addAllAllocationsToReplicationDegrees(this.allocationModel, this.decisionModel);
    this.saveModels();
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AllocationGroup(org.iobserve.planning.data.AllocationGroup) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext)

Example 34 with AllocationContext

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

the class AllocationGroupsContainer method initAllocationGroups.

private void initAllocationGroups() {
    for (final AllocationContext context : this.allocation.getAllocationContexts_Allocation()) {
        final String componentName = context.getAssemblyContext_AllocationContext().getEncapsulatedComponent__AssemblyContext().getEntityName();
        ComponentGroup componentGroup = this.componentNameToComponentGroupMap.get(componentName);
        if (componentGroup == null) {
            componentGroup = new ComponentGroup(componentName);
            this.componentNameToComponentGroupMap.put(componentName, componentGroup);
        }
        final ResourceContainer allocationContainer = context.getResourceContainer_AllocationContext();
        final String containerIdentifier = ModelHelper.getResourceContainerIdentifier(allocationContainer);
        final AllocationGroup addedGroup = componentGroup.addAllocationContext(containerIdentifier, context);
        this.allocationGroups.add(addedGroup);
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 35 with AllocationContext

use of org.palladiosimulator.pcm.allocation.AllocationContext 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)

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