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