Search in sources :

Example 1 with ProcessingResourceSpecification

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

the class ResourceEnvironmentCloudFactory method createProcessingResource.

/**
 * Creates a new processing resource specification for the given resource container.
 *
 * There is no check if the container already has a processing resource.
 *
 * @param nrOfCores
 *            the number of cores the processing resource should have
 * @param processingRate
 *            the processing rate of the resource
 * @param container
 *            the container in which to create the processing resource.
 * @return a processing resource specification
 * @throws ModelHandlingErrorException
 *             when something when wrong with the model handling
 */
public static ProcessingResourceSpecification createProcessingResource(final int nrOfCores, final double processingRate, final ResourceContainer container) throws ModelHandlingErrorException {
    final ProcessingResourceSpecification processor = ResourceenvironmentFactory.eINSTANCE.createProcessingResourceSpecification();
    final PCMRandomVariable pcmProcessingRate = CoreFactory.eINSTANCE.createPCMRandomVariable();
    pcmProcessingRate.setSpecification(Double.toString(processingRate));
    processor.setActiveResourceType_ActiveResourceSpecification(IPalladioResourceRepository.INSTANCE.resources().cpu());
    processor.setId(EcoreUtil.generateUUID());
    processor.setNumberOfReplicas(nrOfCores);
    processor.setMTTF(0.0);
    processor.setMTTR(0.0);
    processor.setProcessingRate_ProcessingResourceSpecification(pcmProcessingRate);
    processor.setRequiredByContainer(true);
    processor.setResourceContainer_ProcessingResourceSpecification(container);
    processor.setSchedulingPolicy(IPalladioResourceRepository.INSTANCE.resources().policyProcessorSharing());
    return processor;
}
Also used : ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Example 2 with ProcessingResourceSpecification

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

the class AddProcessingResourceSpecification method execute.

@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final Object parameter = parameters.get(NEW_PROCESSING_RESOURCE_SPECIFICATION);
    if (parameter == null || !(parameter instanceof ProcessingResourceSpecification)) {
        return;
    }
    final ProcessingResourceSpecification processingResourceSpecification = (ProcessingResourceSpecification) parameter;
    // 1. dialog
    final ProcessingResourceType prt = getResourceType(processingResourceSpecification);
    if (prt != null)
        processingResourceSpecification.setActiveResourceType_ActiveResourceSpecification(prt);
    else
        return;
    // 2. dialog
    final PCMRandomVariable pcmrv = getProcessingRate();
    if (pcmrv != null)
        processingResourceSpecification.setProcessingRate_ProcessingResourceSpecification(pcmrv);
    else
        return;
    // 3. dialog
    final SchedulingPolicy sp = getSchedulingPolicy(processingResourceSpecification);
    if (sp != null)
        processingResourceSpecification.setSchedulingPolicy(sp);
    else
        return;
}
Also used : ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification) EObject(org.eclipse.emf.ecore.EObject) ProcessingResourceType(org.palladiosimulator.pcm.resourcetype.ProcessingResourceType) SchedulingPolicy(org.palladiosimulator.pcm.resourcetype.SchedulingPolicy) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Example 3 with ProcessingResourceSpecification

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

the class ModelHelper method createResourceContainerFromVMType.

/**
 * Creates a new resource container from a specific {@link VMType}, including an entry in the
 * cost repository.
 *
 * @param environment
 *            the resource environment in which to create the container
 * @param costRepository
 *            the cost repository in which to create the costs for the container
 * @param cloudVM
 *            the type of vm this container is an instance of
 * @param containerName
 *            the name of this container
 * @return the newly created resource container
 * @throws ModelHandlingErrorException
 *             when something when wrong with the model handling
 */
public static ResourceContainerCloud createResourceContainerFromVMType(final ResourceEnvironment environment, final CostRepository costRepository, final VMType cloudVM, final String containerName) throws ModelHandlingErrorException {
    final ResourceContainerCloud container = ResourceEnvironmentCloudFactory.createResourceContainer(environment, containerName);
    container.setId(EcoreUtil.generateUUID());
    container.setResourceEnvironment_ResourceContainer(environment);
    container.setInstanceType(cloudVM);
    // Connect container to internet
    final LinkingResource linkingResource = ModelHelper.getInternetLinkingResource(environment);
    linkingResource.getConnectedResourceContainers_LinkingResource().add(container);
    final int nrOfCores = ModelHelper.getNrOfCores(cloudVM);
    final float processingRate = ModelHelper.getProcessingRate(cloudVM);
    // Create processing resource and costs
    final ProcessingResourceSpecification processor = ResourceEnvironmentCloudFactory.createProcessingResource(nrOfCores, processingRate, container);
    container.getActiveResourceSpecifications_ResourceContainer().add(processor);
    // TODO HDD is not used by peropteryx?
    CostModelFactory.createFixedProcessingResourceCost(costRepository, 0.0, cloudVM.getPricePerHour(), processor);
    return container;
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)

Example 4 with ProcessingResourceSpecification

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

the class ModelHelper method createResourceContainerFromVMType.

/**
 * Creates a new resource container from a specific {@link VMType}, including an entry in the
 * cost repository.
 *
 * @param environment
 *            the resource environment in which to create the container
 * @param costRepository
 *            the cost repository in which to create the costs for the container
 * @param cloudVM
 *            the type of vm this container is an instance of
 * @param containerName
 *            the name of this container
 * @return the newly created resource container
 * @throws ModelHandlingErrorException
 *             model handling error
 */
public static ResourceContainerCloud createResourceContainerFromVMType(final ResourceEnvironment environment, final CostRepository costRepository, final VMType cloudVM, final String containerName) throws ModelHandlingErrorException {
    final ResourceContainerCloud container = ResourceEnvironmentCloudFactory.createResourceContainer(environment, containerName);
    container.setId(EcoreUtil.generateUUID());
    container.setResourceEnvironment_ResourceContainer(environment);
    container.setInstanceType(cloudVM);
    // Connect container to internet
    final LinkingResource linkingResource = ModelHelper.getInternetLinkingResource(environment);
    linkingResource.getConnectedResourceContainers_LinkingResource().add(container);
    final int nrOfCores = ModelHelper.getNrOfCores(cloudVM);
    final float processingRate = ModelHelper.getProcessingRate(cloudVM);
    // Create processing resource and costs
    final ProcessingResourceSpecification processor = ResourceEnvironmentCloudFactory.createProcessingResource(nrOfCores, processingRate, container);
    container.getActiveResourceSpecifications_ResourceContainer().add(processor);
    // TODO HDD is not used by peropteryx?
    CostModelFactory.createFixedProcessingResourceCost(costRepository, 0.0, cloudVM.getPricePerHour(), processor);
    return container;
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)

Example 5 with ProcessingResourceSpecification

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

the class AllocationStage method execute.

/**
 * This method is triggered for every allocation event.
 *
 * @param event
 *            one allocation event to be processed
 * @throws MalformedURLException
 *             malformed url exception
 * @throws UnknownObjectException
 *             in case the allocation event is of an unknown type
 */
@Override
protected void execute(final IAllocationEvent event) throws MalformedURLException, UnknownObjectException {
    final URL url;
    if (event instanceof ContainerAllocationEvent) {
        url = new URL(((ContainerAllocationEvent) event).getUrl());
    } else {
        throw new UnknownObjectException(event.getClass() + " is not supported by the allocation filter.");
    }
    final String hostName = url.getHost();
    final Optional<ResourceContainer> resourceContainer = ResourceEnvironmentModelFactory.getResourceContainerByName(this.resourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class), hostName);
    if (!resourceContainer.isPresent()) {
        /**
         * new provider: update the resource environment graph.
         */
        final ResourceEnvironment resourceEnvironmentModelGraph = this.resourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class);
        final ResourceContainer newResourceContainer = ResourceEnvironmentModelFactory.createResourceContainer(resourceEnvironmentModelGraph, hostName);
        resourceEnvironmentModelGraph.getResourceContainer_ResourceEnvironment().add(newResourceContainer);
        this.resourceEnvironmentModelGraphProvider.updateComponent(ResourceEnvironment.class, resourceEnvironmentModelGraph);
        /**
         * signal allocation update.
         */
        this.allocationNotifyOutputPort.send(newResourceContainer);
        this.allocationOutputPort.send(event);
    } else {
        /**
         * error allocation already happened.
         */
        this.logger.debug("ResourceContainer %s was available." + hostName);
        final List<ProcessingResourceSpecification> procResSpec = resourceContainer.get().getActiveResourceSpecifications_ResourceContainer();
        for (int i = 0; i < procResSpec.size(); i++) {
            final String nodeGroupName = procResSpec.get(i).getActiveResourceType_ActiveResourceSpecification().getEntityName();
            this.logger.debug(nodeGroupName);
        }
        /**
         * Notify with existing container.
         */
        this.allocationNotifyOutputPort.send(resourceContainer.get());
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ContainerAllocationEvent(org.iobserve.common.record.ContainerAllocationEvent) ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification) UnknownObjectException(java.rmi.activation.UnknownObjectException) URL(java.net.URL) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Aggregations

ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)6 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)3 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)2 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)2 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)2 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)2 ProcessingResourceType (org.palladiosimulator.pcm.resourcetype.ProcessingResourceType)2 URL (java.net.URL)1 UnknownObjectException (java.rmi.activation.UnknownObjectException)1 EObject (org.eclipse.emf.ecore.EObject)1 ContainerAllocationEvent (org.iobserve.common.record.ContainerAllocationEvent)1 Test (org.junit.Test)1 SchedulingPolicy (org.palladiosimulator.pcm.resourcetype.SchedulingPolicy)1