Search in sources :

Example 16 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.

the class ModelHelper method getResourceContainerFromHostname.

/**
 * Creates a cloud container from the given hostname with the information provided by the model
 * providers in the resource environment provided by the model providers.
 *
 * If the hostname is not a valid cloud container hostname or if no matching VMType could be
 * found, the method returns null.
 *
 * @param modelProviders
 *            the model providers to use
 * @param hostname
 *            the hostname to convert
 * @return the new cloud container or null in case of a problem
 * @throws ModelHandlingErrorException
 *             model handling error
 */
public static ResourceContainerCloud getResourceContainerFromHostname(final PCMModelHandler modelProviders, final String hostname) throws ModelHandlingErrorException {
    final String[] nameParts = hostname.split("_");
    VMType vmType = null;
    // ContainerId_AllocationGroupName_ProviderName_Location_InstanceType
    if (nameParts.length == 5) {
        final String groupName = nameParts[1];
        final String providerName = nameParts[2];
        final String location = nameParts[3];
        final String instanceType = nameParts[4];
        vmType = ModelHelper.getVMType(modelProviders.getCloudProfileModel(), providerName, location, instanceType);
        if (vmType != null) {
            final ResourceEnvironment environment = modelProviders.getResourceEnvironmentModel();
            final CostRepository costRepository = modelProviders.getCostModel();
            final ResourceContainerCloud cloudContainer = ModelHelper.createResourceContainerFromVMType(environment, costRepository, vmType, hostname);
            cloudContainer.setGroupName(groupName);
            return cloudContainer;
        }
    }
    return null;
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType) ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository)

Example 17 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.

the class ModelHelper method getInternetLinkingResource.

/**
 * Searches the resource environment for a linking resource with name 'Internet' and returns it,
 * or creates it if it does not exist.
 *
 * @param environment
 *            the resource environment to search
 * @return the found linking resource or the newly created one
 */
public static LinkingResource getInternetLinkingResource(final ResourceEnvironment environment) {
    final List<LinkingResource> linkingResources = environment.getLinkingResources__ResourceEnvironment();
    final Optional<LinkingResource> internetLink = linkingResources.stream().filter(link -> link.getEntityName().contains(ModelHelper.INTERNET_LINKING_RESOURCE_NAME)).findFirst();
    final LinkingResource linkingResource = internetLink.orElseGet(() -> {
        try {
            return org.iobserve.model.factory.ResourceEnvironmentCloudFactory.createLinkingResource(environment, null, ModelHelper.INTERNET_LINKING_RESOURCE_NAME);
        } catch (final ModelHandlingErrorException e) {
            return null;
        }
    });
    return linkingResource;
}
Also used : PCMModelHandler(org.iobserve.model.PCMModelHandler) CloudProfile(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType) ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) Allocation(org.palladiosimulator.pcm.allocation.Allocation) DecisionSpace(de.uka.ipd.sdq.pcm.designdecision.DecisionSpace) ResourceEnvironmentModelHandler(org.iobserve.model.provider.file.ResourceEnvironmentModelHandler) ModelHandlingErrorException(org.iobserve.model.ModelHandlingErrorException) CostModelFactory(org.iobserve.model.factory.CostModelFactory) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) CloudResourceType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType) DegreeOfFreedomInstance(de.uka.ipd.sdq.pcm.designdecision.DegreeOfFreedomInstance) CloudProvider(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification) ResourceContainerReplicationDegree(de.uka.ipd.sdq.pcm.designdecision.specific.ResourceContainerReplicationDegree) Collectors(java.util.stream.Collectors) CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository) AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) List(java.util.List) CostModelHandler(org.iobserve.model.provider.file.CostModelHandler) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) Optional(java.util.Optional) ResourceEnvironmentCloudFactory(org.iobserve.model.factory.ResourceEnvironmentCloudFactory) ModelHandlingErrorException(org.iobserve.model.ModelHandlingErrorException) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource)

Example 18 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project iobserve-analysis by research-iobserve.

the class ModelTransformer method clearCloudResourcesFromResourceEnv.

private void clearCloudResourcesFromResourceEnv() {
    final ResourceEnvironment environment = this.resourceEnvironmentModel;
    final List<ResourceContainer> resourceContainers = environment.getResourceContainer_ResourceEnvironment();
    for (final Iterator<ResourceContainer> iter = resourceContainers.iterator(); iter.hasNext(); ) {
        final ResourceContainer container = iter.next();
        if (container instanceof ResourceContainerCloud) {
            iter.remove();
        }
    }
    final LinkingResource linkingResource = ModelHelper.getInternetLinkingResource(environment);
    linkingResource.getConnectedResourceContainers_LinkingResource().clear();
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 19 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment 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)

Example 20 with ResourceEnvironment

use of org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddATAction method execute.

/**
 * Creates an {@link ArchitecturalTemplateSelectEObjectDialog} that queries the user for an
 * {@link AT} and applies the corresponding {@link Stereotype} to the selected {@link System}.
 */
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final ArchitecturalTemplateSelectionDialog profileSelectionDialog = new ArchitecturalTemplateSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
    profileSelectionDialog.setElements(ArchitecturalTemplateAPI.getRegisteredArchitecturalTemplates().toArray(new AT[ArchitecturalTemplateAPI.getRegisteredArchitecturalTemplates().size()]));
    profileSelectionDialog.setMessage(DIALOG_MESSAGE);
    if (profileSelectionDialog.open() != Dialog.OK) {
        return;
    }
    final AT at = profileSelectionDialog.getResultArchitecturalTemplate();
    final EObject eObject = selections.iterator().next();
    if (eObject instanceof System) {
        final System system = (System) eObject;
        ArchitecturalTemplateAPI.applyArchitecturalTemplate(system, at);
    } else if (eObject instanceof ResourceEnvironment) {
        final ResourceEnvironment resourceenvironment = (ResourceEnvironment) eObject;
        ArchitecturalTemplateAPI.applyArchitecturalTemplate(resourceenvironment, at);
    } else {
        throw new RuntimeException("Unsupported eObject: " + eObject);
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) AT(org.palladiosimulator.architecturaltemplates.AT) ArchitecturalTemplateSelectionDialog(org.palladiosimulator.architecturaltemplates.ui.dialogs.ArchitecturalTemplateSelectionDialog) EObject(org.eclipse.emf.ecore.EObject) System(org.palladiosimulator.pcm.system.System)

Aggregations

ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)55 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)23 Test (org.junit.Test)15 CostRepository (de.uka.ipd.sdq.pcm.cost.CostRepository)12 Allocation (org.palladiosimulator.pcm.allocation.Allocation)12 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)12 VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)11 CloudProfile (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile)8 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)8 System (org.palladiosimulator.pcm.system.System)8 CloudProvider (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)7 CloudResourceType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType)7 EObject (org.eclipse.emf.ecore.EObject)6 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)6 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)6 IOException (java.io.IOException)5 URI (org.eclipse.emf.common.util.URI)5 PCMModelHandler (org.iobserve.model.PCMModelHandler)5 ResourceEnvironmentModelHandler (org.iobserve.model.provider.file.ResourceEnvironmentModelHandler)5 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)5