Search in sources :

Example 21 with ResourceEnvironment

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

the class ResourceContainerActionFactory method createAllocateAction.

/**
 * Create an allocate action.
 *
 * @param reDeploymentServer
 *            the node where components can be deployed on
 * @return the action
 */
public static AllocateAction createAllocateAction(final DeploymentNode reDeploymentServer) {
    final AllocateAction action = SystemadaptationFactory.eINSTANCE.createAllocateAction();
    final ResourceEnvironment redeploymentResourceEnvironment = ActionFactory.getRedeploymentModels().getResourceEnvironmentModel();
    ResourceContainerActionFactory.initializeResourceContainerAction(action, reDeploymentServer, redeploymentResourceEnvironment);
    return action;
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) AllocateAction(org.iobserve.planning.systemadaptation.AllocateAction)

Example 22 with ResourceEnvironment

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

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

the class SynthesizeAllocationEventStage method execute.

@Override
protected void execute(final PCMDeployedEvent event) throws EventConfigurationException, DBException {
    if (event.getAssemblyContext() == null) {
        throw new EventConfigurationException("Missing assembly context in PCMDeployedEvent");
    }
    this.logger.debug("event received assmeblyContext={} countryCode={} resourceContainer={} service={} url={}", event.getAssemblyContext().getEntityName(), event.getCountryCode(), event.getResourceContainer(), event.getService(), event.getUrl());
    final ResourceEnvironment resourceEnvironment = this.resourceEnvironmentModelResource.getModelRootNode(ResourceEnvironment.class, ResourceenvironmentPackage.Literals.RESOURCE_ENVIRONMENT);
    final Optional<ResourceContainer> resourceContainer = ResourceEnvironmentModelFactory.getResourceContainerByName(resourceEnvironment, event.getService());
    if (resourceContainer.isPresent()) {
        this.logger.debug("Resource container {} exists.", event.getService());
        /**
         * execution environment exists. Can deploy.
         */
        event.setResourceContainer(resourceContainer.get());
        this.deployedOutputPort.send(event);
    } else {
        this.logger.debug("Resource container {} missing, create allocation event", event.getService());
        /**
         * If the resource container with this serverName is not available, send an event to
         * TAllocation (creating the resource container) and forward the deployment event to
         * TDeployment (deploying on created resource container).
         */
        this.allocationOutputPort.send(new ContainerAllocationEvent(SynthesizeAllocationEventStage.TIME_SOURCE.getTime(), event.getService()));
        this.deployedRelayOutputPort.send(event);
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) EventConfigurationException(org.iobserve.analysis.EventConfigurationException) ContainerAllocationEvent(org.iobserve.common.record.ContainerAllocationEvent) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 24 with ResourceEnvironment

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

Example 25 with ResourceEnvironment

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

the class ModelHelper method fillResourceEnvironmentFromCloudProfile.

/**
 * Creates resource containers and their associated costs from the cloud profile given in the
 * model provider.
 *
 * The created resource containers are of the type {@link ResourceContainerCloud} and are
 * connected via an Internet linking resource
 * ({@link #getInternetLinkingResource(ResourceEnvironment)}. For every vm type in the cloud
 * profile, this method creates one resource container representing an instance of this specific
 * vm type. The model is saved after the creation of containers is completed.
 *
 * @param writeURI
 *            location where all files are stored
 * @param modelHandler
 *            the model providers with an initialized resource environment, cost model and cloud
 *            profile
 * @throws ModelHandlingErrorException
 *             model handling issue
 */
public static void fillResourceEnvironmentFromCloudProfile(final org.eclipse.emf.common.util.URI writeURI, final ModelImporter modelHandler) throws ModelHandlingErrorException {
    final ResourceEnvironment environment = modelHandler.getResourceEnvironmentModel();
    final CloudProfile cloudProfileModel = modelHandler.getCloudProfileModel();
    final CostRepository costRepositoryModel = modelHandler.getCostModel();
    for (final CloudProvider provider : cloudProfileModel.getCloudProviders()) {
        for (final CloudResourceType cloudResource : provider.getCloudResources()) {
            if (cloudResource instanceof VMType) {
                final VMType cloudVM = (VMType) cloudResource;
                ModelHelper.createResourceContainerFromVMType(environment, costRepositoryModel, cloudVM, cloudVM.getName());
            }
        }
    }
    new FileModelHandler<ResourceEnvironment>(ModelHelper.RESOURCE_SET, ResourceenvironmentPackage.eINSTANCE).save(writeURI.appendFileExtension(ResourceenvironmentPackage.eNAME), environment);
    new FileModelHandler<CostRepository>(ModelHelper.RESOURCE_SET, costPackage.eINSTANCE).save(writeURI.appendFileExtension(costPackage.eNAME), costRepositoryModel);
}
Also used : CloudProfile(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) CloudResourceType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType) 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

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