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
* @throws NodeLookupException
* node lookup exception
* @throws DBException
* on database errors
*/
@Override
protected void execute(final IAllocationEvent event) throws MalformedURLException, UnknownObjectException, NodeLookupException, DBException {
final String service;
if (event instanceof ContainerAllocationEvent) {
service = ((ContainerAllocationEvent) event).getService();
this.logger.debug("Allocate {}", service);
} else {
this.logger.error("Unknown allocation event type {}", event.getClass());
throw new UnknownObjectException(String.format("%s is not supported by the allocation filter.", event.getClass().getCanonicalName()));
}
final ResourceEnvironment resourceEnvironment = this.resourceEnvironmentResource.getModelRootNode(ResourceEnvironment.class, ResourceenvironmentPackage.Literals.RESOURCE_ENVIRONMENT);
final Optional<ResourceContainer> resourceContainer = ResourceEnvironmentModelFactory.getResourceContainerByName(resourceEnvironment, service);
if (!resourceContainer.isPresent()) {
this.logger.debug("ResourceContainer {} has to be created.", service);
final ResourceContainer newResourceContainer = ResourceEnvironmentModelFactory.createResourceContainer(resourceEnvironment, service);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(newResourceContainer);
this.resourceEnvironmentResource.updatePartition(resourceEnvironment);
/**
* signal allocation update.
*/
this.allocationNotifyOutputPort.send(newResourceContainer);
this.allocationOutputPort.send(event);
} else {
/**
* error allocation already happened.
*/
this.logger.debug("ResourceContainer {} was available.", service);
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());
}
}
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 ResourceEnvironmentDataFactory method createProcessingResourceSpecification.
/**
* Create a {@link ProcessingResourceSpecification}.
*
* @param type
* the for the {@link ProcessingResourceSpecification}
* @return returns a {@link ProcessingResourceSpecification}
*/
public static ProcessingResourceSpecification createProcessingResourceSpecification(final ProcessingResourceType type) {
final ProcessingResourceSpecification specification = ResourceenvironmentFactory.eINSTANCE.createProcessingResourceSpecification();
specification.setActiveResourceType_ActiveResourceSpecification(type);
specification.setMTTF(42);
specification.setMTTR(42);
return specification;
}
use of org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentDataFactory method cloneContainer.
/**
* Clone a {@link ResourceContainer} in a {@link ResourceEnvironment} model.
*
* @param resourceEnvironment
* the {@link ResourceEnvironment} model
* @param existingContainerName
* the name of the existing container
* @param newContainerName
* the name of the cloned container
* @return returns the cloned {@link ResourceContainer}
*/
public static ResourceContainer cloneContainer(final ResourceEnvironment resourceEnvironment, final String existingContainerName, final String newContainerName) {
final ResourceContainer existingContainer = ResourceEnvironmentDataFactory.findContainer(resourceEnvironment, existingContainerName);
final ProcessingResourceSpecification specification = existingContainer.getActiveResourceSpecifications_ResourceContainer().get(0);
return ResourceEnvironmentDataFactory.createResourceContainer(newContainerName, specification);
}
use of org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentDataFactory method createResourceEnvironment.
/**
* Create a new resource environment model.
*
* @return returns the model.
*/
public static ResourceEnvironment createResourceEnvironment() {
final ResourceEnvironment resourceEnvironment = ResourceenvironmentFactory.eINSTANCE.createResourceEnvironment();
resourceEnvironment.setEntityName("defaultResourceEnvironment");
// Resource container types
final ProcessingResourceType client1Type = ResourceEnvironmentDataFactory.createProcessionResourceType("MacBook");
final ProcessingResourceType client2Type = ResourceEnvironmentDataFactory.createProcessionResourceType("ThinkPad");
final ProcessingResourceType client3Type = ResourceEnvironmentDataFactory.createProcessionResourceType("Mainframe");
final ProcessingResourceType orderServerType = ResourceEnvironmentDataFactory.createProcessionResourceType("Cisco Business Server");
final ProcessingResourceType paymentServerType = ResourceEnvironmentDataFactory.createProcessionResourceType("Lenovo Security Server");
// Processing resource specifications
final ProcessingResourceSpecification client1Specification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(client1Type);
final ProcessingResourceSpecification client2Specification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(client2Type);
final ProcessingResourceSpecification client3Specification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(client3Type);
final ProcessingResourceSpecification businessOrderServerSpecification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(orderServerType);
final ProcessingResourceSpecification privateOrderServerSpecification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(orderServerType);
final ProcessingResourceSpecification paymentServerSpecification = ResourceEnvironmentDataFactory.createProcessingResourceSpecification(paymentServerType);
// Resource container
final ResourceContainer client1 = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.QUERY_CONTAINER_1, client1Specification);
final ResourceContainer client2 = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.QUERY_CONTAINER_2, client2Specification);
final ResourceContainer client3 = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.QUERY_CONTAINER_3, client3Specification);
final ResourceContainer businessOrderServer = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.BUSINESS_ORDER_CONTAINER, businessOrderServerSpecification);
final ResourceContainer privateOrderServer = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.PRIVATE_ORDER_CONTAINER, privateOrderServerSpecification);
final ResourceContainer paymentServer = ResourceEnvironmentDataFactory.createResourceContainer(ResourceEnvironmentDataFactory.PAYMENT_CONTAINER, paymentServerSpecification);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(client1);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(client2);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(client3);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(businessOrderServer);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(privateOrderServer);
resourceEnvironment.getResourceContainer_ResourceEnvironment().add(paymentServer);
// linking
// Linking resource type
final CommunicationLinkResourceType lan1Type = ResourcetypeFactory.eINSTANCE.createCommunicationLinkResourceType();
lan1Type.setEntityName("Cat.7 LAN");
// Linking resource specification
final CommunicationLinkResourceSpecification lan1Specification = ResourceenvironmentFactory.eINSTANCE.createCommunicationLinkResourceSpecification();
lan1Specification.setCommunicationLinkResourceType_CommunicationLinkResourceSpecification(lan1Type);
lan1Specification.setFailureProbability(0.01);
// linking resource
final LinkingResource lan1 = ResourceenvironmentFactory.eINSTANCE.createLinkingResource();
// Linking resource
lan1.setEntityName(ResourceEnvironmentDataFactory.LAN_1);
lan1.setResourceEnvironment_LinkingResource(resourceEnvironment);
lan1.setCommunicationLinkResourceSpecifications_LinkingResource(lan1Specification);
lan1.getConnectedResourceContainers_LinkingResource().add(businessOrderServer);
lan1.getConnectedResourceContainers_LinkingResource().add(paymentServer);
resourceEnvironment.getLinkingResources__ResourceEnvironment().add(lan1);
return resourceEnvironment;
}
Aggregations