Search in sources :

Example 1 with EventConfigurationException

use of org.iobserve.analysis.EventConfigurationException 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)

Aggregations

EventConfigurationException (org.iobserve.analysis.EventConfigurationException)1 ContainerAllocationEvent (org.iobserve.common.record.ContainerAllocationEvent)1 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)1 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)1