Example #1
0
 public LogicalChannelBinding(
     LogicalChannel logicalChannel,
     LogicalChannelBindingMethodDesc consumingBindingDesc,
     LogicalChannelBindingMethodDesc consumingSignalBindingDesc)
 {
     LogicalChannel             = logicalChannel;
     ConsumingBindingDesc       = consumingBindingDesc;
     ConsumingSignalBindingDesc = consumingSignalBindingDesc;
 }
        private static SignalHandler GetSignalHandler(
            int producerNum,
            object target,
            LogicalChannelBindingMethodDesc consumingSignalBindingDesc,
            ImportService importService)
        {
            if (consumingSignalBindingDesc == null) {
                return SignalHandlerDefault.INSTANCE;
            }

            if (consumingSignalBindingDesc.BindingType is LogicalChannelBindingTypePassAlong) {
                return new SignalHandlerDefaultWInvoke(target, consumingSignalBindingDesc.Method);
            }

            if (consumingSignalBindingDesc.BindingType is LogicalChannelBindingTypePassAlongWStream) {
                var streamInfo = (LogicalChannelBindingTypePassAlongWStream) consumingSignalBindingDesc.BindingType;
                return new SignalHandlerDefaultWInvokeStream(
                    target,
                    consumingSignalBindingDesc.Method,
                    streamInfo.StreamNum);
            }

            throw new IllegalStateException("Unrecognized signal binding: " + consumingSignalBindingDesc.BindingType);
        }
Example #3
0
        public static EPDataFlowInstance Instantiate(
            IContainer container,
            int agentInstanceId,
            DataflowDesc dataflow,
            EPDataFlowInstantiationOptions options)
        {
            var statementContext = dataflow.StatementContext;

            // allocate agent instance context
            var @lock = statementContext.StatementAgentInstanceLockFactory.GetStatementLock(
                statementContext.StatementName,
                statementContext.Annotations,
                statementContext.IsStatelessSelect,
                statementContext.StatementType);
            var handle = new EPStatementAgentInstanceHandle(statementContext.EpStatementHandle, agentInstanceId, @lock);
            var auditProvider = statementContext.StatementInformationals.AuditProvider;
            var instrumentationProvider = statementContext.StatementInformationals.InstrumentationProvider;
            var agentInstanceContext = new AgentInstanceContext(statementContext, handle, null, null, auditProvider, instrumentationProvider);

            // assure variables
            statementContext.VariableManagementService.SetLocalVersion();

            // instantiate operators
            var operators = InstantiateOperators(container, agentInstanceContext, options, dataflow);

            // determine binding of each channel to input methods (ports)
            IList<LogicalChannelBinding> operatorChannelBindings = new List<LogicalChannelBinding>();
            foreach (var channel in dataflow.LogicalChannels) {
                var targetClass = operators.Get(channel.ConsumingOpNum).GetType();
                var consumingMethod = FindMatchingMethod(channel.ConsumingOpPrettyPrint, targetClass, channel, false);

                LogicalChannelBindingMethodDesc onSignalMethod = null;
                if (channel.OutputPort.HasPunctuation) {
                    onSignalMethod = FindMatchingMethod(channel.ConsumingOpPrettyPrint, targetClass, channel, true);
                }

                operatorChannelBindings.Add(new LogicalChannelBinding(channel, consumingMethod, onSignalMethod));
            }

            // obtain realization
            var dataFlowSignalManager = new DataFlowSignalManager();
            var statistics = DataflowInstantiatorHelper.Realize(
                dataflow,
                operators,
                operatorChannelBindings,
                dataFlowSignalManager,
                options,
                agentInstanceContext);

            // For each GraphSource add runnable
            IList<GraphSourceRunnable> sourceRunnables = new List<GraphSourceRunnable>();
            var audit = AuditEnum.DATAFLOW_SOURCE.GetAudit(statementContext.Annotations) != null;
            foreach (var operatorEntry in operators) {
                if (!(operatorEntry.Value is DataFlowSourceOperator)) {
                    continue;
                }

                var meta = dataflow.OperatorMetadata.Get(operatorEntry.Key);

                var graphSource = (DataFlowSourceOperator) operatorEntry.Value;
                var runnable = new GraphSourceRunnable(
                    agentInstanceContext,
                    graphSource,
                    dataflow.DataflowName,
                    options.DataFlowInstanceId,
                    meta.OperatorName,
                    operatorEntry.Key,
                    meta.OperatorPrettyPrint,
                    options.ExceptionHandler,
                    audit);
                sourceRunnables.Add(runnable);

                dataFlowSignalManager.AddSignalListener(operatorEntry.Key, runnable);
            }

            return new EPDataFlowInstanceImpl(
                options.DataFlowInstanceUserObject,
                options.DataFlowInstanceId,
                statistics,
                operators,
                sourceRunnables,
                dataflow,
                agentInstanceContext,
                statistics,
                options.ParametersURIs);
        }