Search in sources :

Example 31 with ResourceContainer

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);
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ContainerAllocationEvent(org.iobserve.common.record.ContainerAllocationEvent) UnknownObjectException(java.rmi.activation.UnknownObjectException) URL(java.net.URL) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 32 with ResourceContainer

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));
}
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 ResourceContainer

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));
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification) ProcessingResourceType(org.palladiosimulator.pcm.resourcetype.ProcessingResourceType) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 34 with ResourceContainer

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));
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) Transaction(org.neo4j.graphdb.Transaction) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 35 with ResourceContainer

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);
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Aggregations

ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)35 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)16 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)8 Test (org.junit.Test)7 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)7 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)6 ComputeService (org.jclouds.compute.ComputeService)5 Allocation (org.palladiosimulator.pcm.allocation.Allocation)5 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)5 URL (java.net.URL)3 ContainerAllocationEvent (org.iobserve.common.record.ContainerAllocationEvent)3 UnknownObjectException (java.rmi.activation.UnknownObjectException)2 ArrayList (java.util.ArrayList)2 SystemadaptationFactory (org.iobserve.planning.systemadaptation.SystemadaptationFactory)2 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)2 System (org.palladiosimulator.pcm.system.System)2 File (java.io.File)1 URI (org.eclipse.emf.common.util.URI)1 DDiagramElement (org.eclipse.sirius.diagram.DDiagramElement)1 DEdge (org.eclipse.sirius.diagram.DEdge)1