コード例 #1
0
        /// <summary>
        /// Returns an instance of a text file reader input adapter.
        /// </summary>
        /// <param name="configInfo">Configuration passed from the query binding.</param>
        /// <param name="eventShape">Event shape requested from the query binding.</param>
        /// <param name="cepEventType">Event type expected by the bound query template.</param>
        /// <returns>An instance of a text file reader input adapter.</returns>
        public InputAdapterBase Create(TextFileReaderConfig configInfo, EventShape eventShape, CepEventType cepEventType)
        {
            InputAdapterBase adapter = default(InputAdapterBase);

            if (eventShape == EventShape.Point)
            {
                adapter = new TextFilePointInput(configInfo, cepEventType);
            }
            else if (eventShape == EventShape.Interval)
            {
                adapter = new TextFileIntervalInput(configInfo, cepEventType);
            }
            else if (eventShape == EventShape.Edge)
            {
                adapter = new TextFileEdgeInput(configInfo, cepEventType);
            }
            else
            {
                throw new ArgumentException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              "TextFileReaderFactory cannot instantiate adapter with event shape {0}",
                              eventShape.ToString()));
            }

            return(adapter);
        }
コード例 #2
0
        /// <summary>
        /// Returns an instance of a text file writer output adapter.
        /// </summary>
        /// <param name="configInfo">Configuration passed from the query binding.</param>
        /// <param name="eventShape">Event shape requested from the query binding.</param>
        /// <param name="cepEventType">Event type produced by the bound query template.</param>
        /// <returns>An instance of a text file writer output adapter.</returns>
        public OutputAdapterBase Create(TextFileWriterConfig configInfo, EventShape eventShape, CepEventType cepEventType)
        {
            OutputAdapterBase adapter = default(OutputAdapterBase);

            switch (eventShape)
            {
            case EventShape.Point:
                adapter = new TextFilePointOutput(configInfo, cepEventType);
                break;

            case EventShape.Interval:
                adapter = new TextFileIntervalOutput(configInfo, cepEventType);
                break;

            case EventShape.Edge:
                adapter = new TextFileEdgeOutput(configInfo, cepEventType);
                break;

            default:
                throw new ArgumentException(string.Format(
                                                CultureInfo.InvariantCulture,
                                                "TextFileWriterFactory cannot instantiate adapter with event shape {0}",
                                                eventShape.ToString()));
            }

            return(adapter);
        }
コード例 #3
0
 public InputAdapterBase Create <TPayload>(TwitterConfig config, EventShape eventShape)
 {
     // Only support the point event model
     if (eventShape == EventShape.Point)
     {
         return(new TwitterInput(config));
     }
     else
     {
         return(default(InputAdapterBase));
     }
 }
コード例 #4
0
 public OutputAdapterBase Create <TPayload>(PayloadOutputConfig config, EventShape eventShape)
 {
     // Only support the point event model
     if (eventShape == EventShape.Point)
     {
         return(new OutputAdapterFromFile(config));
     }
     else
     {
         return(default(OutputAdapterBase));
     }
 }
コード例 #5
0
        /// <summary>
        /// Declaratively advance application time (i.e. inject CTI's)
        /// </summary>
        /// <returns></returns>
        public AdapterAdvanceTimeSettings DeclareAdvanceTimeProperties <TPayload>(
            SimulatedInputAdapterConfig configInfo, EventShape eventShape)
        {
            trace.LogMsg(TraceEventType.Information,
                         "Advance time policy: CTI f {0}, CTI offset {1}, time policy: {2}",
                         configInfo.CtiFrequency, TimeSpan.FromTicks(-1), AdvanceTimePolicy.Adjust);

            var timeGenSettings = new AdvanceTimeGenerationSettings(configInfo.CtiFrequency,
                                                                    TimeSpan.FromTicks(-1), true);

            return(new AdapterAdvanceTimeSettings(timeGenSettings, AdvanceTimePolicy.Adjust));
        }
コード例 #6
0
        public OutputAdapterBase Create(TracerConfig configInfo, EventShape eventShape, CepEventType cepEventType)
        {
            OutputAdapterBase adapter = default(OutputAdapterBase);

            switch (eventShape)
            {
            case EventShape.Point:
                adapter = new TracerPointOutputAdapter(configInfo, cepEventType);
                break;
            }

            return(adapter);
        }
コード例 #7
0
        private TestDataProducer CreateProducer(TestDataInputConfig config, EventShape eventShape)
        {
            switch (eventShape)
            {
            case EventShape.Point:
                //Create the publisher.
                return(new TestDataProducer(config));

            default:
                throw new ArgumentException(string.Format(
                                                System.Globalization.CultureInfo.InvariantCulture,
                                                "TestDataInputFactory cannot instantiate adapter with event shape {0}",
                                                eventShape.ToString()));
            }
        }
コード例 #8
0
        public OutputAdapterBase Create <TPayload>(ConsoleOutputConfig configInfo, EventShape eventShape)
        {
            switch (eventShape)
            {
            case EventShape.Point:
                return(new ObserverTypedPointOutputAdapter <TPayload>(CreatePointObserverSink <TPayload>(configInfo)));

            case EventShape.Interval:
                return(new ObserverTypedIntervalOutputAdapter <TPayload>(CreateIntervalObserverSink <TPayload>(configInfo)));

            case EventShape.Edge:
                return(new ObserverTypedEdgeOutputAdapter <TPayload>(CreateEdgeObserverSink <TPayload>(configInfo)));

            default:
                throw new ArgumentOutOfRangeException("eventShape");
            }
        }
コード例 #9
0
        public InputAdapterBase Create <TPayload>(GeneratorConfig configInfo, EventShape eventShape)
        {
            switch (eventShape)
            {
            case EventShape.Edge:
                return(new GeneratorAdapterEdge(configInfo));

            case EventShape.Interval:
                return(new GeneratorAdapterInterval(configInfo));

            case EventShape.Point:
                return(new GeneratorAdapterPoint(configInfo));

            default:
                throw new ArgumentException("Unknown event shape");
            }
        }
コード例 #10
0
        public InputAdapterBase Create(WcfAdapterConfig configInfo, EventShape eventShape, CepEventType cepEventType)
        {
            InputAdapterBase inputAdapter;

            switch (eventShape)
            {
            case EventShape.Point:
            {
                inputAdapter = new WcfPointInputAdapter(cepEventType, configInfo);
            }
            break;

            default:
                throw new NotImplementedException();
            }

            return(inputAdapter);
        }
コード例 #11
0
        public OutputAdapterBase Create(Uri configInfo, EventShape eventShape, CepEventType cepEventType)
        {
            OutputAdapterBase outputAdapter;

            switch (eventShape)
            {
            case EventShape.Point:
            {
                outputAdapter = new WcfPointOutputAdapter(cepEventType, configInfo);
            }
            break;

            default:
                throw new NotImplementedException();
            }

            return(outputAdapter);
        }
コード例 #12
0
 public OutputAdapterBase Create <TPayload>(StackerConfig configInfo, EventShape eventShape)
 {
     if (eventShape == EventShape.Point)
     {
         return(new StackerPointOutput <TPayload>(configInfo));
     }
     else if (eventShape == EventShape.Interval)
     {
         return(new StackerIntervalOutput <TPayload>(configInfo));
     }
     else if (eventShape == EventShape.Edge)
     {
         return(new StackerEdgeOutput <TPayload>(configInfo));
     }
     else
     {
         return(default(OutputAdapterBase));
     }
 }
コード例 #13
0
 public OutputAdapterBase Create <TPayload>(AzureDbConfig configInfo, EventShape eventShape)
 {
     if (eventShape == EventShape.Point)
     {
         return(new AzureDbPointOutput <TPayload>(configInfo));
     }
     else if (eventShape == EventShape.Interval)
     {
         throw new NotImplementedException("Adapters for other event shapes haven't been implemented");
     }
     else if (eventShape == EventShape.Edge)
     {
         throw new NotImplementedException("Adapters for other event shapes haven't been implemented");
     }
     else
     {
         return(default(OutputAdapterBase));
     }
 }
コード例 #14
0
        public OutputAdapterBase Create(SqlOutputConfig configInfo, EventShape eventShape, CepEventType cepEventType)
        {
            OutputAdapterBase adapter = default(OutputAdapterBase);

            switch (eventShape)
            {
            case EventShape.Point:
                adapter = new SqlOutputPoint(configInfo, cepEventType);
                break;

            case EventShape.Interval:
                adapter = new SqlOutputInterval(configInfo, cepEventType);
                break;

            default:
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Unknown event shape {0}", eventShape.ToString()));
            }

            return(adapter);
        }
コード例 #15
0
 public InputAdapterBase Create <TPayload>(TwitterConfig config, EventShape eventShape)
 {
     // Only support the point event model
     if (eventShape == EventShape.Point)
     {
         return(new TwitterInput(config));
     }
     else if (eventShape == EventShape.Interval)
     {
         throw new NotImplementedException("Adapters for other event shapes haven't been implemented");
     }
     else if (eventShape == EventShape.Edge)
     {
         throw new NotImplementedException("Adapters for other event shapes haven't been implemented");
     }
     else
     {
         return(default(InputAdapterBase));
     }
 }
コード例 #16
0
        /// <summary>
        /// Create an instance of a console output adapter that dumps received
        /// events to the .NET Debug or Console window.
        /// </summary>
        public OutputAdapterBase Create(ConsoleAdapterConfig configInfo,
                                        EventShape eventShape, CepEventType cepEventType)
        {
            OutputAdapterBase ret = default(OutputAdapterBase);

            switch (eventShape)
            {
            case EventShape.Point:
                ret = new ConsolePointOutputAdapter(configInfo, cepEventType);
                break;

            case EventShape.Interval:
                ret = new ConsoleIntervalOutputAdapter(configInfo, cepEventType);
                break;

            case EventShape.Edge:
                ret = new ConsoleEdgeOutputAdapter(configInfo, cepEventType);
                break;
            }
            return(ret);
        }
コード例 #17
0
        /// <summary>
        /// Based on a configuration and an event type generate an adapter reference
        /// </summary>
        public InputAdapterBase Create <TPayload>(SimulatedInputAdapterConfig configInfo,
                                                  EventShape eventShape)
        {
            InputAdapterBase ret = default(InputAdapterBase);

            switch (eventShape)
            {
            case EventShape.Point:
                ret = new SimulatedInputPointAdapter <TPayload>(configInfo);
                break;

            case EventShape.Interval:
                ret = new SimulatedInputIntervalAdapter <TPayload>(configInfo);
                break;

            case EventShape.Edge:
                ret = new SimulatedInputEdgeAdapter <TPayload>(configInfo);
                break;
            }

            return(ret);
        }
コード例 #18
0
 public AdapterAdvanceTimeSettings DeclareAdvanceTimeProperties(WcfAdapterConfig configInfo, EventShape eventShape, CepEventType cepEventType)
 {
     return(new AdapterAdvanceTimeSettings(
                new AdvanceTimeGenerationSettings(1, TimeSpan.FromTicks(-1)),
                AdvanceTimePolicy.Drop));
 }
コード例 #19
0
        public IObservable <StreamInputEvent <TPayload> > CreateObservableSource <TPayload>(object config, EventShape eventShape)
        {
            //Check the payload type.
            CheckPayloadType <TPayload>();
            //Check config class for the proper type.
            TestDataInputConfig typedConfig = config as TestDataInputConfig;

            if (typedConfig == null)
            {
                //Invalid cast
                throw new ArgumentException("Configuration class must be of type TestDataInputConfig");
            }
            return((IObservable <StreamInputEvent <TPayload> >)CreateProducer(typedConfig, eventShape));
        }
        /// <summary>
        /// Create a ReplayablePointCsvInputAdapter without replay: start at the beginning.
        /// </summary>
        /// <typeparam name="TPayload">Ignored: this always produced XYPayloads</typeparam>
        /// <param name="configInfo">The config info.</param>
        /// <param name="eventShape">The event shape; must be Point.</param>
        /// <returns>The new adapter.</returns>
        public InputAdapterBase Create <TPayload>(ReplayablePointCsvInputAdapterConfig configInfo, EventShape eventShape)
        {
            // We only support points.
            if (eventShape != EventShape.Point)
            {
                throw new ArgumentException("Got event shape = " + eventShape + "; only Point is supported.");
            }

            return(new ReplayablePointCsvInputAdapter(configInfo.File, configInfo.Interval));
        }
コード例 #21
0
        public static IRemoteStreamableBinding ToBinding <TPayload>(this IQStreamable <TPayload> stream, Application cepApplication,
                                                                    Type consumerFactoryType, object configInfo, EventShape eventShape)
        {
            var factory = Activator.CreateInstance(consumerFactoryType) as ISinkFactory;

            if (factory == null)
            {
                throw new ArgumentException("Factory cannot be created or does not implement ISinkFactory");
            }

            switch (eventShape)
            {
            case EventShape.Point:
                var pointObserver = cepApplication.DefineObserver(() =>
                                                                  factory.CreatePointObserverSink <TPayload>(configInfo));
                return(stream.Bind(pointObserver));

            case EventShape.Interval:
                var intervalObserver = cepApplication.DefineObserver(() =>
                                                                     factory.CreateIntervalObserverSink <TPayload>(configInfo));
                return(stream.Bind(intervalObserver));

            case EventShape.Edge:
                var edgeObserver = cepApplication.DefineObserver(() =>
                                                                 factory.CreateEdgeObserverSink <TPayload>(configInfo));
                return(stream.Bind(edgeObserver));

            default:
                throw new ArgumentOutOfRangeException("eventShape");
            }
        }
コード例 #22
0
 public AdapterAdvanceTimeSettings DeclareAdvanceTimeProperties <TPayload>(GeneratorConfig configInfo, EventShape eventShape)
 {
     // Inject a CTI one tick _after_ (negative delay) each event and
     // drop violating events. This ensures maximum liveliness, since
     // each event is immediately committed.  Note that this will drop
     // duplicate events (events collocated in time) when enqueued by
     // the input adapter.
     return(new AdapterAdvanceTimeSettings(
                new AdvanceTimeGenerationSettings(configInfo.CtiFrequency, TimeSpan.FromTicks(-1)),
                AdvanceTimePolicy.Drop));
 }
コード例 #23
0
 public InputAdapterBase Create <TPayload>(InConfig configInfo, EventShape eventShape)
 {
     return(new InAdapter(configInfo));
 }
コード例 #24
0
        public static IQbservable <StreamInputEvent <TPayload> > CreateObservable(Application cepApplication,
                                                                                  Type sourceFactoryType, object configInfo, EventShape eventShape)
        {
            string entityName = "Observable:" + typeof(TPayload).FullName;

            if (_observable == null)
            {
                //Check the application.
                if (cepApplication.Entities.ContainsKey(entityName))
                {
                    _observable = cepApplication.GetObservable <Type, object, EventShape, StreamInputEvent <TPayload> >(entityName);
                }
                else
                {
                    //Define and deploy.
                    _observable = cepApplication.DefineObservable(
                        (Type t, object c, EventShape e) => InstantiateObservable(t, c, e));
                    _observable.Deploy(entityName);
                }
            }
            return(_observable.Invoke(sourceFactoryType, configInfo, eventShape));
        }
コード例 #25
0
        private static void BindAndRunQuery <TPayload>(string queryName, CepStream <TPayload> queryStream, EventShape outputEventShape, List <string> inputFields, List <string> outputFields)
        {
            var inputConfig = new CsvInputConfig
            {
                InputFileName        = @"..\..\..\TollInput.txt",
                Delimiter            = new char[] { ',' },
                BufferSize           = 4096,
                CtiFrequency         = 1,
                CultureName          = "en-US",
                Fields               = inputFields,
                NonPayloadFieldCount = 2,
                StartTimePos         = 1,
                EndTimePos           = 2
            };

            // The adapter recognizes empty filename as a write to console.
            var outputConfig = new CsvOutputConfig
            {
                OutputFileName = string.Empty,
                Delimiter      = new string[] { "\t" },
                CultureName    = "en-US",
                Fields         = outputFields
            };

            // Note - Please change the instance name to the one you have chosen during installation
            using (var server = Server.Create("Default"))
            {
                Application application = server.CreateApplication("TollStationApp");

                // set up input and output adapters
                InputAdapter  inputAdapter  = application.CreateInputAdapter <CsvInputFactory>("input", "Csv Input Source");
                OutputAdapter outputAdapter = application.CreateOutputAdapter <CsvOutputFactory>("output", "Csv Output");

                // set up the query template
                QueryTemplate queryTemplate = application.CreateQueryTemplate("QueryTemplate", string.Empty, queryStream);

                // set up advance time settings to enqueue CTIs
                var advanceTimeGenerationSettings = new AdvanceTimeGenerationSettings(inputConfig.CtiFrequency, TimeSpan.Zero, true);
                var advanceTimeSettings           = new AdvanceTimeSettings(advanceTimeGenerationSettings, null, AdvanceTimePolicy.Adjust);

                // Bind query template to input and output streams
                QueryBinder queryBinder = new QueryBinder(queryTemplate);
                queryBinder.BindProducer <TollReading>("TollStream", inputAdapter, inputConfig, EventShape.Interval, advanceTimeSettings);
                queryBinder.AddConsumer("outputStream", outputAdapter, outputConfig, outputEventShape, StreamEventOrder.FullyOrdered);

                // Create a runnable query by binding the query template to the input stream of interval events,
                // and to an output stream of fully ordered point events (through an output adapter instantiated
                // from the output factory class)
                Query query = application.CreateQuery(queryName, "Hello Toll Query", queryBinder);

                RunQuery(query);
            }
        }
コード例 #26
0
 public InputAdapterBase Create <TPayload>(TestDataInputConfig configInfo, EventShape eventShape)
 {
     CheckPayloadType <TPayload>();
     return(new ObservableTypedPointInputAdapter <TestDataEvent, TestDataInputConfig>(
                CreateProducer(configInfo, eventShape)));
 }
コード例 #27
0
        public static IQStreamable <TPayload> Create(Application cepApplication, Type sourceFactoryType, object configInfo, EventShape eventShape, AdvanceTimeSettings advanceTimeSettings)
        {
            var observable = CreateObservable(cepApplication, sourceFactoryType, configInfo, eventShape);

            switch (eventShape)
            {
            case EventShape.Point:
                return(observable.ToPointStreamable(e => e.GetPointEvent(), advanceTimeSettings));

            case EventShape.Interval:
                return(observable.ToIntervalStreamable(e => e.GetIntervalEvent(), advanceTimeSettings));

            case EventShape.Edge:
                return(observable.ToEdgeStreamable(e => e.GetEdgeEvent(), advanceTimeSettings));

            default:
                throw new ArgumentOutOfRangeException("eventShape");
            }
        }
コード例 #28
0
        private static IObservable <StreamInputEvent <TPayload> > InstantiateObservable(Type sourceFactoryType, object configInfo, EventShape eventShape)
        {
            var sourceFactory = Activator.CreateInstance(sourceFactoryType) as ISourceFactory;

            if (sourceFactory == null)
            {
                throw new ArgumentException("Specified type is not a source factory.");
            }
            return(sourceFactory.CreateObservableSource <TPayload>(configInfo, eventShape));
        }
コード例 #29
0
 public static IQStreamable <TPayload> Create(Application cepApplication, Type sourceFactoryType, object configInfo, EventShape eventShape)
 {
     return(Create(cepApplication, sourceFactoryType, configInfo, eventShape, null));
 }
コード例 #30
0
 public OutputAdapterBase Create <TPayload>(OutConfig configInfo, EventShape eventShape)
 {
     return(new OutAdapter(configInfo));
 }