public EPDataFlowEmitterWrapperWStatistics( EPDataFlowEmitter facility, int producerOpNum, OperatorStatisticsProvider statisticsProvider, bool cpuStatistics) { _facility = facility; _producerOpNum = producerOpNum; _statisticsProvider = statisticsProvider; _cpuStatistics = cpuStatistics; }
public static OperatorStatisticsProvider Realize( DataflowDesc dataflow, IDictionary<int, object> operators, IList<LogicalChannelBinding> bindings, DataFlowSignalManager dataFlowSignalManager, EPDataFlowInstantiationOptions options, AgentInstanceContext agentInstanceContext) { IDictionary<int, OperatorMetadataDescriptor> operatorMetadata = dataflow.OperatorMetadata; // First pass: inject runtime context IDictionary<int, EPDataFlowEmitter> runtimeContexts = new Dictionary<int, EPDataFlowEmitter>(); OperatorStatisticsProvider statisticsProvider = null; if (options.IsOperatorStatistics) { statisticsProvider = new OperatorStatisticsProvider(operatorMetadata); } foreach (int producerOpNum in dataflow.OperatorBuildOrder) { var operatorPrettyPrint = operatorMetadata.Get(producerOpNum).OperatorPrettyPrint; if (Log.IsDebugEnabled) { Log.Debug("Generating runtime context for " + operatorPrettyPrint); } // determine the number of output streams var producingOp = operators.Get(producerOpNum); var numOutputStreams = operatorMetadata.Get(producerOpNum).NumOutputPorts; var targets = GetOperatorConsumersPerStream( numOutputStreams, producerOpNum, operators, operatorMetadata, bindings); var runtimeContext = GenerateRuntimeContext( agentInstanceContext, dataflow, options.DataFlowInstanceId, producerOpNum, operatorPrettyPrint, dataFlowSignalManager, targets, options); if (options.IsOperatorStatistics) { runtimeContext = new EPDataFlowEmitterWrapperWStatistics( runtimeContext, producerOpNum, statisticsProvider, options.IsCpuStatistics); } TypeHelper.SetFieldForAnnotation(producingOp, typeof(DataFlowContextAttribute), runtimeContext); runtimeContexts.Put(producerOpNum, runtimeContext); } // Second pass: hook punctuation such that it gets forwarded foreach (int producerOpNum in dataflow.OperatorBuildOrder) { var operatorPrettyPrint = operatorMetadata.Get(producerOpNum).OperatorPrettyPrint; if (Log.IsDebugEnabled) { Log.Debug("Handling signals for " + operatorPrettyPrint); } // determine consumers that receive punctuation ISet<int> consumingOperatorsWithPunctuation = new HashSet<int>(); foreach (var binding in bindings) { if (!binding.LogicalChannel.OutputPort.HasPunctuation || binding.LogicalChannel.OutputPort.ProducingOpNum != producerOpNum) { continue; } consumingOperatorsWithPunctuation.Add(binding.LogicalChannel.ConsumingOpNum); } // hook up a listener for each foreach (var consumerPunc in consumingOperatorsWithPunctuation) { var context = runtimeContexts.Get(consumerPunc); if (context == null) { continue; } dataFlowSignalManager.AddSignalListener( producerOpNum, new ProxyDataFlowSignalListener { ProcProcessSignal = signal => context.SubmitSignal(signal) }); } } return statisticsProvider; }