Search in sources :

Example 1 with ModelProvider

use of org.iobserve.model.provider.neo4j.ModelProvider in project iobserve-analysis by research-iobserve.

the class AnalysisMain method createConfiguration.

@Override
protected AnalysisConfiguration createConfiguration(final Configuration configuration) throws ConfigurationException {
    /**
     * Configure model handling.
     */
    // old model providers without neo4j
    final PCMModelHandler modelFileHandler = new PCMModelHandler(this.modelInitDirectory);
    final ICorrespondence correspondenceModel = modelFileHandler.getCorrespondenceModel();
    /**
     * initialize neo4j graphs.
     */
    final GraphLoader graphLoader = new GraphLoader(this.modelDatabaseDirectory);
    Graph repositoryModelGraph = graphLoader.initializeRepositoryModelGraph(modelFileHandler.getRepositoryModel());
    Graph resourceEnvironmentGraph = graphLoader.initializeResourceEnvironmentModelGraph(modelFileHandler.getResourceEnvironmentModel());
    Graph allocationModelGraph = graphLoader.initializeAllocationModelGraph(modelFileHandler.getAllocationModel());
    Graph systemModelGraph = graphLoader.initializeSystemModelGraph(modelFileHandler.getSystemModel());
    Graph usageModelGraph = graphLoader.initializeUsageModelGraph(modelFileHandler.getUsageModel());
    /**
     * load neo4j graphs.
     */
    repositoryModelGraph = graphLoader.createRepositoryModelGraph();
    resourceEnvironmentGraph = graphLoader.createResourceEnvironmentModelGraph();
    allocationModelGraph = graphLoader.createAllocationModelGraph();
    systemModelGraph = graphLoader.createSystemModelGraph();
    usageModelGraph = graphLoader.createUsageModelGraph();
    /**
     * new graphModelProvider.
     */
    final IModelProvider<Repository> repositoryModelProvider = new ModelProvider<>(repositoryModelGraph);
    final IModelProvider<ResourceEnvironment> resourceEnvironmentModelProvider = new ModelProvider<>(resourceEnvironmentGraph);
    final IModelProvider<Allocation> allocationModelProvider = new ModelProvider<>(allocationModelGraph);
    final IModelProvider<org.palladiosimulator.pcm.system.System> systemModelProvider = new ModelProvider<>(systemModelGraph);
    final IModelProvider<UsageModel> usageModelProvider = new ModelProvider<>(usageModelGraph);
    // get systemId
    final org.palladiosimulator.pcm.system.System systemModel = systemModelProvider.readOnlyRootComponent(org.palladiosimulator.pcm.system.System.class);
    final String systemId = systemModel.getId();
    try {
        /**
         * URLs for sending updates to the deployment visualization.
         */
        // TODO this should be moved to the visualization sinks
        final String[] sinks = configuration.getStringArrayProperty(ConfigurationKeys.CONTAINER_MANAGEMENT_SINK, ",");
        if (sinks.length > 0) {
            final InitializeDeploymentVisualization deploymentVisualization = new InitializeDeploymentVisualization(this.containerManagementVisualizationBaseUrl, systemId, allocationModelProvider, systemModelProvider, resourceEnvironmentModelProvider);
            deploymentVisualization.initialize();
        }
        return new AnalysisConfiguration(configuration, repositoryModelProvider, resourceEnvironmentModelProvider, allocationModelProvider, systemModelProvider, usageModelProvider, correspondenceModel);
    } catch (final MalformedURLException e) {
        AbstractServiceMain.LOGGER.debug("URL construction for deployment visualization failed.", e);
        return null;
    } catch (final IOException e) {
        AbstractServiceMain.LOGGER.debug("Deployment visualization could not connect to visualization service.", e);
        return null;
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) MalformedURLException(java.net.MalformedURLException) IModelProvider(org.iobserve.model.provider.neo4j.IModelProvider) ModelProvider(org.iobserve.model.provider.neo4j.ModelProvider) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ICorrespondence(org.iobserve.model.correspondence.ICorrespondence) AnalysisConfiguration(org.iobserve.analysis.configurations.AnalysisConfiguration) PCMModelHandler(org.iobserve.model.PCMModelHandler) IOException(java.io.IOException) Repository(org.palladiosimulator.pcm.repository.Repository) Graph(org.iobserve.model.provider.neo4j.Graph) GraphLoader(org.iobserve.model.provider.neo4j.GraphLoader) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel)

Example 2 with ModelProvider

use of org.iobserve.model.provider.neo4j.ModelProvider 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);
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ModelProvider(org.iobserve.model.provider.neo4j.ModelProvider) PCMModelHandler(org.iobserve.model.PCMModelHandler) IOException(java.io.IOException) System(org.palladiosimulator.pcm.system.System) Graph(org.iobserve.model.provider.neo4j.Graph) GraphLoader(org.iobserve.model.provider.neo4j.GraphLoader) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ConfigurationException(org.iobserve.stages.general.ConfigurationException)

Example 3 with ModelProvider

use of org.iobserve.model.provider.neo4j.ModelProvider in project iobserve-analysis by research-iobserve.

the class UserBehaviorTransformationTest method testBranchWithinLoop.

/**
 * TODO this test is dysfunctional as models are missing Test branch within a loop.
 *
 * @throws IOException
 *             when reading and writing files.
 */
// @Test
public void testBranchWithinLoop() throws IOException {
    // TODO load that model
    final ICorrespondence correspondenceModel = null;
    // TODO fix location
    final GraphLoader graphLoader = new GraphLoader(null);
    final Graph graph = graphLoader.createRepositoryModelGraph();
    final ModelProvider<Repository> repositoryModelProvider = new ModelProvider<>(graph);
    final RepositoryLookupModelProvider repositoryLookupModel = new RepositoryLookupModelProvider(repositoryModelProvider.readRootComponent(Repository.class));
    final int numberOfIterations = 500;
    final int stepSize = 1;
    final List<AccuracyResults> results = new ArrayList<>();
    for (int i = 1; i <= numberOfIterations; i += stepSize) {
        final int numberOfUserGroups = UserBehaviorTransformationTest.NUMBER_OF_USER_GROUPS;
        final int varianceOfUserGroups = 0;
        final int thinkTime = UserBehaviorTransformationTest.THINK_TIME;
        final boolean isClosedWorkload = UserBehaviorTransformationTest.CLOSED_WORKLOAD;
        final ReferenceElements referenceElements = SimpleSequenceReference.getModel(UserBehaviorTransformationTest.REFERENCE_USAGE_MODEL, repositoryLookupModel, correspondenceModel, thinkTime, isClosedWorkload);
        final UserBehaviorTransformation behaviorModeling = new UserBehaviorTransformation(referenceElements.getEntryCallSequenceModel(), numberOfUserGroups, varianceOfUserGroups, isClosedWorkload, thinkTime, repositoryLookupModel, correspondenceModel);
        behaviorModeling.modelUserBehavior();
        final AccuracyResults accuracyResults = UserBehaviorEvaluation.matchUsageModels(behaviorModeling.getPcmUsageModel(), referenceElements.getUsageModel());
        results.add(accuracyResults);
        final double relativeMeasurementError = WorkloadEvaluation.calculateRME(behaviorModeling.getPcmUsageModel(), referenceElements);
        if (UserBehaviorTransformationTest.LOGGER.isDebugEnabled()) {
            UserBehaviorTransformationTest.LOGGER.debug("RME " + relativeMeasurementError);
        }
        TestHelper.saveModel(behaviorModeling.getPcmUsageModel(), UserBehaviorTransformationTest.OUTPUT_USAGE_MODEL);
        if (UserBehaviorTransformationTest.LOGGER.isDebugEnabled()) {
            UserBehaviorTransformationTest.LOGGER.debug("Iteration :" + i + "/" + numberOfIterations);
        }
    }
    TestHelper.writeAccuracyResults(results);
}
Also used : RepositoryLookupModelProvider(org.iobserve.model.provider.RepositoryLookupModelProvider) ModelProvider(org.iobserve.model.provider.neo4j.ModelProvider) ArrayList(java.util.ArrayList) Repository(org.palladiosimulator.pcm.repository.Repository) Graph(org.iobserve.model.provider.neo4j.Graph) GraphLoader(org.iobserve.model.provider.neo4j.GraphLoader) ICorrespondence(org.iobserve.model.correspondence.ICorrespondence) RepositoryLookupModelProvider(org.iobserve.model.provider.RepositoryLookupModelProvider)

Aggregations

Graph (org.iobserve.model.provider.neo4j.Graph)3 GraphLoader (org.iobserve.model.provider.neo4j.GraphLoader)3 ModelProvider (org.iobserve.model.provider.neo4j.ModelProvider)3 IOException (java.io.IOException)2 PCMModelHandler (org.iobserve.model.PCMModelHandler)2 ICorrespondence (org.iobserve.model.correspondence.ICorrespondence)2 Allocation (org.palladiosimulator.pcm.allocation.Allocation)2 Repository (org.palladiosimulator.pcm.repository.Repository)2 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 AnalysisConfiguration (org.iobserve.analysis.configurations.AnalysisConfiguration)1 RepositoryLookupModelProvider (org.iobserve.model.provider.RepositoryLookupModelProvider)1 IModelProvider (org.iobserve.model.provider.neo4j.IModelProvider)1 ConfigurationException (org.iobserve.stages.general.ConfigurationException)1 System (org.palladiosimulator.pcm.system.System)1 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)1