use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentModelProviderTest method createThenDeleteObject.
/**
* Test whether deletions work correctly.
*
* @throws DBException
*/
@Override
@Test
public void createThenDeleteObject() throws DBException {
final Neo4JModelResource<ResourceEnvironment> resource = ModelProviderTestUtils.prepareResource("createThenDeleteObject", this.prefix, this.ePackage);
resource.storeModelPartition(this.testModel);
Assert.assertFalse(ModelProviderTestUtils.isResourceEmpty(resource));
for (final LinkingResource lr : this.testModel.getLinkingResources__ResourceEnvironment()) {
resource.deleteObject(lr);
}
for (final ResourceContainer rc : this.testModel.getResourceContainer_ResourceEnvironment()) {
resource.deleteObject(rc);
}
// no containments anywhere)
try (Transaction tx = resource.getGraphDatabaseService().beginTx()) {
resource.getGraphDatabaseService().execute("MATCH (m:`" + ModelProviderTestUtils.removePrefix(ResourceEnvironment.class.getCanonicalName()) + "`), (n:`" + ModelProviderTestUtils.removePrefix(ProcessingResourceType.class.getCanonicalName()) + "`), (o:`" + ModelProviderTestUtils.removePrefix(CommunicationLinkResourceType.class.getCanonicalName()) + "`) DELETE n, m, o");
tx.success();
}
Assert.assertTrue(ModelProviderTestUtils.isResourceEmpty(resource));
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentDataFactory method createResourceEnvironment.
/**
* Create a new resource environment model.
*
* @return returns the model.
*/
public static ResourceEnvironment createResourceEnvironment() {
final ResourceEnvironment resourceEnvironment = ResourceenvironmentFactory.eINSTANCE.createResourceEnvironment();
resourceEnvironment.setEntityName("defaultResourceEnvironment");
// Resource container types
final ProcessingResourceType client1Type = ResourceEnvironmentDataFactory.createProcessionResourceType("MacBook");
final ProcessingResourceType client2Type = ResourceEnvironmentDataFactory.createProcessionResourceType("ThinkPad");
final ProcessingResourceType client3Type = ResourceEnvironmentDataFactory.createProcessionResourceType("Mainframe");
final ProcessingResourceType orderServerType = ResourceEnvironmentDataFactory.createProcessionResourceType("Cisco Business Server");
final ProcessingResourceType paymentServerType = ResourceEnvironmentDataFactory.createProcessionResourceType("Lenovo Security Server");
// Processing resource specifications
final ProcessingResourceSpecification client1Specification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(client1Type);
final ProcessingResourceSpecification client2Specification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(client2Type);
final ProcessingResourceSpecification client3Specification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(client3Type);
final ProcessingResourceSpecification businessOrderServerSpecification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(orderServerType);
final ProcessingResourceSpecification privateOrderServerSpecification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(orderServerType);
final ProcessingResourceSpecification paymentServerSpecification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(paymentServerType);
// Resource container
final ResourceContainer client1 = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.QUERY_CONTAINER_1, client1Specification);
final ResourceContainer client2 = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.QUERY_CONTAINER_2, client2Specification);
final ResourceContainer client3 = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.QUERY_CONTAINER_3, client3Specification);
final ResourceContainer businessOrderServer = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.BUSINESS_ORDER_CONTAINER, businessOrderServerSpecification);
final ResourceContainer privateOrderServer = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.PRIVATE_ORDER_CONTAINER, privateOrderServerSpecification);
final ResourceContainer paymentServer = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.PAYMENT_CONTAINER, paymentServerSpecification);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(client1);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(client2);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(client3);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(businessOrderServer);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(privateOrderServer);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(paymentServer);
// linking
// Linking resource type
final CommunicationLinkResourceType lan1Type = ResourcetypeFactory.eINSTANCE.createCommunicationLinkResourceType();
lan1Type.setEntityName("Cat.7 LAN");
// Linking resource specification
final CommunicationLinkResourceSpecification lan1Specification = ResourceenvironmentFactory.eINSTANCE.createCommunicationLinkResourceSpecification();
lan1Specification.setCommunicationLinkResourceType_CommunicationLinkResourceSpecification(lan1Type);
lan1Specification.setFailureProbability(0.01);
// linking resource
final LinkingResource lan1 = ResourceenvironmentFactory.eINSTANCE.createLinkingResource();
// Linking resource
lan1.setEntityName(ResourceEnvironmentDataFactory.LAN_1);
lan1.setResourceEnvironment_LinkingResource(resourceEnvironment);
lan1.setCommunicationLinkResourceSpecifications_LinkingResource(lan1Specification);
lan1.getConnectedResourceContainers_LinkingResource().add(businessOrderServer);
lan1.getConnectedResourceContainers_LinkingResource().add(paymentServer);
resourceEnvironment.getLinkingResources__ResourceEnvironment().add(lan1);
return resourceEnvironment;
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ModelHelper method getResourceContainerFromHostname.
/**
* Creates a cloud container from the given hostname with the information provided by the model
* providers in the resource environment provided by the model providers.
*
* If the hostname is not a valid cloud container hostname or if no matching VMType could be
* found, the method returns null.
*
* @param modelProviders
* the model providers to use
* @param hostname
* the hostname to convert
* @return the new cloud container or null in case of a problem
* @throws ModelHandlingErrorException
* model handling error
*/
public static ResourceContainerCloud getResourceContainerFromHostname(final ModelImporter modelProviders, final String hostname) throws ModelHandlingErrorException {
final String[] nameParts = hostname.split("_");
VMType vmType = null;
// ContainerId_AllocationGroupName_ProviderName_Location_InstanceType
if (nameParts.length == 5) {
final String groupName = nameParts[1];
final String providerName = nameParts[2];
final String location = nameParts[3];
final String instanceType = nameParts[4];
vmType = ModelHelper.getVMType(modelProviders.getCloudProfileModel(), providerName, location, instanceType);
if (vmType != null) {
final ResourceEnvironment environment = modelProviders.getResourceEnvironmentModel();
final CostRepository costRepository = modelProviders.getCostModel();
final ResourceContainerCloud cloudContainer = ModelHelper.createResourceContainerFromVMType(environment, costRepository, vmType, hostname);
cloudContainer.setGroupName(groupName);
return cloudContainer;
}
}
return null;
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ModelHelper method fillResourceEnvironmentFromCloudProfile.
/**
* Creates resource containers and their associated costs from the cloud profile given in the
* model provider.
*
* The created resource containers are of the type {@link ResourceContainerCloud} and are
* connected via an Internet linking resource
* ({@link #getInternetLinkingResource(ResourceEnvironment)}. For every vm type in the cloud
* profile, this method creates one resource container representing an instance of this specific
* vm type. The model is saved after the creation of containers is completed.
*
* @param writeURI
* location where all files are stored
* @param modelHandler
* the model providers with an initialized resource environment, cost model and cloud
* profile
* @throws ModelHandlingErrorException
* model handling error
*/
public static void fillResourceEnvironmentFromCloudProfile(final org.eclipse.emf.common.util.URI writeURI, final ModelImporter modelHandler) throws ModelHandlingErrorException {
final ResourceEnvironment environment = modelHandler.getResourceEnvironmentModel();
final CloudProfile cloudProfileModel = modelHandler.getCloudProfileModel();
final CostRepository costRepositoryModel = modelHandler.getCostModel();
for (final CloudProvider provider : cloudProfileModel.getCloudProviders()) {
for (final CloudResourceType cloudResource : provider.getCloudResources()) {
if (cloudResource instanceof VMType) {
final VMType cloudVM = (VMType) cloudResource;
ModelHelper.createResourceContainerFromVMType(environment, costRepositoryModel, cloudVM, cloudVM.getName());
}
}
}
new FileModelHandler<ResourceEnvironment>(modelHandler.getResourceSet(), ResourceenvironmentPackage.eINSTANCE).save(writeURI.appendFileExtension(ResourceenvironmentPackage.eNAME), environment);
new FileModelHandler<CostRepository>(modelHandler.getResourceSet(), costPackage.eINSTANCE).save(writeURI.appendFileExtension(costPackage.eNAME), costRepositoryModel);
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class PrivacyViolationDetectionServiceMain method createTeetimeConfiguration.
@Override
protected PipelineConfiguration createTeetimeConfiguration() throws ConfigurationException {
/**
* load models.
*/
try {
final ModelImporter modelHandler = new ModelImporter(this.parameterConfiguration.getModelInitDirectory());
/**
* initialize database.
*/
final IModelResource<CorrespondenceModel> correspondenceModelResource = this.loadResourceAndInitDB(CorrespondencePackage.eINSTANCE, modelHandler.getCorrespondenceModel());
final IModelResource<Repository> repositoryModelResource = this.loadResourceAndInitDB(RepositoryPackage.eINSTANCE, modelHandler.getRepositoryModel());
final IModelResource<ResourceEnvironment> resourceEnvironmentModelResource = this.loadResourceAndInitDB(ResourceenvironmentPackage.eINSTANCE, modelHandler.getResourceEnvironmentModel());
final IModelResource<System> systemModelResource = this.loadResourceAndInitDB(SystemPackage.eINSTANCE, modelHandler.getSystemModel());
final IModelResource<Allocation> allocationModelResource = this.loadResourceAndInitDB(AllocationPackage.eINSTANCE, modelHandler.getAllocationModel());
final IModelResource<DataProtectionModel> privacyModelResource = this.loadResourceAndInitDB(PrivacyPackage.eINSTANCE, modelHandler.getPrivacyModel());
return new PipelineConfiguration(this.kiekerConfiguration, correspondenceModelResource, repositoryModelResource, resourceEnvironmentModelResource, systemModelResource, allocationModelResource, privacyModelResource, this.parameterConfiguration.getWarningFile(), this.parameterConfiguration.getAlarmsFile(), this.parameterConfiguration.getModelDumpDirectory());
} catch (final DBException | IOException e) {
throw new ConfigurationException(e);
}
}
Aggregations