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