Search in sources :

Example 1 with ModelHandlingErrorException

use of org.iobserve.model.ModelHandlingErrorException 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 2 with ModelHandlingErrorException

use of org.iobserve.model.ModelHandlingErrorException 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)

Aggregations

CostRepository (de.uka.ipd.sdq.pcm.cost.CostRepository)2 DecisionSpace (de.uka.ipd.sdq.pcm.designdecision.DecisionSpace)2 DegreeOfFreedomInstance (de.uka.ipd.sdq.pcm.designdecision.DegreeOfFreedomInstance)2 ResourceContainerReplicationDegree (de.uka.ipd.sdq.pcm.designdecision.specific.ResourceContainerReplicationDegree)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 EcoreUtil (org.eclipse.emf.ecore.util.EcoreUtil)2 ModelHandlingErrorException (org.iobserve.model.ModelHandlingErrorException)2 PCMModelHandler (org.iobserve.model.PCMModelHandler)2 CostModelFactory (org.iobserve.model.factory.CostModelFactory)2 ResourceEnvironmentCloudFactory (org.iobserve.model.factory.ResourceEnvironmentCloudFactory)2 CostModelHandler (org.iobserve.model.provider.file.CostModelHandler)2 ResourceEnvironmentModelHandler (org.iobserve.model.provider.file.ResourceEnvironmentModelHandler)2 Allocation (org.palladiosimulator.pcm.allocation.Allocation)2 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)2 CloudProfile (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile)2 CloudProvider (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)2 CloudResourceType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType)2 VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)2