Search in sources :

Example 6 with CopyByReferenceStrategy

use of teetime.stage.basic.distributor.strategy.CopyByReferenceStrategy 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

CopyByReferenceStrategy (teetime.stage.basic.distributor.strategy.CopyByReferenceStrategy)6 Distributor (teetime.stage.basic.distributor.Distributor)4 IFlowRecord (kieker.common.record.flow.IFlowRecord)2 TraceReconstructionCompositeStage (org.iobserve.analysis.traces.TraceReconstructionCompositeStage)2 Test (org.junit.Test)2 IDistributorStrategy (teetime.stage.basic.distributor.strategy.IDistributorStrategy)2 IContainerManagementSinkStage (org.iobserve.analysis.feature.IContainerManagementSinkStage)1 IContainerManagementSinksStage (org.iobserve.analysis.feature.IContainerManagementSinksStage)1 EventBasedTrace (org.iobserve.stages.data.trace.EventBasedTrace)1 ImplementsEventMatcher (org.iobserve.stages.general.ImplementsEventMatcher)1 EventBasedTrace (teetime.stage.trace.traceReconstruction.EventBasedTrace)1