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;
}
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;
}
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;
}
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;
}
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());
}
}
Aggregations