use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class DeallocationStage method execute.
@Override
protected void execute(final IDeallocationEvent event) throws Exception {
final URL url;
if (event instanceof ContainerAllocationEvent) {
url = new URL(((ContainerAllocationEvent) event).getUrl());
} else {
throw new UnknownObjectException(event.getClass() + " is not supported by the allocation filter.");
}
final String hostName = url.getHost();
final Optional<ResourceContainer> resourceContainer = ResourceEnvironmentModelFactory.getResourceContainerByName(this.resourceEnvironmentModelProvider.readOnlyRootComponent(ResourceEnvironment.class), hostName);
if (resourceContainer.isPresent()) {
/**
* new provider: update the resource environment graph.
*/
final ResourceEnvironment resourceEnvironmentModelGraph = this.resourceEnvironmentModelProvider.readOnlyRootComponent(ResourceEnvironment.class);
resourceEnvironmentModelGraph.getResourceContainer_ResourceEnvironment().remove(resourceContainer.get());
this.resourceEnvironmentModelProvider.updateComponent(ResourceEnvironment.class, resourceEnvironmentModelGraph);
/**
* signal allocation update.
*/
this.deallocationNotifyOutputPort.send(resourceContainer.get());
this.deallocationOutputPort.send(event);
} else {
/**
* error deallocation already happened.
*/
this.logger.error("ResourceContainer %s is missing." + hostName);
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer 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.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentModelProviderTest method createThenUpdateThenReadUpdated.
@Override
@Test
public void createThenUpdateThenReadUpdated() {
final ModelProvider<ResourceEnvironment> modelProvider = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
final TestModelBuilder testModelBuilder = new TestModelBuilder();
final ResourceEnvironment writtenModel = testModelBuilder.getResourceEnvironment();
final ResourceContainer orderServer = testModelBuilder.getOrderServer();
final LinkingResource writtenLan1 = testModelBuilder.getLan1();
final ResourceEnvironment readModel;
modelProvider.createComponent(writtenModel);
// Update the model by replacing the orderServer by two separated servers
writtenModel.getResourceContainer_ResourceEnvironment().remove(orderServer);
writtenLan1.getConnectedResourceContainers_LinkingResource().remove(orderServer);
final ResourceContainer businessOrderServer = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
final ProcessingResourceSpecification businessOrderServerSpecification = ResourceenvironmentFactory.eINSTANCE.createProcessingResourceSpecification();
final ProcessingResourceType businessOrderServerType = ResourcetypeFactory.eINSTANCE.createProcessingResourceType();
businessOrderServer.setEntityName("businessOrderServer");
businessOrderServer.setResourceEnvironment_ResourceContainer(writtenModel);
businessOrderServer.getActiveResourceSpecifications_ResourceContainer().add(businessOrderServerSpecification);
businessOrderServerSpecification.setActiveResourceType_ActiveResourceSpecification(businessOrderServerType);
businessOrderServerType.setEntityName("Cisco Business Server PRO");
final ResourceContainer privateOrderServer = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
final ProcessingResourceSpecification privateOrderServerSpecification = ResourceenvironmentFactory.eINSTANCE.createProcessingResourceSpecification();
final ProcessingResourceType privateOrderServerType = ResourcetypeFactory.eINSTANCE.createProcessingResourceType();
privateOrderServer.setEntityName("privateOrderServer");
privateOrderServer.setResourceEnvironment_ResourceContainer(writtenModel);
privateOrderServer.getActiveResourceSpecifications_ResourceContainer().add(privateOrderServerSpecification);
privateOrderServerSpecification.setActiveResourceType_ActiveResourceSpecification(privateOrderServerType);
privateOrderServerType.setEntityName("Lenovo High Load Server PRO");
writtenModel.getResourceContainer_ResourceEnvironment().add(businessOrderServer);
writtenModel.getResourceContainer_ResourceEnvironment().add(privateOrderServer);
writtenLan1.getConnectedResourceContainers_LinkingResource().add(businessOrderServer);
writtenLan1.getConnectedResourceContainers_LinkingResource().add(privateOrderServer);
modelProvider.updateComponent(ResourceEnvironment.class, writtenModel);
readModel = modelProvider.readOnlyRootComponent(ResourceEnvironment.class);
Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentModelProviderTest method createThenDeleteComponent.
@Override
@Test
public void createThenDeleteComponent() {
final ModelProvider<ResourceEnvironment> modelProvider = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
final ResourceEnvironment writtenModel = new TestModelBuilder().getResourceEnvironment();
modelProvider.createComponent(writtenModel);
Assert.assertFalse(IModelProviderTest.isGraphEmpty(modelProvider));
for (final LinkingResource lr : writtenModel.getLinkingResources__ResourceEnvironment()) {
new ModelProvider<LinkingResource>(ResourceEnvironmentModelProviderTest.graph).deleteComponent(LinkingResource.class, lr.getId());
}
for (final ResourceContainer rc : writtenModel.getResourceContainer_ResourceEnvironment()) {
new ModelProvider<ResourceContainer>(ResourceEnvironmentModelProviderTest.graph).deleteComponent(ResourceContainer.class, rc.getId());
}
// no containments anywhere)
try (Transaction tx = ResourceEnvironmentModelProviderTest.graph.getGraphDatabaseService().beginTx()) {
ResourceEnvironmentModelProviderTest.graph.getGraphDatabaseService().execute("MATCH (m:ResourceEnvironment), (n:ProcessingResourceType), (o:CommunicationLinkResourceType) DELETE n, m, o");
tx.success();
}
Assert.assertTrue(IModelProviderTest.isGraphEmpty(modelProvider));
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer 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);
}
}
Aggregations