use of org.iobserve.model.correspondence.ICorrespondence 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;
}
}
use of org.iobserve.model.correspondence.ICorrespondence 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);
}
Aggregations