Search in sources :

Example 11 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project Palladio-Editors-Sirius by PalladioSimulator.

the class AllocationCreationWizard method init.

@Override
protected void init(IStructuredSelection selection) {
    String viewpointName = Activator.VIEWPOINT_NAME;
    viewpoint = Activator.getDefault().getViewpoint();
    String ext = Activator.getDefault().getViewpoint().getModelFileExtension();
    modelCreationPage = new ModelCreationPage(selection, viewpointName + " Creation Wizard", "new" + viewpointName, ext);
    representationDescription = Activator.getDefault().getRepresentationDescription();
    String defaultRepresentationName = "new " + Activator.REPRESENTATION_NAME;
    this.representationCreationPage.setDefaultRepresentationName(defaultRepresentationName);
    resourceEnvironmentSelectorpage = new ResourceEnvironmentSelectorPage();
    systemSelectorPage = new SystemSelectorPage();
    additionalPages.add(resourceEnvironmentSelectorpage);
    additionalPages.add(systemSelectorPage);
    Allocation obj = AllocationFactory.eINSTANCE.createAllocation();
    obj.setEntityName("New Allocation");
    modelObject = obj;
}
Also used : ModelCreationPage(org.palladiosimulator.editors.sirius.ui.wizard.model.ModelCreationPage) Allocation(org.palladiosimulator.pcm.allocation.Allocation)

Example 12 with Allocation

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

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

the class AssemblyContextActionFactory method generateMigrateAction.

/**
 * Create a migration action.
 *
 * @param runtimeNode
 *            source node
 * @param reDeploymentNode
 *            target node
 * @return returns the migration action
 */
public static MigrateAction generateMigrateAction(final ComponentNode runtimeNode, final ComponentNode reDeploymentNode) {
    final MigrateAction action = SystemadaptationFactory.eINSTANCE.createMigrateAction();
    final Allocation runtimeAllocation = ActionFactory.getRuntimeModels().getAllocationModel();
    final Allocation redeploymentAllocation = ActionFactory.getRedeploymentModels().getAllocationModel();
    final System runtimeSystem = ActionFactory.getRuntimeModels().getSystemModel();
    final System redeploymentSystem = ActionFactory.getRedeploymentModels().getSystemModel();
    AssemblyContextActionFactory.initializeAssemblyContextAction(action, reDeploymentNode, redeploymentAllocation, redeploymentSystem);
    action.setSourceAllocationContext(ActionFactory.getAllocationContext(runtimeNode.getAllocationContextID(), runtimeAllocation));
    // source providing allocation contexts
    ActionFactory.getProvidingAssemblyContexts(runtimeNode.getAssemblyContextID(), runtimeSystem).forEach(ac -> action.getSourceProvidingAllocationContexts().add(ActionFactory.getAllocationContextContainingAssemblyContext(ac.getId(), runtimeAllocation)));
    // source requiring allocation contexts
    ActionFactory.getRequiringAssemblyContexts(runtimeNode.getAssemblyContextID(), runtimeSystem).forEach(ac -> action.getSourceRequiringAllocationContexts().add(ActionFactory.getAllocationContextContainingAssemblyContext(ac.getId(), runtimeAllocation)));
    return action;
}
Also used : Allocation(org.palladiosimulator.pcm.allocation.Allocation) System(org.palladiosimulator.pcm.system.System) MigrateAction(org.iobserve.planning.systemadaptation.MigrateAction)

Example 14 with Allocation

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

the class AssemblyContextActionFactory method generateChangeRepositoryComponentAction.

/**
 * Create a change repository component action.
 *
 * @param runtimeNode
 *            node to be changed
 * @param reDeploymentNode
 *            target node
 * @return returns the composed action
 */
public static ChangeRepositoryComponentAction generateChangeRepositoryComponentAction(final ComponentNode runtimeNode, final ComponentNode reDeploymentNode) {
    final ChangeRepositoryComponentAction action = SystemadaptationFactory.eINSTANCE.createChangeRepositoryComponentAction();
    final Allocation runtimeAllocation = ActionFactory.getRuntimeModels().getAllocationModel();
    final Allocation redeploymentAllocation = ActionFactory.getRedeploymentModels().getAllocationModel();
    final System redeploymentSystem = ActionFactory.getRedeploymentModels().getSystemModel();
    AssemblyContextActionFactory.initializeAssemblyContextAction(action, reDeploymentNode, redeploymentAllocation, redeploymentSystem);
    action.setSourceAllocationContext(ActionFactory.getAllocationContext(runtimeNode.getAllocationContextID(), runtimeAllocation));
    return action;
}
Also used : Allocation(org.palladiosimulator.pcm.allocation.Allocation) System(org.palladiosimulator.pcm.system.System) ChangeRepositoryComponentAction(org.iobserve.planning.systemadaptation.ChangeRepositoryComponentAction)

Example 15 with Allocation

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

the class NetworkLink method execute.

/**
 * Execute this filter.
 *
 * @param event
 *            event to use
 * @throws NodeLookupException
 * @throws DBException
 *             on db errors
 */
@Override
protected void execute(final TraceMetadata event) throws NodeLookupException, DBException {
    final ResourceEnvironment resourceEnvironment = this.resourceEnvironmentModelResource.getAndLockModelRootNode(ResourceEnvironment.class, ResourceenvironmentPackage.Literals.RESOURCE_ENVIRONMENT);
    final System system = this.systemModelResource.getModelRootNode(System.class, SystemPackage.Literals.SYSTEM);
    final Allocation allocation = this.allocationModelResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    NetworkLink.collectUnLinkedResourceContainer(resourceEnvironment).stream().forEach(unLinkedResCont -> {
        NetworkLink.getAsmContextDeployedOnContainer(allocation, unLinkedResCont).stream().map(asmCtx -> NetworkLink.getConnectedAsmCtx(system, asmCtx)).map(listAsmCtxToConnect -> NetworkLink.collectResourceContainer(allocation, listAsmCtxToConnect)).map(listResContToConnectTo -> NetworkLink.getLinkingResources(resourceEnvironment, listResContToConnectTo)).flatMap(l -> l.stream()).collect(Collectors.toList()).stream().forEach(link -> link.getConnectedResourceContainers_LinkingResource().add(unLinkedResCont));
    });
    this.resourceEnvironmentModelResource.updatePartition(resourceEnvironment);
}
Also used : Logger(org.slf4j.Logger) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) TraceMetadata(kieker.common.record.flow.trace.TraceMetadata) ResourceenvironmentPackage(org.palladiosimulator.pcm.resourceenvironment.ResourceenvironmentPackage) AssemblyConnector(org.palladiosimulator.pcm.core.composition.AssemblyConnector) LoggerFactory(org.slf4j.LoggerFactory) NodeLookupException(org.iobserve.model.persistence.neo4j.NodeLookupException) Connector(org.palladiosimulator.pcm.core.composition.Connector) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) Collectors(java.util.stream.Collectors) Allocation(org.palladiosimulator.pcm.allocation.Allocation) DBException(org.iobserve.model.persistence.DBException) List(java.util.List) Neo4JModelResource(org.iobserve.model.persistence.neo4j.Neo4JModelResource) AbstractConsumerStage(teetime.framework.AbstractConsumerStage) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) Optional(java.util.Optional) System(org.palladiosimulator.pcm.system.System) AllocationPackage(org.palladiosimulator.pcm.allocation.AllocationPackage) SystemPackage(org.palladiosimulator.pcm.system.SystemPackage) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) Allocation(org.palladiosimulator.pcm.allocation.Allocation) System(org.palladiosimulator.pcm.system.System)

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