public override void Run(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType("SupportEvent", typeof(SupportTradeEvent)); string statementTwo = "( every event1=SupportEvent(userId in ('100','101')) ->\n" + " (SupportEvent(userId in ('100','101'), direction = event1.direction ) ->\n" + " SupportEvent(userId in ('100','101'), direction = event1.direction )\n" + " ) where timer:within(8 hours)\n" + " and not eventNC=SupportEvent(userId in ('100','101'), direction!= event1.direction )\n" + " ) -> eventFinal=SupportEvent(userId in ('100','101'), direction != event1.direction ) where timer:within(1 hour)"; var runnable = new TwoPatternRunnable(epService); var t = new Thread(runnable.Run); t.Start(); Thread.Sleep(200); // Create a second pattern, wait 200 msec, destroy second pattern in a loop for (int i = 0; i < 10; i++) { EPStatement statement = epService.EPAdministrator.CreatePattern(statementTwo); Thread.Sleep(200); statement.Dispose(); } runnable.SetShutdown(true); Thread.Sleep(1000); Assert.IsFalse(t.IsAlive); }
public void Test2Patterns() { String statementTwo = "( every event1=SupportEvent(UserId in ('100','101')) ->\n" + " (SupportEvent(UserId in ('100','101'), Direction = event1.Direction ) ->\n" + " SupportEvent(UserId in ('100','101'), Direction = event1.Direction )\n" + " ) where timer:within(8 hours)\n" + " and not eventNC=SupportEvent(UserId in ('100','101'), Direction!= event1.Direction )\n" + " ) -> eventFinal=SupportEvent(UserId in ('100','101'), Direction != event1.Direction ) where timer:within(1 hour)"; TwoPatternRunnable runnable = new TwoPatternRunnable(engine); Thread t = new Thread(runnable.Run); t.Start(); Thread.Sleep(100); // Create a second pattern, wait 500 msec, destroy second pattern in a loop for (int i = 0; i < 10; i++) { EPStatement statement = engine.EPAdministrator.CreatePattern(statementTwo); Thread.Sleep(200); statement.Dispose(); } runnable.Shutdown = true; Thread.Sleep(1000); Assert.IsFalse(t.IsAlive); }