Search in sources :

Example 21 with ResourceContainerCloud

use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.

the class ModelTransformer method createResourcesAndReplicationDegrees.

private void createResourcesAndReplicationDegrees(final AllocationGroup allocationGroup) throws ModelHandlingErrorException {
    final CloudProfile profile = this.cloudProfileModel;
    final ResourceEnvironment environment = this.resourceEnvironmentModel;
    final CostRepository costs = this.costModel;
    // Get resource container that represents the instances this allocation
    // group is currently deployed on
    final ResourceContainerCloud representingContainer = allocationGroup.getRepresentingResourceContainer();
    if (representingContainer == null) {
        throw new IllegalArgumentException(String.format("Could not find a cloud container for allocation group '%s'. Check your model.", allocationGroup.getName()));
    }
    // Set group name of the representing container and add it to the
    // resource environment
    representingContainer.setGroupName(allocationGroup.getName());
    representingContainer.setEntityName(allocationGroup.getName());
    ModelHelper.addResourceContainerToEnvironment(environment, representingContainer);
    final int nrOfCurrentReplicas = allocationGroup.getAllocationContexts().size();
    // Upper bound for number of replicas for one resource
    // container type should be sufficiently high
    final int toNrOfReplicas = (nrOfCurrentReplicas + PlanningData.POSSIBLE_REPLICAS_OFFSET) * PlanningData.POSSIBLE_REPLICAS_FACTOR;
    // representing container create only replication degree
    for (final CloudProvider provider : profile.getCloudProviders()) {
        for (final CloudResourceType cloudResource : provider.getCloudResources()) {
            if (cloudResource instanceof VMType) {
                final VMType cloudVM = (VMType) cloudResource;
                final String degreeName;
                final ResourceContainerCloud createdContainer;
                if (this.isSameVMType(cloudVM, representingContainer)) {
                    createdContainer = representingContainer;
                    degreeName = String.format("%s_ReplicationDegree", allocationGroup.getName());
                } else {
                    final String containerName = AllocationGroup.getAllocationGroupName(allocationGroup.getComponentName(), ModelHelper.getResourceContainerIdentifier(cloudVM));
                    createdContainer = ModelHelper.createResourceContainerFromVMType(environment, costs, cloudVM, containerName);
                    degreeName = String.format("%s_ReplicationDegree", containerName);
                }
                DesignDecisionModelFactory.createReplicationDegree(this.decisionSpace, degreeName, createdContainer, 1, toNrOfReplicas);
            }
        }
    }
}
Also used : CloudProfile(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) CloudResourceType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType) ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType) CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository) CloudProvider(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)

Aggregations

ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)21 VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)6 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)6 ComputeService (org.jclouds.compute.ComputeService)5 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)4 CostRepository (de.uka.ipd.sdq.pcm.cost.CostRepository)3 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)3 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)2 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)1 Template (org.jclouds.compute.domain.Template)1 TemplateBuilder (org.jclouds.compute.domain.TemplateBuilder)1 TemplateOptions (org.jclouds.compute.options.TemplateOptions)1 Statement (org.jclouds.scriptbuilder.domain.Statement)1 CloudProfile (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile)1 CloudProvider (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)1 CloudResourceType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType)1