Search in sources :

Example 1 with IContainerManagementSinkStage

use of org.iobserve.analysis.feature.IContainerManagementSinkStage in project iobserve-analysis by research-iobserve.

the class AnalysisConfiguration method createContainerManagementSink.

/**
 * Create sinks for container management visualization.
 *
 * @param configuration
 *            configuration object
 * @param resourceEnvironmentModelResource
 * @param allocationModelResource
 * @param systemModelResource
 *
 * @throws ConfigurationException
 *             when configuration fails
 */
private void createContainerManagementSink(final kieker.common.configuration.Configuration configuration, final Neo4JModelResource<ResourceEnvironment> resourceEnvironmentModelResource, final Neo4JModelResource<System> systemModelResource, final Neo4JModelResource<Allocation> allocationModelResource) throws ConfigurationException {
    final String[] containerManagementSinks = configuration.getStringArrayProperty(ConfigurationKeys.CONTAINER_MANAGEMENT_SINK, AnalysisConfiguration.DELIMETER);
    if (containerManagementSinks.length == 1) {
        final IContainerManagementSinkStage containerManagementSinksStage = InstantiationFactory.createWithConfiguration(IContainerManagementSinkStage.class, containerManagementSinks[0], configuration);
        /**
         * connect ports.
         */
        this.connectPorts(this.allocationStage.getAllocationNotifyOutputPort(), containerManagementSinksStage.getAllocationInputPort());
        this.connectPorts(this.deallocationStage.getDeallocationNotifyOutputPort(), containerManagementSinksStage.getDeallocationInputPort());
        this.connectPorts(this.deploymentStage.getDeployedOutputPort(), containerManagementSinksStage.getDeployedInputPort());
        this.connectPorts(this.undeploymentStage.getUndeployedOutputPort(), containerManagementSinksStage.getUndeployedInputPort());
    } else if (containerManagementSinks.length > 1) {
        /**
         * In case of multiple outputs, we require distributors.
         */
        final Distributor<ResourceContainer> allocationDistributor = new Distributor<>(new CopyByReferenceStrategy());
        final Distributor<ResourceContainer> deallocationDistributor = new Distributor<>(new CopyByReferenceStrategy());
        final Distributor<PCMDeployedEvent> deploymentDistributor = new Distributor<>(new CopyByReferenceStrategy());
        final Distributor<PCMUndeployedEvent> undeploymentDistributor = new Distributor<>(new CopyByReferenceStrategy());
        /**
         * link distributor to container management.
         */
        this.connectPorts(this.allocationStage.getAllocationNotifyOutputPort(), allocationDistributor.getInputPort());
        this.connectPorts(this.deallocationStage.getDeallocationNotifyOutputPort(), deallocationDistributor.getInputPort());
        this.connectPorts(this.deploymentStage.getDeployedOutputPort(), deploymentDistributor.getInputPort());
        this.connectPorts(this.undeploymentStage.getUndeployedOutputPort(), undeploymentDistributor.getInputPort());
        /**
         * Create and connect sinks.
         */
        for (final String containerManagementSink : containerManagementSinks) {
            final IContainerManagementSinkStage containerManagementSinksStage = InstantiationFactory.getInstance(configuration).create(IContainerManagementSinkStage.class, containerManagementSink, IContainerManagementSinkStage.SIGNATURE, configuration, resourceEnvironmentModelResource, allocationModelResource, systemModelResource);
            /**
             * connect ports.
             */
            this.connectPorts(allocationDistributor.getNewOutputPort(), containerManagementSinksStage.getAllocationInputPort());
            this.connectPorts(deallocationDistributor.getNewOutputPort(), containerManagementSinksStage.getDeallocationInputPort());
            this.connectPorts(deploymentDistributor.getNewOutputPort(), containerManagementSinksStage.getDeployedInputPort());
            this.connectPorts(undeploymentDistributor.getNewOutputPort(), containerManagementSinksStage.getUndeployedInputPort());
        }
    } else {
        AnalysisConfiguration.LOGGER.warn("No container management sinks specified. Therefore, deployment and allocation changes will not be communicated.");
    }
}
Also used : Distributor(teetime.stage.basic.distributor.Distributor) CopyByReferenceStrategy(teetime.stage.basic.distributor.strategy.CopyByReferenceStrategy) IContainerManagementSinkStage(org.iobserve.analysis.feature.IContainerManagementSinkStage)

Aggregations

IContainerManagementSinkStage (org.iobserve.analysis.feature.IContainerManagementSinkStage)1 Distributor (teetime.stage.basic.distributor.Distributor)1 CopyByReferenceStrategy (teetime.stage.basic.distributor.strategy.CopyByReferenceStrategy)1