use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class PrivacyViolationDetectionServiceMain method createConfiguration.
@Override
protected PrivacyViolationDetectionConfiguration createConfiguration(final Configuration configuration) throws ConfigurationException {
/**
* load models.
*/
final PCMModelHandler modelHandler = new PCMModelHandler(this.pcmDirectory);
final GraphLoader graphLoader = new GraphLoader(this.modelDatabaseDirectory);
final Graph allocationModelGraph = graphLoader.initializeAllocationModelGraph(modelHandler.getAllocationModel());
final Graph resourceEnvironmentGraph = graphLoader.initializeResourceEnvironmentModelGraph(modelHandler.getResourceEnvironmentModel());
final Graph systemGraph = graphLoader.initializeSystemModelGraph(modelHandler.getSystemModel());
final ModelProvider<Allocation> allocationModelProvider = new ModelProvider<>(allocationModelGraph);
final ModelProvider<ResourceEnvironment> resourceEnvironmentModelProvider = new ModelProvider<>(resourceEnvironmentGraph);
final ModelProvider<System> systemModelProvider = new ModelProvider<>(systemGraph);
try {
return new PrivacyViolationDetectionConfiguration(this.inputPort, this.outputs, modelHandler.getCorrespondenceModel(), resourceEnvironmentModelProvider, allocationModelProvider, systemModelProvider, this.warningFile, this.alarmsFile);
} catch (final IOException e) {
throw new ConfigurationException(e);
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ModelGenerationFactory method createNewModel.
public static void createNewModel(final CommandLine commandLine) throws InitializationException, IOException {
ModelGenerationFactory.LOGGER.info("Creating new model!");
final URI repoLocation = URI.createFileURI(commandLine.getOptionValue("i"));
final URI outputLocation = URI.createFileURI(commandLine.getOptionValue("o"));
ModelGenerationFactory.LOGGER.info("Copying repository model to new location.");
final RepositoryModelHandler repoModelProvider = new RepositoryModelHandler();
repoModelProvider.load(repoLocation);
ModelGenerationFactory.copyRepoToOutput(outputLocation, repoModelProvider);
ModelGenerationFactory.LOGGER.info("Generating system model.");
final System systemModel = ModelGenerationFactory.generateAndSaveSystem(commandLine, outputLocation);
ModelGenerationFactory.LOGGER.info("Generating resource environment model.");
final ResourceEnvironment resEnvModel = ModelGenerationFactory.generateAndSaveResourceEnvironment(commandLine, outputLocation, systemModel.getEntityName());
ModelGenerationFactory.LOGGER.info("Generating allocation model.");
ModelGenerationFactory.generateAndSaveAllocation(outputLocation, systemModel, resEnvModel);
ModelGenerationFactory.LOGGER.info("Generating done!");
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment 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.ResourceEnvironment in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentModelProviderTest method createThenClearGraph.
@Override
@Test
public void createThenClearGraph() {
final ModelProvider<ResourceEnvironment> modelProvider = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
final ResourceEnvironment writtenModel = new TestModelBuilder().getResourceEnvironment();
modelProvider.createComponent(writtenModel);
Assert.assertFalse(IModelProviderTest.isGraphEmpty(modelProvider));
modelProvider.clearGraph();
Assert.assertTrue(IModelProviderTest.isGraphEmpty(modelProvider));
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment 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));
}
Aggregations