Search in sources :

Example 1 with ModelImporter

use of org.iobserve.model.ModelImporter in project iobserve-analysis by research-iobserve.

the class AnalysisMain method createTeetimeConfiguration.

@Override
protected AnalysisConfiguration createTeetimeConfiguration() throws ConfigurationException {
    /**
     * Configure model handling.
     */
    if (this.parameterConfiguration.isPcmFeature()) {
        try {
            final ModelImporter modelHandler = new ModelImporter(this.parameterConfiguration.getModelInitDirectory());
            /**
             * initialize neo4j graphs.
             */
            final Neo4JModelResource<CorrespondenceModel> correspondenceModelResource = new Neo4JModelResource<>(CorrespondencePackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "correspondence"));
            correspondenceModelResource.storeModelPartition(modelHandler.getCorrespondenceModel());
            final Neo4JModelResource<Repository> repositoryModelResource = new Neo4JModelResource<>(RepositoryPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "repository"));
            repositoryModelResource.storeModelPartition(modelHandler.getRepositoryModel());
            final Neo4JModelResource<ResourceEnvironment> resourceEnvironmentModelResource = new Neo4JModelResource<>(ResourceenvironmentPackage.eINSTANCE, // add
            new File(this.parameterConfiguration.getModelDatabaseDirectory(), "resourceenvironment"));
            resourceEnvironmentModelResource.storeModelPartition(modelHandler.getResourceEnvironmentModel());
            final Neo4JModelResource<System> systemModelResource = new Neo4JModelResource<>(SystemPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "system"));
            systemModelResource.storeModelPartition(modelHandler.getSystemModel());
            final Neo4JModelResource<Allocation> allocationModelResource = new Neo4JModelResource<>(AllocationPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "allocation"));
            allocationModelResource.storeModelPartition(modelHandler.getAllocationModel());
            final Neo4JModelResource<UsageModel> usageModelResource = new Neo4JModelResource<>(UsagemodelPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "usageModel"));
            usageModelResource.storeModelPartition(modelHandler.getUsageModel());
            final Neo4JModelResource<DataProtectionModel> privacyModelResource = new Neo4JModelResource<>(PrivacyPackage.eINSTANCE, new File(this.parameterConfiguration.getModelDatabaseDirectory(), "privacy"));
            privacyModelResource.storeModelPartition(modelHandler.getPrivacyModel());
            // get systemId
            final System systemModel = systemModelResource.getModelRootNode(System.class, SystemPackage.Literals.SYSTEM);
            this.kiekerConfiguration.setProperty(ConfigurationKeys.SYSTEM_ID, systemModel.getId());
            return new AnalysisConfiguration(this.kiekerConfiguration, repositoryModelResource, resourceEnvironmentModelResource, systemModelResource, allocationModelResource, usageModelResource, correspondenceModelResource);
        } catch (final IOException e) {
            // TODO should be replaced by logger
            // NOPMD
            java.lang.System.err.println("Cannot load all models " + e.getLocalizedMessage());
            // required
            return null;
        } catch (final DBException e) {
            // TODO should be replaced by logger
            // NOPMD
            java.lang.System.err.println("Cannot store all models in DB " + e.getLocalizedMessage());
            // required
            return null;
        }
    } else {
        return new AnalysisConfiguration(this.kiekerConfiguration);
    }
}
Also used : Neo4JModelResource(org.iobserve.model.persistence.neo4j.Neo4JModelResource) DBException(org.iobserve.model.persistence.DBException) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) DataProtectionModel(org.iobserve.model.privacy.DataProtectionModel) CorrespondenceModel(org.iobserve.model.correspondence.CorrespondenceModel) IOException(java.io.IOException) System(org.palladiosimulator.pcm.system.System) ModelImporter(org.iobserve.model.ModelImporter) Repository(org.palladiosimulator.pcm.repository.Repository) Allocation(org.palladiosimulator.pcm.allocation.Allocation) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) File(java.io.File)

Example 2 with ModelImporter

use of org.iobserve.model.ModelImporter in project iobserve-analysis by research-iobserve.

the class ModelGraphCreator method execute.

@Override
protected void execute(final AdaptationData adaptationData) throws Exception {
    final HostComponentAllocationGraphFactory runtimeFactory = new HostComponentAllocationGraphFactory();
    final HostComponentAllocationGraphFactory redeploymentFactory = new HostComponentAllocationGraphFactory();
    final File runtimeModelDir = adaptationData.getRuntimeModelDir();
    final File redeploymentModelDir = adaptationData.getReDeploymentModelDir();
    final HostComponentAllocationGraph runtimeModelGraph = runtimeFactory.buildGraph(new ModelImporter(runtimeModelDir), ModelGraphRevision.RUNTIME);
    final HostComponentAllocationGraph redeploymentModelGraph = redeploymentFactory.buildGraph(new ModelImporter(redeploymentModelDir), ModelGraphRevision.REDEPLOYMENT);
    adaptationData.setRuntimeGraph(runtimeModelGraph);
    adaptationData.setReDeploymentGraph(redeploymentModelGraph);
    this.getOutputPort().send(adaptationData);
}
Also used : ModelImporter(org.iobserve.model.ModelImporter) HostComponentAllocationGraph(org.iobserve.adaptation.data.graph.HostComponentAllocationGraph) HostComponentAllocationGraphFactory(org.iobserve.adaptation.data.graph.HostComponentAllocationGraphFactory) File(java.io.File)

Example 3 with ModelImporter

use of org.iobserve.model.ModelImporter in project iobserve-analysis by research-iobserve.

the class ModelComparer method execute.

@Override
protected void execute(final URI element) throws Exception {
    boolean equalGraphs = false;
    if (this.baseAdaptationData != null) {
        // TODO finish
        final ModelImporter modelProviders = new ModelImporter(new File(element.toFileString()));
        final HostComponentAllocationGraphFactory graphFactory = new HostComponentAllocationGraphFactory();
        final HostComponentAllocationGraph runtimeGraph = graphFactory.buildGraph(modelProviders, ModelGraphRevision.RUNTIME);
        if (runtimeGraph.equals(this.baseAdaptationData.getReDeploymentGraph()) && this.baseAdaptationData.getReDeploymentGraph().equals(runtimeGraph)) {
            equalGraphs = true;
            SystemEvaluation.disableEvaluation();
        }
    }
    this.outputPort.send(Boolean.valueOf(equalGraphs));
}
Also used : ModelImporter(org.iobserve.model.ModelImporter) HostComponentAllocationGraph(org.iobserve.adaptation.data.graph.HostComponentAllocationGraph) HostComponentAllocationGraphFactory(org.iobserve.adaptation.data.graph.HostComponentAllocationGraphFactory) File(java.io.File)

Example 4 with ModelImporter

use of org.iobserve.model.ModelImporter in project iobserve-analysis by research-iobserve.

the class ComposedActionFactoryInitialization method execute.

@Override
protected void execute(final AdaptationData adaptationData) throws Exception {
    // Set up ActionFactory because the rule engine will invoke it in ComposedActionComputation
    if (!this.isTestRun) {
        ActionFactory.setRuntimeModels(new ModelImporter(adaptationData.getRuntimeModelDir()));
        ActionFactory.setRedeploymentModels(new ModelImporter(adaptationData.getReDeploymentModelDir()));
    }
    this.outputPort.send(adaptationData);
}
Also used : ModelImporter(org.iobserve.model.ModelImporter)

Example 5 with ModelImporter

use of org.iobserve.model.ModelImporter in project iobserve-analysis by research-iobserve.

the class ModelProcessing method initModelTransformation.

private void initModelTransformation(final File originalModelDirectory) throws IOException, InitializationException {
    final ModelImporter originalModelHandler = new ModelImporter(originalModelDirectory);
    this.processedModelDirectory = new File(originalModelDirectory, ModelProcessing.PROCESSED_MODEL_FOLDER);
    FileUtils.copyDirectory(originalModelDirectory, this.processedModelDirectory);
    this.processedModelHandler = new ModelImporter(this.processedModelDirectory);
    this.allocationModel = this.processedModelHandler.getAllocationModel();
    this.cloudProfileModel = this.processedModelHandler.getCloudProfileModel();
    this.costModel = this.processedModelHandler.getCostModel();
    this.decisionModel = this.processedModelHandler.getDesignDecisionModel();
    this.resourceEnvironmentModel = this.processedModelHandler.getResourceEnvironmentModel();
    this.systemModel = this.processedModelHandler.getSystemModel();
    if (this.decisionModel == null) {
        this.decisionModel = DesignDecisionModelFactory.createDecisionSpace("processedDecision");
    }
    this.originalAllocationGroups = new AllocationGroupsContainer(originalModelHandler.getAllocationModel());
}
Also used : ModelImporter(org.iobserve.model.ModelImporter) AllocationGroupsContainer(org.iobserve.planning.data.AllocationGroupsContainer) File(java.io.File)

Aggregations

ModelImporter (org.iobserve.model.ModelImporter)6 File (java.io.File)4 IOException (java.io.IOException)2 HostComponentAllocationGraph (org.iobserve.adaptation.data.graph.HostComponentAllocationGraph)2 HostComponentAllocationGraphFactory (org.iobserve.adaptation.data.graph.HostComponentAllocationGraphFactory)2 CorrespondenceModel (org.iobserve.model.correspondence.CorrespondenceModel)2 DBException (org.iobserve.model.persistence.DBException)2 DataProtectionModel (org.iobserve.model.privacy.DataProtectionModel)2 Allocation (org.palladiosimulator.pcm.allocation.Allocation)2 Repository (org.palladiosimulator.pcm.repository.Repository)2 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)2 System (org.palladiosimulator.pcm.system.System)2 ConfigurationException (kieker.common.exception.ConfigurationException)1 Neo4JModelResource (org.iobserve.model.persistence.neo4j.Neo4JModelResource)1 AllocationGroupsContainer (org.iobserve.planning.data.AllocationGroupsContainer)1 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)1