Search in sources :

Example 6 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation 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 7 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class AssemblyContextActionFactory method generateAllocateAction.

/**
 * Create an allocation action.
 *
 * @param runtimeNode
 *            node to be allocated
 * @param reDeploymentNode
 *            node to be deployed
 * @return returns the allocation action
 */
public static AllocateAction generateAllocateAction(final ComponentNode runtimeNode, final ComponentNode reDeploymentNode) {
    final SystemadaptationFactory factory = SystemadaptationFactory.eINSTANCE;
    final AllocateAction action = factory.createAllocateAction();
    // Allcotaion has no runtime component
    // AssemblyContextActionFactory.setSourceAssemblyContext(action,
    // runtimeNode.getAssemblyContextID());
    final org.palladiosimulator.pcm.system.System reDeplSystem = ActionFactory.getRedeploymentModels().getSystemModel();
    action.setSourceAssemblyContext(ActionFactory.getAssemblyContext(reDeploymentNode.getAssemblyContextID(), reDeplSystem));
    final Allocation reDeplAllocation = ActionFactory.getRedeploymentModels().getAllocationModel();
    action.setNewAllocationContext(ActionFactory.getAllocationContext(reDeploymentNode.getAllocationContextID(), reDeplAllocation));
    return action;
}
Also used : Allocation(org.palladiosimulator.pcm.allocation.Allocation) SystemadaptationFactory(org.iobserve.planning.systemadaptation.SystemadaptationFactory) AllocateAction(org.iobserve.planning.systemadaptation.AllocateAction)

Example 8 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class ModelGenerationFactory method generateAndSaveAllocation.

private static Allocation generateAndSaveAllocation(final URI outputLocation, final System systemModel, final ResourceEnvironment resEnvModel) {
    final AllocationGeneration allocationGen = new AllocationGeneration(systemModel, resEnvModel);
    final Allocation allocationModel = allocationGen.generateAllocation();
    final AllocationModelHandler allocationModelProvider = new AllocationModelHandler();
    final URI allocationModelURI = URI.createFileURI(outputLocation.toFileString() + File.separator + resEnvModel.getEntityName() + ".allocation");
    allocationModelProvider.save(allocationModelURI, allocationModel);
    return allocationModel;
}
Also used : AllocationModelHandler(org.iobserve.model.provider.file.AllocationModelHandler) Allocation(org.palladiosimulator.pcm.allocation.Allocation) URI(org.eclipse.emf.common.util.URI)

Example 9 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class ModelModificationFactory method createNewModel.

/**
 * Create a new model.
 *
 * @param commandLine
 *            command line parameters
 * @throws InitializationException
 *             when handler do not initialize
 * @throws IOException
 *             on io errors
 */
public static void createNewModel(final CommandLine commandLine) throws InitializationException, IOException {
    ModelModificationFactory.LOGGER.info("Modifying model!");
    final URI inputModels = URI.createFileURI(commandLine.getOptionValue("i"));
    final URI outputLocation = URI.createFileURI(commandLine.getOptionValue("o"));
    ModelModificationFactory.LOGGER.info("Copying models to new location.");
    PCMModelHandler modelProviders = new PCMModelHandler(new File(inputModels.toFileString()));
    final URI copyURI = ModelModificationFactory.copyRepoToOutput(outputLocation, modelProviders);
    modelProviders = new PCMModelHandler(new File(copyURI.toFileString()));
    final Allocation allocationModel = modelProviders.getAllocationModel();
    final ResourceEnvironment resourceEnvironmentModel = modelProviders.getResourceEnvironmentModel();
    final System systemModel = modelProviders.getSystemModel();
    final Repository repositoryModel = modelProviders.getRepositoryModel();
    final ResourceEnvironmentModification resEnvMod = new ResourceEnvironmentModification(resourceEnvironmentModel);
    ModelModificationFactory.LOGGER.info("Terminating Server");
    final List<ResourceContainer> terminatedResourceContainers = resEnvMod.modifyResEnvTerminate(Integer.parseInt(commandLine.getOptionValue("ac")));
    ModelModificationFactory.LOGGER.info("Acquiring Server");
    resEnvMod.modifyResEnvAcquire(Integer.parseInt(commandLine.getOptionValue("ac")));
    ModelModificationFactory.LOGGER.info("Fixing Allocation after terminating");
    AllocationModification allocMod = new AllocationModification(allocationModel, systemModel, resourceEnvironmentModel);
    final int terminationMigrations = allocMod.modifyAllocationFixTerminations(terminatedResourceContainers);
    ModelModificationFactory.LOGGER.info("Deallocating Components");
    final SystemModification sysMod = new SystemModification(systemModel, repositoryModel);
    final List<AssemblyContext> deallocatedACs = sysMod.modifySystemDeallocations(Integer.parseInt(commandLine.getOptionValue("de")));
    ModelModificationFactory.LOGGER.info("Fixing Allocation after deallocating");
    allocMod = new AllocationModification(allocationModel, systemModel, resourceEnvironmentModel);
    allocMod.modifyAllocationFixDeallocations(deallocatedACs);
    // LOG.info("Exchanging Components");
    // sysMod.modifySystem_ChangeComp(Integer.parseInt(commandLine.getOptionValue("cr")));
    ModelModificationFactory.LOGGER.info("Allocating new Components");
    final List<AssemblyContext> allocatedACs = sysMod.modifySystemAllocate(Integer.parseInt(commandLine.getOptionValue("al")));
    ModelModificationFactory.LOGGER.info("Creating Allocation for new components");
    allocMod = new AllocationModification(allocationModel, systemModel, resourceEnvironmentModel);
    allocMod.modifyAllocationFixAllocations(allocatedACs);
    ModelModificationFactory.LOGGER.info("Creating migrations");
    allocMod = new AllocationModification(allocationModel, systemModel, resourceEnvironmentModel);
    final int totalMigrations = Integer.parseInt(commandLine.getOptionValue("al"));
    // allocationMigrations
    final int migrationsToPerform = totalMigrations - terminationMigrations;
    if (migrationsToPerform > 0) {
        ModelModificationFactory.LOGGER.info("Migrations to Perform: {}", migrationsToPerform);
        allocMod.modifyAllocationMigrate(migrationsToPerform);
    } else {
        ModelModificationFactory.LOGGER.info(String.format("All migrations (%d) are already perfomed by Server-Termination (%d)!", totalMigrations, migrationsToPerform));
    }
    ModelModificationFactory.LOGGER.info("Saving models!");
    modelProviders.save(outputLocation);
    ModelModificationFactory.LOGGER.info("Modification done!");
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) PCMModelHandler(org.iobserve.model.PCMModelHandler) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) URI(org.eclipse.emf.common.util.URI) System(org.palladiosimulator.pcm.system.System) Repository(org.palladiosimulator.pcm.repository.Repository) Allocation(org.palladiosimulator.pcm.allocation.Allocation) File(java.io.File) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 10 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class SerializePcmModelStage method execute.

@Override
protected void execute(final EObject model) throws Exception {
    final ResourceSet resourceSet = model.eResource().getResourceSet();
    final String filePathPrefix = this.modelDirectory.getAbsolutePath() + File.separator + this.modelName;
    final String filePath;
    if (model instanceof Allocation) {
        filePath = filePathPrefix + "." + AllocationPackage.eNAME;
        new FileModelHandler<Allocation>(resourceSet, AllocationPackage.eINSTANCE).save(URI.createFileURI(filePath), (Allocation) model);
    } else if (model instanceof CloudProfile) {
        filePath = filePathPrefix + "." + CloudprofilePackage.eNAME;
        new FileModelHandler<CloudProfile>(resourceSet, CloudprofilePackage.eINSTANCE).save(URI.createFileURI(filePath), (CloudProfile) model);
    } else if (model instanceof CostRepository) {
        filePath = filePathPrefix + "." + costPackage.eNAME;
        new FileModelHandler<CostRepository>(resourceSet, costPackage.eINSTANCE).save(URI.createFileURI(filePath), (CostRepository) model);
    } else if (model instanceof DecisionSpace) {
        filePath = filePathPrefix + "." + designdecisionPackage.eNAME;
        new FileModelHandler<DecisionSpace>(resourceSet, designdecisionPackage.eINSTANCE).save(URI.createFileURI(filePath), (DecisionSpace) model);
    } else if (model instanceof QMLDeclarations) {
        filePath = filePathPrefix + "." + QMLDeclarationsPackage.eNAME;
        new FileModelHandler<QMLDeclarations>(resourceSet, QMLDeclarationsPackage.eINSTANCE).save(URI.createFileURI(filePath), (QMLDeclarations) model);
    } else if (model instanceof Repository) {
        filePath = filePathPrefix + "." + RepositoryPackage.eNAME;
        new FileModelHandler<Repository>(resourceSet, RepositoryPackage.eINSTANCE).save(URI.createFileURI(filePath), (Repository) model);
    } else if (model instanceof ResourceEnvironment) {
        filePath = filePathPrefix + "." + ResourceenvironmentPackage.eNAME;
        new FileModelHandler<ResourceEnvironment>(resourceSet, ResourceenvironmentPackage.eINSTANCE).save(URI.createFileURI(filePath), (ResourceEnvironment) model);
    } else if (model instanceof System) {
        filePath = filePathPrefix + "." + SystemPackage.eNAME;
        new FileModelHandler<System>(resourceSet, SystemPackage.eINSTANCE).save(URI.createFileURI(filePath), (System) model);
    } else if (model instanceof UsageModel) {
        filePath = filePathPrefix + UsagemodelPackage.eNAME;
        new FileModelHandler<UsageModel>(resourceSet, UsagemodelPackage.eINSTANCE).save(URI.createFileURI(filePath), (UsageModel) model);
    } else {
        throw new IllegalArgumentException("The EObject passed to this stage must be a PCM model!");
    }
    this.getOutputPort().send(new File(filePath));
}
Also used : CloudProfile(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) QMLDeclarations(de.uka.ipd.sdq.dsexplore.qml.declarations.QMLDeclarations.QMLDeclarations) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) System(org.palladiosimulator.pcm.system.System) CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository) Repository(org.palladiosimulator.pcm.repository.Repository) FileModelHandler(org.iobserve.model.persistence.file.FileModelHandler) Allocation(org.palladiosimulator.pcm.allocation.Allocation) CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository) DecisionSpace(de.uka.ipd.sdq.pcm.designdecision.DecisionSpace) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) File(java.io.File)

Aggregations

Allocation (org.palladiosimulator.pcm.allocation.Allocation)37 Test (org.junit.Test)16 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)10 System (org.palladiosimulator.pcm.system.System)10 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)9 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)7 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)7 File (java.io.File)4 IOException (java.io.IOException)4 PCMModelHandler (org.iobserve.model.PCMModelHandler)4 Repository (org.palladiosimulator.pcm.repository.Repository)4 CorrespondenceModel (org.iobserve.model.correspondence.CorrespondenceModel)3 DBException (org.iobserve.model.persistence.DBException)3 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)3 ArrayList (java.util.ArrayList)2 URI (org.eclipse.emf.common.util.URI)2 EObject (org.eclipse.emf.ecore.EObject)2 ModelImporter (org.iobserve.model.ModelImporter)2 Neo4JModelResource (org.iobserve.model.persistence.neo4j.Neo4JModelResource)2 DataProtectionModel (org.iobserve.model.privacy.DataProtectionModel)2