Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
 public override void Start()
 {
     if (RunMode == RunMode.History)
     {
         Runtime.SendEvent(new CurrentTimeEvent(0));
     }
 }
Exemplo n.º 3
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.º 4
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.º 5
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.º 6
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.º 7
0
        public void TestLatencyAlert()
        {
            var services   = new[] { "s0", "s1", "s2" };
            var customers  = new[] { "c0", "c1", "c2" };
            var limitSpike = new[] { 15000L, 10000L, 10040L };

            // Set up limits for 3 services/customer combinations
            for (var i = 0; i < services.Length; i++)
            {
                var limit = new LatencyLimit(services[i], customers[i], limitSpike[i]);
                runtime.SendEvent(limit);
            }

            // Send events
            for (int i = 0; i < 100; i++)
            {
                for (int index = 0; index < services.Length; index++)
                {
                    var measurement = new OperationMeasurement(services[index], customers[index], 9950 + i, true);
                    runtime.SendEvent(measurement);
                }
            }

            // Send a new limit
            var nlimit = new LatencyLimit(services[1], customers[1], 8000);

            runtime.SendEvent(nlimit);

            // Send a new spike
            var nmeasurement = new OperationMeasurement(services[1], customers[1], 8001, true);

            runtime.SendEvent(nmeasurement);
        }
Exemplo n.º 8
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.º 9
0
        public void TestLatencyAlert()
        {
            String[]             services  = { "s0", "s1", "s2" };
            String[]             customers = { "c0", "c1", "c2" };
            OperationMeasurement measurement;

            for (int i = 0; i < 100; i++)
            {
                for (int index = 0; index < services.Length; index++)
                {
                    measurement = new OperationMeasurement(services[index], customers[index],
                                                           9950 + i, true);
                    runtime.SendEvent(measurement);
                }
            }

            // This should generate an alert
            measurement = new OperationMeasurement(services[0], customers[0], 10000, true);
            runtime.SendEvent(measurement);

            // This should generate an alert
            measurement = new OperationMeasurement(services[1], customers[1], 10001, true);
            runtime.SendEvent(measurement);

            // This should not generate an alert
            measurement = new OperationMeasurement(services[2], customers[2], 9999, true);
            runtime.SendEvent(measurement);
        }
Exemplo n.º 10
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.º 11
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.º 12
0
 private static void ExecuteSender(EPRuntime runtime, IEnumerable <int> values)
 {
     foreach (int value in values)
     {
         runtime.SendEvent(new SupportBean_S0(value));
     }
 }
Exemplo n.º 13
0
            public void Run()
            {
                var bean = new SupportBean();

                bean.LongPrimitive = DateTimeHelper.CurrentTimeMillis;
                _runtime.SendEvent(bean);
            }
Exemplo n.º 14
0
 public void Run()
 {
     for (int i = 0; i < _values.Length; i++)
     {
         _runtime.SendEvent(new SupportBean_S0(_values[i]));
     }
 }
Exemplo n.º 15
0
        private void SendTimer(long timeInMSec)
        {
            var       theEvent = new CurrentTimeEvent(timeInMSec);
            EPRuntime runtime  = _epService.EPRuntime;

            runtime.SendEvent(theEvent);
        }
Exemplo n.º 16
0
        public static XmlDocument SendEvent(EPRuntime runtime, String xml)
        {
            XmlDocument simpleDoc = GetDocument(xml);

            runtime.SendEvent(simpleDoc);
            return(simpleDoc);
        }
Exemplo n.º 17
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();
        }
        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.º 19
0
        private void SendTimer(long time)
        {
            CurrentTimeEvent theEvent = new CurrentTimeEvent(time);
            EPRuntime        runtime  = _epService.EPRuntime;

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

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

            runtime.SendEvent(theEvent);
        }
Exemplo n.º 22
0
        private void RunAssertionGroupBySumStartEager(EPServiceProvider epService)
        {
            long startTime = 1000;

            SendTimer(epService, startTime);

            EPRuntime   engine = epService.EPRuntime;
            EPStatement stmt   = epService.EPAdministrator.CreateEPL(
                "select symbol, sum(price) as s from " + typeof(SupportMarketDataBean).FullName +
                "#time_length_batch(5, 10, \"START_EAGER\") group by symbol order by symbol asc");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

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

            SendTimer(epService, startTime + 6000);
            Assert.AreEqual(1, listener.NewDataList.Count);
            EventBean[] events = listener.LastNewData;
            Assert.IsNull(events);
            listener.Reset();

            SendTimer(epService, startTime + 7000);
            engine.SendEvent(new SupportMarketDataBean("S1", "e1", 10d));

            SendTimer(epService, startTime + 8000);
            engine.SendEvent(new SupportMarketDataBean("S2", "e2", 77d));

            SendTimer(epService, startTime + 9000);
            engine.SendEvent(new SupportMarketDataBean("S1", "e3", 1d));

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

            SendTimer(epService, startTime + 11000);
            Assert.AreEqual(1, listener.NewDataList.Count);
            events = listener.LastNewData;
            Assert.AreEqual(2, events.Length);
            Assert.AreEqual("S1", events[0].Get("symbol"));
            Assert.AreEqual(11d, events[0].Get("s"));
            Assert.AreEqual("S2", events[1].Get("symbol"));
            Assert.AreEqual(77d, events[1].Get("s"));
            listener.Reset();

            stmt.Dispose();
        }
        private void SendEvent()
        {
            long id       = Interlocked.Increment(ref _idCounter);
            var  theEvent = new SupportBean();

            theEvent.LongPrimitive = id;
            _epRuntime.SendEvent(theEvent);
        }
Exemplo n.º 24
0
        private SupportBeanTimestamp SendEvent(String id, long timestamp)
        {
            SupportBeanTimestamp theEvent = new SupportBeanTimestamp(id, timestamp);
            EPRuntime            runtime  = _epService.EPRuntime;

            runtime.SendEvent(theEvent);
            return(theEvent);
        }
Exemplo n.º 25
0
        private SupportBeanTimestamp SendEvent(EPServiceProvider epService, string id, long timestamp)
        {
            var       theEvent = new SupportBeanTimestamp(id, timestamp);
            EPRuntime runtime  = epService.EPRuntime;

            runtime.SendEvent(theEvent);
            return(theEvent);
        }
Exemplo n.º 26
0
        private void SendEvent(EPRuntime epRuntime)
        {
            String      eventXMLText = GenerateEvent();
            XmlDocument simpleDoc    = new XmlDocument();

            simpleDoc.LoadXml(eventXMLText);
            epRuntime.SendEvent(simpleDoc);
        }
Exemplo n.º 27
0
 public void Run()
 {
     try
     {
         for (int i = 0; i < 1000; i++)
         {
             _runtime.SendEvent(new MyEventA("key1", _random.Next(0, 1000000)));
             _runtime.SendEvent(new MyEventA("key2", _random.Next(0, 1000000)));
             _runtime.SendEvent(new MyEventB("key1", _random.Next(0, 1000000)));
             _runtime.SendEvent(new MyEventB("key2", _random.Next(0, 1000000)));
         }
     }
     catch (Exception ex)
     {
         _exception = ex;
     }
 }
Exemplo n.º 28
0
            public void Run()
            {
                var bean = new SupportBean {
                    LongPrimitive = PerformanceObserver.MilliTime
                };

                _runtime.SendEvent(bean);
            }
Exemplo n.º 29
0
        public void SendBidEvent()
        {
            var bidEvent = new BidData(
                SymbolList[Rand.Next(SymbolList.Length)],
                0L,
                Rand.NextDouble());

            _espRuntime.SendEvent(bidEvent);
        }
Exemplo n.º 30
0
        public void TestGroupBySumStartEager()
        {
            long startTime = 1000;

            SendTimer(startTime);

            EPRuntime   engine = _epService.EPRuntime;
            EPStatement stmt   = _epService.EPAdministrator.CreateEPL(
                "select Symbol, sum(Price) as s from " + typeof(SupportMarketDataBean).FullName +
                ".win:time_length_batch(5, 10, \"START_EAGER\") group by Symbol order by Symbol asc");

            stmt.Events += _listener.Update;

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

            SendTimer(startTime + 6000);
            Assert.AreEqual(1, _listener.NewDataList.Count);
            EventBean[] events = _listener.LastNewData;
            Assert.IsNull(events);
            _listener.Reset();

            SendTimer(startTime + 7000);
            engine.SendEvent(new SupportMarketDataBean("S1", "e1", 10d));

            SendTimer(startTime + 8000);
            engine.SendEvent(new SupportMarketDataBean("S2", "e2", 77d));

            SendTimer(startTime + 9000);
            engine.SendEvent(new SupportMarketDataBean("S1", "e3", 1d));

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

            SendTimer(startTime + 11000);
            Assert.AreEqual(1, _listener.NewDataList.Count);
            events = _listener.LastNewData;
            Assert.AreEqual(2, events.Length);
            Assert.AreEqual("S1", events[0].Get("Symbol"));
            Assert.AreEqual(11d, events[0].Get("s"));
            Assert.AreEqual("S2", events[1].Get("Symbol"));
            Assert.AreEqual(77d, events[1].Get("s"));
            _listener.Reset();
        }