Search in sources :

Example 41 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment 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 42 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.

the class ResourceEnvironmentModelProviderTest method createThenReadRoot.

@Override
@Test
public void createThenReadRoot() {
    final ModelProvider<ResourceEnvironment> modelProvider = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
    final ResourceEnvironment writtenModel = new TestModelBuilder().getResourceEnvironment();
    final ResourceEnvironment readModel;
    modelProvider.createComponent(writtenModel);
    readModel = modelProvider.readOnlyRootComponent(ResourceEnvironment.class);
    Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) Test(org.junit.Test)

Example 43 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.

the class ModelTransformer method createResourcesAndReplicationDegrees.

private void createResourcesAndReplicationDegrees(final AllocationGroup allocationGroup) throws ModelHandlingErrorException {
    final CloudProfile profile = this.cloudProfileModel;
    final ResourceEnvironment environment = this.resourceEnvironmentModel;
    final CostRepository costs = this.costModel;
    // Get resource container that represents the instances this allocation
    // group is currently deployed on
    final ResourceContainerCloud representingContainer = allocationGroup.getRepresentingResourceContainer();
    if (representingContainer == null) {
        throw new IllegalArgumentException(String.format("Could not find a cloud container for allocation group '%s'. Check your model.", allocationGroup.getName()));
    }
    // Set group name of the representing container and add it to the
    // resource environment
    representingContainer.setGroupName(allocationGroup.getName());
    representingContainer.setEntityName(allocationGroup.getName());
    ModelHelper.addResourceContainerToEnvironment(environment, representingContainer);
    final int nrOfCurrentReplicas = allocationGroup.getAllocationContexts().size();
    // Upper bound for number of replicas for one resource
    // container type should be sufficiently high
    final int toNrOfReplicas = (nrOfCurrentReplicas + PlanningData.POSSIBLE_REPLICAS_OFFSET) * PlanningData.POSSIBLE_REPLICAS_FACTOR;
    // representing container create only replication degree
    for (final CloudProvider provider : profile.getCloudProviders()) {
        for (final CloudResourceType cloudResource : provider.getCloudResources()) {
            if (cloudResource instanceof VMType) {
                final VMType cloudVM = (VMType) cloudResource;
                final String degreeName;
                final ResourceContainerCloud createdContainer;
                if (this.isSameVMType(cloudVM, representingContainer)) {
                    createdContainer = representingContainer;
                    degreeName = String.format("%s_ReplicationDegree", allocationGroup.getName());
                } else {
                    final String containerName = AllocationGroup.getAllocationGroupName(allocationGroup.getComponentName(), ModelHelper.getResourceContainerIdentifier(cloudVM));
                    createdContainer = ModelHelper.createResourceContainerFromVMType(environment, costs, cloudVM, containerName);
                    degreeName = String.format("%s_ReplicationDegree", containerName);
                }
                DesignDecisionModelFactory.createReplicationDegree(this.decisionSpace, degreeName, createdContainer, 1, toNrOfReplicas);
            }
        }
    }
}
Also used : CloudProfile(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) CloudResourceType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType) ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType) CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository) CloudProvider(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)

Example 44 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.

the class AllocationResourceContainerTest method stubMocksResourceContainer.

/**
 * Define the test situation in which a {@link ContainerAllocationEvent} is defined as input and
 * the specified {@link ResourceContainer} does exist in the {@link ResourceEnvironment}.
 */
@SuppressWarnings("unchecked")
@Before
public void stubMocksResourceContainer() {
    /**
     * mock for ResourceEnvironmentModelBuilder
     */
    // use PowerMockito for calling static methods of this final class
    PowerMockito.mockStatic(ResourceEnvironmentModelFactory.class);
    /**
     * mock for new graph provider
     */
    AllocationResourceContainerTest.mockedResourceEnvironmentModelGraphProvider = Mockito.mock(ModelProvider.class);
    this.allocationStage = new AllocationStage(AllocationResourceContainerTest.mockedResourceEnvironmentModelGraphProvider);
    Mockito.when(AllocationResourceContainerTest.mockedResourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class)).thenReturn(ResourceEnvironmentDataFactory.RESOURCE_ENVIRONMENT);
    Mockito.when(ResourceEnvironmentModelFactory.getResourceContainerByName(AllocationResourceContainerTest.mockedResourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class), ImplementationLevelDataFactory.SERVICE)).thenReturn(Optional.of(ResourceEnvironmentDataFactory.RESOURCE_CONTAINER));
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ModelProvider(org.iobserve.model.provider.neo4j.ModelProvider) AllocationStage(org.iobserve.analysis.deployment.AllocationStage) Before(org.junit.Before)

Example 45 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project Palladio-Editors-Sirius by PalladioSimulator.

the class ResourceEnvironmentCreationWizard method init.

@Override
protected void init(IStructuredSelection selection) {
    String viewpointName = Activator.VIEWPOINT_NAME;
    viewpoint = Activator.getDefault().getViewpoint();
    String ext = Activator.getDefault().getViewpoint().getModelFileExtension();
    modelCreationPage = new ModelCreationPage(selection, viewpointName + " Creation Wizard", "new" + viewpointName, ext);
    representationDescription = Activator.getDefault().getRepresentationDescription();
    String defaultRepresentationName = "new " + Activator.REPRESENTATION_NAME;
    this.representationCreationPage.setDefaultRepresentationName(defaultRepresentationName);
    ResourceEnvironment obj = ResourceenvironmentFactory.eINSTANCE.createResourceEnvironment();
    obj.setEntityName("New ResourceEnvironment");
    modelObject = obj;
}
Also used : ModelCreationPage(org.palladiosimulator.editors.sirius.ui.wizard.model.ModelCreationPage) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)

Aggregations

ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)55 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)23 Test (org.junit.Test)15 CostRepository (de.uka.ipd.sdq.pcm.cost.CostRepository)12 Allocation (org.palladiosimulator.pcm.allocation.Allocation)12 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)12 VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)11 CloudProfile (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile)8 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)8 System (org.palladiosimulator.pcm.system.System)8 CloudProvider (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)7 CloudResourceType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType)7 EObject (org.eclipse.emf.ecore.EObject)6 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)6 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)6 IOException (java.io.IOException)5 URI (org.eclipse.emf.common.util.URI)5 PCMModelHandler (org.iobserve.model.PCMModelHandler)5 ResourceEnvironmentModelHandler (org.iobserve.model.provider.file.ResourceEnvironmentModelHandler)5 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)5