Search in sources :

Example 11 with ResourceEnvironment

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

the class ResourceContainerActionFactory method setSourceResourceContainer.

private static ResourceContainerAction setSourceResourceContainer(final ResourceContainerAction action, final String resourceContainerID) {
    final ResourceEnvironment resEnvModel = ActionFactory.getRuntimeModels().getResourceEnvironmentModel();
    final ResourceContainer resourceContainer = ActionFactory.getResourceContainer(resourceContainerID, resEnvModel);
    action.setSourceResourceContainer(resourceContainer);
    return action;
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 12 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 13 with ResourceEnvironment

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

the class ModelGenerationFactory method generateAndSaveResourceEnvironment.

private static ResourceEnvironment generateAndSaveResourceEnvironment(final CommandLine commandLine, final URI outputLocation, final String modelName) {
    final ResourceEnvironmentGeneration resEnvGen = new ResourceEnvironmentGeneration(modelName);
    final ResourceEnvironment resEnvModel = resEnvGen.craeteResourceEnvironment(Integer.parseInt(commandLine.getOptionValue("r")));
    final ResourceEnvironmentModelHandler resEnvModelProvider = new ResourceEnvironmentModelHandler();
    final URI resEnvModelURI = URI.createFileURI(outputLocation.toFileString() + File.separator + resEnvModel.getEntityName() + ".resourceenvironment");
    resEnvModelProvider.save(resEnvModelURI, resEnvModel);
    return resEnvModel;
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ResourceEnvironmentModelHandler(org.iobserve.model.provider.file.ResourceEnvironmentModelHandler) URI(org.eclipse.emf.common.util.URI)

Example 14 with ResourceEnvironment

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

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

the class GeoLocation method execute.

@Override
protected void execute(final PCMDeployedEvent element) throws Exception {
    // TODO this might be better implemented using query functions addressing RescourceContainer
    final ResourceEnvironment resourceEnvironment = this.resourceEnvironmentModelProvider.readRootComponent(ResourceEnvironment.class);
    final EList<ResourceContainer> resContainers = resourceEnvironment.getResourceContainer_ResourceEnvironment();
    for (final ResourceContainer resContainer : resContainers) {
        if (resContainer.getEntityName().equals(element.getService()) && resContainer instanceof ResourceContainerPrivacy) {
            final ResourceContainerPrivacy resContainerPrivacy = (ResourceContainerPrivacy) resContainer;
            final int geolocation = resContainerPrivacy.getGeolocation();
            if (geolocation != element.getCountryCode()) {
                resContainerPrivacy.setGeolocation(element.getCountryCode());
                this.outputPort.send(element);
            }
            break;
        }
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ResourceContainerPrivacy(org.palladiosimulator.pcm.resourceenvironmentprivacy.ResourceContainerPrivacy) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

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