Esempio n. 1
0
        public LogSinkOp(
            LogSinkFactory factory,
            string dataFlowInstanceId,
            ConsoleOpRenderer renderer,
            string title,
            string layout,
            bool log,
            bool linefeed)
        {
            this.factory = factory;
            this.dataFlowInstanceId = dataFlowInstanceId;
            this.renderer = renderer;
            this.title = title;
            this.layout = layout;
            this.log = log;
            this.linefeed = linefeed;

            shellPerStream = new EventBeanSPI[factory.EventTypes.Length];
            for (var i = 0; i < factory.EventTypes.Length; i++) {
                EventType eventType = factory.EventTypes[i];
                if (eventType != null) {
                    shellPerStream[i] = EventTypeUtility.GetShellForType(eventType);
                }
            }
        }
Esempio n. 2
0
        public DataFlowOpInitializeResult Initialize(DataFlowOpInitializateContext context)
        {
            if (!context.OutputPorts.IsEmpty())
            {
                throw new ArgumentException("LogSink operator does not provide an output stream");
            }

            _dataflowName       = context.DataflowName;
            _dataFlowInstanceId = context.DataflowInstanceId;

            _shellPerStream = new EventBeanSPI[context.InputPorts.Count];
            foreach (KeyValuePair <int, DataFlowOpInputPort> entry in context.InputPorts)
            {
                EventType eventType = entry.Value.TypeDesc.EventType;
                if (eventType != null)
                {
                    _shellPerStream[entry.Key] = context.StatementContext.EventAdapterService.GetShellForType(eventType);
                }
            }

            if (format == null)
            {
                _renderer = new ConsoleOpRendererSummary();
            }
            else
            {
                try
                {
                    var formatEnum = EnumHelper.Parse <LogSinkOutputFormat>(format.Trim());
                    if (formatEnum == LogSinkOutputFormat.summary)
                    {
                        _renderer = new ConsoleOpRendererSummary();
                    }
                    else
                    {
                        _renderer = new ConsoleOpRendererXmlJSon(formatEnum, context.Engine.EPRuntime);
                    }
                }
                catch (Exception ex)
                {
                    throw new ExprValidationException("Format '" + format + "' is not supported, expecting any of " + EnumHelper.GetValues <LogSinkOutputFormat>().Render());
                }
            }

            return(null);
        }