public InsertRunnable(
     EPRuntime runtime,
     int numInserts)
 {
     this.runtime = runtime;
     this.numInserts = numInserts;
 }
Exemplo n.º 2
0
        private void RunAssertionSensorPerEvent(EPServiceProvider epService)
        {
            string stmtString =
                "SELECT irstream * " +
                "FROM\n " +
                typeof(SupportSensorEvent).FullName + "#groupwin(type)#time(1 hour)#unique(device)#sort(1, measurement desc) as high ";

            EPStatement stmt         = epService.EPAdministrator.CreateEPL(stmtString);
            var         testListener = new SupportUpdateListener();

            stmt.Events += testListener.Update;

            EPRuntime runtime = epService.EPRuntime;

            var eventOne = new SupportSensorEvent(1, "Temperature", "Device1", 5.0, 96.5);

            runtime.SendEvent(eventOne);
            EPAssertionUtil.AssertUnderlyingPerRow(testListener.AssertInvokedAndReset(), new object[] { eventOne }, null);

            var eventTwo = new SupportSensorEvent(2, "Temperature", "Device2", 7.0, 98.5);

            runtime.SendEvent(eventTwo);
            EPAssertionUtil.AssertUnderlyingPerRow(testListener.AssertInvokedAndReset(), new object[] { eventTwo }, new object[] { eventOne });

            var eventThree = new SupportSensorEvent(3, "Temperature", "Device2", 4.0, 99.5);

            runtime.SendEvent(eventThree);
            EPAssertionUtil.AssertUnderlyingPerRow(testListener.AssertInvokedAndReset(), new object[] { eventThree }, new object[] { eventTwo });

            SupportSensorEvent theEvent = (SupportSensorEvent)stmt.First().Underlying;

            Assert.AreEqual(3, theEvent.Id);

            stmt.Dispose();
        }
 public FilterRunnable(
     EPRuntime runtime,
     int numEvents)
 {
     this.runtime = runtime;
     this.numEvents = numEvents;
 }
Exemplo n.º 4
0
        public static EPStatement Create(EPRuntime runtime)
        {
            var stmt = "insert into TicksPerSecond " +
                       "select Feed as feed, count(*) as cnt from MarketDataEvent.win:time_batch(1 sec) group by Feed";

            return(runtime.DeployStatement(stmt));
        }
Exemplo n.º 5
0
 public StmtNamedWindowMergeCallable(
     EPRuntime runtime,
     int numEvents)
 {
     this.runtime = (EPEventServiceSPI) runtime.EventService;
     this.numEvents = numEvents;
 }
Exemplo n.º 6
0
        public void SetUp()
        {
            _container = SupportContainer.Reset();

            _propertyTypes = new Dictionary<String, Object>();
            _propertyTypes.Put("MyInt", typeof(int?));
            _propertyTypes.Put("MyDouble", typeof(double?));
            _propertyTypes.Put("MyString", typeof(String));

            _eventTypeName = "mapEvent";
            var configuration = new Configuration(_container);
            configuration.Runtime.Threading.IsInternalTimerEnabled = false;
            configuration.Common.AddEventType(_eventTypeName, _propertyTypes);
            configuration.Common.AddEventType("myNonMapEvent", typeof(Type).FullName);

            _runtime = EPRuntimeProvider.GetRuntime("CSVProvider", configuration);
            _runtime.Initialize();

            var statementText = "select * from mapEvent#length(5)";
            var statement = CompileDeploy(_runtime, statementText).Statements[0];

            _listener = new SupportUpdateListener();
            statement.Events += _listener.Update;

            // Set the clock to 0
            _currentTime = 0;
            SendTimeEvent(0);

            _propertyOrderNoTimestamps = new[] {"MyInt", "MyDouble", "MyString"};
            _propertyOrderTimestamps = new[] {"timestamp", "MyInt", "MyDouble", "MyString"};
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            _container = SupportContainer.Reset();

            IDictionary <String, Object> propertyTypes = new LinkedHashMap <String, Object>();

            propertyTypes.Put("myInt", typeof(int));
            propertyTypes.Put("myDouble", typeof(double?));
            propertyTypes.Put("myString", typeof(String));

            _eventTypeName = "mapEvent";
            var configuration = new Configuration(_container);

            configuration.Runtime.Threading.IsInternalTimerEnabled = false;
            configuration.Common.AddEventType(_eventTypeName, propertyTypes);

            _runtime = EPRuntimeProvider.GetRuntime("Adapter", configuration);
            _runtime.Initialize();

            var statementText = "select * from mapEvent#length(5)";
            var statement     = CompileUtil.CompileDeploy(_runtime, statementText).Statements[0];

            _listener         = new SupportUpdateListener();
            statement.Events += _listener.Update;

            // Set the clock to 0
            _currentTime = 0;
            SendTimeEvent(0);

            _coordinator = new AdapterCoordinatorImpl(_runtime, true);

            _propertyOrderNoTimestamp = new[] { "myInt", "myDouble", "myString" };
            var propertyOrderTimestamp = new[] { "timestamp", "myInt", "myDouble", "myString" };

            // A CSVPlayer for a file with timestamps, not looping
            _timestampsNotLooping = new CSVInputAdapterSpec(new AdapterInputSource(_container, "regression/timestampOne.csv"), _eventTypeName);
            _timestampsNotLooping.IsUsingEngineThread = true;
            _timestampsNotLooping.PropertyOrder       = propertyOrderTimestamp;
            _timestampsNotLooping.TimestampColumn     = "timestamp";

            // A CSVAdapter for a file with timestamps, looping
            _timestampsLooping                     = new CSVInputAdapterSpec(new AdapterInputSource(_container, "regression/timestampTwo.csv"), _eventTypeName);
            _timestampsLooping.IsLooping           = true;
            _timestampsLooping.IsUsingEngineThread = true;
            _timestampsLooping.PropertyOrder       = propertyOrderTimestamp;
            _timestampsLooping.TimestampColumn     = "timestamp";

            // A CSVAdapter that sends 10 events per sec, not looping
            _noTimestampsNotLooping = new CSVInputAdapterSpec(new AdapterInputSource(_container, "regression/noTimestampOne.csv"), _eventTypeName);
            _noTimestampsNotLooping.EventsPerSec        = 10;
            _noTimestampsNotLooping.PropertyOrder       = _propertyOrderNoTimestamp;
            _noTimestampsNotLooping.IsUsingEngineThread = true;

            // A CSVAdapter that sends 5 events per sec, looping
            _noTimestampsLooping = new CSVInputAdapterSpec(new AdapterInputSource(_container, "regression/noTimestampTwo.csv"), _eventTypeName);
            _noTimestampsLooping.EventsPerSec        = 5;
            _noTimestampsLooping.IsLooping           = true;
            _noTimestampsLooping.PropertyOrder       = _propertyOrderNoTimestamp;
            _noTimestampsLooping.IsUsingEngineThread = true;
        }
Exemplo n.º 8
0
        public void TestEngineThread1PerSec()
        {
            _runtime = EPRuntimeProvider.GetRuntime("testExistingTypeNoOptions", MakeConfig("TypeA"));
            _runtime.Initialize();

            var stmt     = CompileDeploy(_runtime, "select symbol, price, volume from TypeA#length(100)").Statements[0];
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            var spec = new CSVInputAdapterSpec(new AdapterInputSource(_container, CSV_FILENAME_ONELINE_TRADE_MULTIPLE), "TypeA");

            spec.EventsPerSec        = 1;
            spec.IsUsingEngineThread = true;

            InputAdapter inputAdapter = new CSVInputAdapter(_runtime, spec);

            inputAdapter.Start();

            Thread.Sleep(1500);
            Assert.AreEqual(1, listener.GetNewDataList().Count);
            listener.Reset();
            Thread.Sleep(300);
            Assert.AreEqual(0, listener.GetNewDataList().Count);

            Thread.Sleep(2000);
            Assert.IsTrue(listener.GetNewDataList().Count >= 2);
        }
Exemplo n.º 9
0
        public void TestDynamicType()
        {
            var spec = new CSVInputAdapterSpec(
                new AdapterInputSource(_container, CSV_FILENAME_ONELINE_TRADE), "TypeB");

            var config = new Configuration(_container);

            config.Runtime.Threading.IsInternalTimerEnabled = false;
            _runtime = EPRuntimeProvider.GetDefaultRuntime(config);
            _runtime.Initialize();

            CompileDeploy(_runtime, "@public @buseventtype create schema TypeB(symbol string, price string, volume string)");

            InputAdapter feed = new CSVInputAdapter(_runtime, spec);

            var stmt     = CompileDeploy(_runtime, "select symbol, price, volume from TypeB#length(100)").Statements[0];
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            Assert.AreEqual(typeof(string), stmt.EventType.GetPropertyType("symbol"));
            Assert.AreEqual(typeof(string), stmt.EventType.GetPropertyType("price"));
            Assert.AreEqual(typeof(string), stmt.EventType.GetPropertyType("volume"));

            feed.Start();
            Assert.AreEqual(1, listener.GetNewDataList().Count);
        }
Exemplo n.º 10
0
 public UpdateEventArgs(
     EPRuntime runtime,
     EPStatement statement)
 {
     Runtime   = runtime;
     Statement = statement;
 }
Exemplo n.º 11
0
 public StatelessRunnable(
     EPRuntime runtime,
     int numRepeats)
 {
     this.runtime = runtime;
     this.numRepeats = numRepeats;
 }
        private SupportCallEvent SendEvent(EPRuntime runtime, long callId, string source, string destination, long startTime, long endTime)
        {
            var theEvent = new SupportCallEvent(callId, source, destination, startTime, endTime);

            runtime.SendEvent(theEvent);
            return(theEvent);
        }
Exemplo n.º 13
0
        private void SendTimer(long time, EPServiceProvider epService)
        {
            var       theEvent = new CurrentTimeEvent(time);
            EPRuntime runtime  = epService.EPRuntime;

            runtime.SendEvent(theEvent);
        }
Exemplo n.º 14
0
        public void TestSensorPerEvent()
        {
            String stmtString =
                "SELECT irstream * " +
                "FROM\n " +
                typeof(SupportSensorEvent).FullName + "#groupwin(type)#time(1 hour)#unique(device)#sort(1, measurement desc) as high ";

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtString);

            stmt.Events += _testListener.Update;

            EPRuntime runtime = _epService.EPRuntime;

            SupportSensorEvent eventOne = new SupportSensorEvent(1, "Temperature", "Device1", 5.0, 96.5);

            runtime.SendEvent(eventOne);
            EPAssertionUtil.AssertUnderlyingPerRow(_testListener.AssertInvokedAndReset(), new Object[] { eventOne }, null);

            SupportSensorEvent eventTwo = new SupportSensorEvent(2, "Temperature", "Device2", 7.0, 98.5);

            runtime.SendEvent(eventTwo);
            EPAssertionUtil.AssertUnderlyingPerRow(_testListener.AssertInvokedAndReset(), new Object[] { eventTwo }, new Object[] { eventOne });

            SupportSensorEvent eventThree = new SupportSensorEvent(3, "Temperature", "Device2", 4.0, 99.5);

            runtime.SendEvent(eventThree);
            EPAssertionUtil.AssertUnderlyingPerRow(_testListener.AssertInvokedAndReset(), new Object[] { eventThree }, new Object[] { eventTwo });

            IEnumerator <EventBean> it       = stmt.GetEnumerator();
            SupportSensorEvent      theEvent = (SupportSensorEvent)it.Advance().Underlying;

            Assert.AreEqual(3, theEvent.Id);
        }
Exemplo n.º 15
0
        public void TestTimeAccumRStream()
        {
            long startTime = 1000;

            SendTimer(startTime);
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(
                "select rstream * from " + typeof(SupportMarketDataBean).FullName +
                "#time_accum(10 sec)");

            stmt.Events += _listener.Update;
            EPRuntime engine = _epService.EPRuntime;

            SendTimer(startTime + 10000);
            Assert.IsFalse(_listener.IsInvoked);

            // some events at 10 sec
            engine.SendEvent(_events[0]);
            engine.SendEvent(_events[1]);
            engine.SendEvent(_events[2]);
            Assert.IsFalse(_listener.IsInvoked);

            // flush out of the window
            SendTimer(startTime + 20000);
            Assert.AreEqual(1, _listener.NewDataList.Count);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[0], _events[1], _events[2] }, _listener.GetNewDataListFlattened());
            _listener.Reset();
        }
Exemplo n.º 16
0
        private void RunAssertionTimeAccumRStream(EPServiceProvider epService, SupportMarketDataBean[] events)
        {
            long startTime = 1000;

            SendTimer(epService, startTime);
            EPStatement stmt = epService.EPAdministrator.CreateEPL(
                "select rstream * from " + typeof(SupportMarketDataBean).FullName +
                "#time_accum(10 sec)");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;
            EPRuntime engine = epService.EPRuntime;

            SendTimer(epService, startTime + 10000);
            Assert.IsFalse(listener.IsInvoked);

            // some events at 10 sec
            engine.SendEvent(events[0]);
            engine.SendEvent(events[1]);
            engine.SendEvent(events[2]);
            Assert.IsFalse(listener.IsInvoked);

            // flush out of the window
            SendTimer(epService, startTime + 20000);
            Assert.AreEqual(1, listener.NewDataList.Count);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[0], events[1], events[2] }, listener.GetNewDataListFlattened());
            listener.Reset();

            stmt.Dispose();
        }
Exemplo n.º 17
0
        private void SendTimer(long time)
        {
            CurrentTimeEvent theEvent = new CurrentTimeEvent(time);
            EPRuntime        runtime  = _epService.EPRuntime;

            runtime.SendEvent(theEvent);
        }
Exemplo n.º 18
0
        private void SendTimer(long timeInMSec)
        {
            var       theEvent = new CurrentTimeEvent(timeInMSec);
            EPRuntime runtime  = _epService.EPRuntime;

            runtime.SendEvent(theEvent);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes Esper and prepares event listeners.
        /// </summary>
        static void InitializeEsper()
        {
            var serviceProvider = EPServiceProviderManager.GetDefaultProvider();

            _runtime       = serviceProvider.EPRuntime;
            _administrator = serviceProvider.EPAdministrator;
            // You must tell esper about your events, failure to do so means you will be using
            // the fully qualified names of your events.  There are many ways to do that, but
            // this one is short-hand which makes the name of your event aliased to the fully
            // qualified name of your type.
            var typeDefinition = new Dictionary <string, object>
            {
                { "Symbol", typeof(string) },
                { "Price", "double" },
                { "Quantity", "int" }
            };

            _administrator.Configuration.AddEventType("TradeEvent", typeDefinition);
            // Create a statement or pattern; these are the bread and butter of esper.  This
            // method creates a statement.  You want to hang on to the statement if you intend
            // to listen directly to the results.
            var statement = _administrator.CreateEPL("select * from TradeEvent where Price > 700.0");

            // Hook up an event handler to the statement
            statement.Events += new UpdateEventHandler(HandleEvent);
        }
Exemplo n.º 20
0
        public void TestForceOutputStartEagerSum()
        {
            long startTime = 1000;

            SendTimer(startTime);

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(
                "select sum(Price) from " + typeof(SupportMarketDataBean).FullName +
                ".win:time_length_batch(10 sec, 3, 'force_update, start_eager')");

            stmt.Events += _listener.Update;
            EPRuntime engine = _epService.EPRuntime;

            Assert.IsFalse(_listener.IsInvoked);

            SendTimer(startTime + 9999);
            Assert.IsFalse(_listener.IsInvoked);

            // Send batch off
            SendTimer(startTime + 10000);
            Assert.AreEqual(null, _listener.LastNewData[0].Get("sum(Price)"));
            _listener.Reset();

            // Send batch off
            SendTimer(startTime + 20000);
            Assert.AreEqual(null, _listener.LastNewData[0].Get("sum(Price)"));
            _listener.Reset();

            engine.SendEvent(_events[11]);
            engine.SendEvent(_events[12]);
            SendTimer(startTime + 30000);
            Assert.AreEqual(23.0, _listener.LastNewData[0].Get("sum(Price)"));
            _listener.Reset();
        }
Exemplo n.º 21
0
        private void SendTimer(long timeInMSec)
        {
            CurrentTimeEvent theEvent = new CurrentTimeEvent(timeInMSec);
            EPRuntime        runtime  = _engine.EPRuntime;

            runtime.SendEvent(theEvent);
        }
Exemplo n.º 22
0
 private static void ExecuteSender(EPRuntime runtime, IEnumerable <int> values)
 {
     foreach (int value in values)
     {
         runtime.SendEvent(new SupportBean_S0(value));
     }
 }
Exemplo n.º 23
0
        public void TestTimeLengthBatchForceOutputSum()
        {
            long startTime = 1000;

            SendTimer(startTime);

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(
                "select sum(Price) from " + typeof(SupportMarketDataBean).FullName +
                ".win:time_length_batch(10 sec, 3, 'FORCE_UPDATE')");

            stmt.Events += _listener.Update;
            EPRuntime engine = _epService.EPRuntime;

            // Send 1 events in batch
            engine.SendEvent(_events[10]);
            Assert.IsFalse(_listener.IsInvoked);

            SendTimer(startTime + 10000);
            Assert.AreEqual(10.0, _listener.LastNewData[0].Get("sum(Price)"));
            _listener.Reset();

            SendTimer(startTime + 20000);
            Assert.AreEqual(null, _listener.LastNewData[0].Get("sum(Price)"));
            _listener.Reset();

            SendTimer(startTime + 30000);
            Assert.AreEqual(null, _listener.LastNewData[0].Get("sum(Price)"));
            _listener.Reset();

            SendTimer(startTime + 40000);
            Assert.AreEqual(null, _listener.LastNewData[0].Get("sum(Price)"));
            _listener.Reset();
        }
Exemplo n.º 24
0
        public void TestReadWritePropsBean()
        {
            var configuration = new Configuration(_container);

            configuration.Common.AddEventType("ExampleMarketDataBeanReadWrite", typeof(ExampleMarketDataBeanReadWrite));
            //configuration.Common.AddImportNamespace(typeof(FileSourceCSV));
            configuration.Common.AddImportNamespace(typeof(DefaultSupportCaptureOp));

            _runtime = EPRuntimeProvider.GetRuntime("testExistingTypeNoOptions", configuration);
            _runtime.Initialize();

            var stmt     = CompileUtil.CompileDeploy(_runtime, "select * from ExampleMarketDataBeanReadWrite#length(100)").Statements[0];
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            var inputAdapter = new CSVInputAdapter(
                _runtime,  // _baseUseCase.Runtime,
                new AdapterInputSource(_container, TestCSVAdapterUseCases.CSV_FILENAME_ONELINE_TRADE), "ReadWrite");

            inputAdapter.Start();

            Assert.AreEqual(1, listener.GetNewDataList().Count);
            var eb = listener.GetNewDataList()[0][0];

            Assert.IsTrue(typeof(ExampleMarketDataBeanReadWrite) == eb.Underlying.GetType());
            Assert.AreEqual(55.5 * 1000, eb.Get("value"));
        }
Exemplo n.º 25
0
        public static IDictionary<string, FilterItem[]> GetFilterSvcAllStmtForTypeMulti(
            EPRuntime runtime,
            string eventTypeName)
        {
            var pairs = GetFilterSvcAllStmt(runtime);

            var eventType = runtime.EventTypeService.GetBusEventType(eventTypeName);
            var typeId = eventType.Metadata.EventTypeIdPair;
            var filters = pairs.Get(typeId);

            var deployments = runtime.DeploymentService.Deployments;
            IDictionary<string, FilterItem[]> statements = new Dictionary<string, FilterItem[]>();
            foreach (var deployment in deployments) {
                var info = runtime.DeploymentService.GetDeployment(deployment);
                foreach (var statement in info.Statements) {
                    var list = filters.Get(((EPStatementSPI) statement).StatementId);
                    if (list != null) {
                        Assert.AreEqual(1, list.Count);
                        statements.Put(statement.Name, list[0]);
                    }
                }
            }

            return statements;
        }
Exemplo n.º 26
0
 public RegressionEnvironmentBase(
     Configuration configuration,
     EPRuntime runtime)
 {
     Configuration = configuration;
     Runtime = runtime;
 }
Exemplo n.º 27
0
        public void TestSum()
        {
            long startTime = 1000;

            SendTimer(startTime);
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(
                "select irstream sum(Price) as sumPrice from " + typeof(SupportMarketDataBean).FullName +
                "#time_accum(10 sec)");

            stmt.Events += _listener.Update;
            EPRuntime engine = _epService.EPRuntime;

            // 1st event
            SendTimer(startTime + 20000);
            engine.SendEvent(_events[5]);
            AssertData(_listener.LastNewData[0], 5d);
            AssertData(_listener.LastOldData[0], null);
            _listener.Reset();

            // 2nd event
            SendTimer(startTime + 25000);
            engine.SendEvent(_events[6]);
            AssertData(_listener.LastNewData[0], 11d);
            AssertData(_listener.LastOldData[0], 5d);
            _listener.Reset();

            SendTimer(startTime + 34999);
            Assert.IsFalse(_listener.IsInvoked);

            SendTimer(startTime + 35000);
            AssertData(_listener.LastNewData[0], null);
            AssertData(_listener.LastOldData[0], 11d);
            _listener.Reset();
        }
Exemplo n.º 28
0
        public void TestPreviousAndPrior()
        {
            long startTime = 1000;

            SendTimer(startTime);
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(
                "select Price, prev(1, Price) as prevPrice, prior(1, Price) as priorPrice from " + typeof(SupportMarketDataBean).FullName +
                ".win:time_length_batch(10 sec, 3)");

            stmt.Events += _listener.Update;
            EPRuntime engine = _epService.EPRuntime;

            // Send 3 events in batch
            engine.SendEvent(_events[0]);
            engine.SendEvent(_events[1]);
            Assert.IsFalse(_listener.IsInvoked);

            engine.SendEvent(_events[2]);
            Assert.AreEqual(1, _listener.NewDataList.Count);
            EventBean[] events = _listener.LastNewData;
            AssertData(events[0], 0, null, null);
            AssertData(events[1], 1.0, 0.0, 0.0);
            AssertData(events[2], 2.0, 1.0, 1.0);
            _listener.Reset();
        }
Exemplo n.º 29
0
        public static XmlDocument SendEvent(EPRuntime runtime, String xml)
        {
            XmlDocument simpleDoc = GetDocument(xml);

            runtime.SendEvent(simpleDoc);
            return(simpleDoc);
        }
Exemplo n.º 30
0
        private void RunAssertionPreviousAndPrior(EPServiceProvider epService, SupportMarketDataBean[] premades)
        {
            long startTime = 1000;

            SendTimer(epService, startTime);
            EPStatement stmt = epService.EPAdministrator.CreateEPL(
                "select price, prev(1, price) as prevPrice, prior(1, price) as priorPrice from " + typeof(SupportMarketDataBean).FullName +
                "#time_length_batch(10 sec, 3)");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;
            EPRuntime engine = epService.EPRuntime;

            // Send 3 events in batch
            engine.SendEvent(premades[0]);
            engine.SendEvent(premades[1]);
            Assert.IsFalse(listener.IsInvoked);

            engine.SendEvent(premades[2]);
            Assert.AreEqual(1, listener.NewDataList.Count);
            EventBean[] events = listener.LastNewData;
            AssertData(events[0], 0, null, null);
            AssertData(events[1], 1.0, 0.0, 0.0);
            AssertData(events[2], 2.0, 1.0, 1.0);
            listener.Reset();

            stmt.Dispose();
        }
Exemplo n.º 31
0
        private static void InitializeNesper()
        {
            nesperConf = new com.espertech.esper.client.Configuration();
            nesperConf.AddEventType(typeof(Feed));

            epService = EPServiceProviderManager.GetDefaultProvider(nesperConf);
            _runtime = epService.EPRuntime;
            mHandler = new MessageHandler();
            mHandler.UpdatePrediction += Predict;
        }
Exemplo n.º 32
0
 public void start()
 {
     Configuration config = new Configuration();
     config.AddEventType(typeof(XtiveTag));
     this._epService = EPServiceProviderManager.GetDefaultProvider(config);
     this._epRuntime = this._epService.EPRuntime;
     this._epService.EPAdministrator.CreateEPL(this._epl1);
     try
     {
         this._statement = this._epService.EPAdministrator.CreateEPL(this._epl2);
     }
     catch (Exception e1)
     { }
     try
     {
         this._statement.AddEventHandlerWithReplay(new PrefilterListener(this._form).PrefilterEventHandler);
     }
     catch (Exception e1)
     { }
 }
Exemplo n.º 33
0
        static void InitializeEsper()
        {
            // It is critical that you tell Esper what events you want to
            // listen to.  However, registering this way creates events
            // that use the class name (short form) as the event name.  If
            // you choose not to use it, you must use the full class name
            // including namespace to identify the class.
            var config = new Configuration();
            // I prefer add events using the type as a generic argument.
            config.AddEventType<TotalEvent>();

            var EPSP = EPServiceProviderManager.GetDefaultProvider(config);
            _runtime = EPSP.EPRuntime;

            var query = "select * from TotalEvent";
            var statement = EPSP.EPAdministrator.CreateEPL(query);
            Console.WriteLine(statement);
            // now the statement is listening to events, but if you want your handler to receive
            // events, you're going to have to use one of the techniques to listen to events.
            statement.Events += (sender, e) =>
            {
            #if NOT_IN_USE
                Console.WriteLine("I just received an event");
                Console.WriteLine("Sender: {0}", sender); // this will be the statement
                Console.WriteLine("NewEvents: {0}", e.NewEvents); // this is probably what you want
                foreach (var nevent in e.NewEvents)
                {
                    // when using '*' the underlying property is the object
                    var @event = nevent.Underlying as TotalEvent;
                    Console.WriteLine(@event);
                    // Assuming you just want to get properties, you can just use the indexer
                    // but you must be sure that the property case is correct.
                    String month = nevent["Month"] as String;
                    Console.WriteLine(month);
                }
            #endif
            };
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventPublisherArgs"/> class.
 /// </summary>
 /// <param name="runtime">The runtime.</param>
 /// <param name="statement">The statement.</param>
 public EventPublisherArgs(EPRuntime runtime, EPStatement statement)
 {
     Runtime = runtime;
     Statement = statement;
 }