public override void Run(EPServiceProvider epService)
        {
            ConditionHandlerFactoryContext conditionHandlerFactoryContext = SupportConditionHandlerFactory.FactoryContexts[0];

            Assert.AreEqual(conditionHandlerFactoryContext.EngineURI, epService.URI);
            handler = SupportConditionHandlerFactory.LastHandler;

            string[] fields = "c0".Split(',');

            string epl = "@Name('S1') select * from SupportBean " +
                         "match_recognize (" +
                         "  partition by TheString " +
                         "  measures P1.TheString as c0" +
                         "  pattern (P1 P2) " +
                         "  define " +
                         "    P1 as P1.IntPrimitive = 1," +
                         "    P2 as P2.IntPrimitive = 2" +
                         ")";

            var         listener = new SupportUpdateListener();
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(epl);

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean("A", 1));
            epService.EPRuntime.SendEvent(new SupportBean("B", 1));
            epService.EPRuntime.SendEvent(new SupportBean("C", 1));
            Assert.IsTrue(handler.Contexts.IsEmpty());

            // overflow
            epService.EPRuntime.SendEvent(new SupportBean("D", 1));
            ExecRowRecogMaxStatesEngineWide3Instance.AssertContextEnginePool(epService, stmt, handler.GetAndResetContexts(), 3, ExecRowRecogMaxStatesEngineWide3Instance.GetExpectedCountMap("S1", 3));
            epService.EPRuntime.SendEvent(new SupportBean("E", 1));
            ExecRowRecogMaxStatesEngineWide3Instance.AssertContextEnginePool(epService, stmt, handler.GetAndResetContexts(), 3, ExecRowRecogMaxStatesEngineWide3Instance.GetExpectedCountMap("S1", 4));

            epService.EPRuntime.SendEvent(new SupportBean("D", 2));    // D gone
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "D" });

            epService.EPRuntime.SendEvent(new SupportBean("A", 2));    // A gone
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "A" });

            epService.EPRuntime.SendEvent(new SupportBean("C", 2));    // C gone
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "C" });

            epService.EPRuntime.SendEvent(new SupportBean("F", 1));
            Assert.IsTrue(handler.Contexts.IsEmpty());

            epService.EPRuntime.SendEvent(new SupportBean("G", 1));
            ExecRowRecogMaxStatesEngineWide3Instance.AssertContextEnginePool(epService, stmt, handler.GetAndResetContexts(), 3, ExecRowRecogMaxStatesEngineWide3Instance.GetExpectedCountMap("S1", 3));

            epService.EPAdministrator.Configuration.MatchRecognizeMaxStates = 4L;

            epService.EPRuntime.SendEvent(new SupportBean("G", 1));
            Assert.IsTrue(handler.Contexts.IsEmpty());

            epService.EPRuntime.SendEvent(new SupportBean("H", 1));
            ExecRowRecogMaxStatesEngineWide3Instance.AssertContextEnginePool(epService, stmt, handler.GetAndResetContexts(), 4, ExecRowRecogMaxStatesEngineWide3Instance.GetExpectedCountMap("S1", 4));

            epService.EPAdministrator.Configuration.MatchRecognizeMaxStates = null;

            epService.EPRuntime.SendEvent(new SupportBean("I", 1));
            Assert.IsTrue(handler.Contexts.IsEmpty());
        }
コード例 #2
0
        public override void Run(EPServiceProvider epService)
        {
            handler = SupportConditionHandlerFactory.LastHandler;
            string[] fields = "c0".Split(',');

            string eplOne = "@Name('S1') select * from SupportBean(TheString = 'A') " +
                            "match_recognize (" +
                            "  partition by IntPrimitive " +
                            "  measures P2.IntPrimitive as c0" +
                            "  pattern (P1 P2) " +
                            "  define " +
                            "    P1 as P1.LongPrimitive = 1," +
                            "    P2 as P2.LongPrimitive = 2" +
                            ")";
            EPStatement stmtOne     = epService.EPAdministrator.CreateEPL(eplOne);
            var         listenerOne = new SupportUpdateListener();

            stmtOne.Events += listenerOne.Update;

            string eplTwo = "@Name('S2') select * from SupportBean(TheString = 'B')#length(2) " +
                            "match_recognize (" +
                            "  partition by IntPrimitive " +
                            "  measures P2.IntPrimitive as c0" +
                            "  pattern (P1 P2) " +
                            "  define " +
                            "    P1 as P1.LongPrimitive = 1," +
                            "    P2 as P2.LongPrimitive = 2" +
                            ")";
            EPStatement stmtTwo     = epService.EPAdministrator.CreateEPL(eplTwo);
            var         listenerTwo = new SupportUpdateListener();

            stmtTwo.Events += listenerTwo.Update;

            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("A", 100, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("A", 200, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 100, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 200, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 300, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 400, 1));
            EPAssertionUtil.EnumeratorToArray(stmtTwo.GetEnumerator());
            Assert.IsTrue(handler.Contexts.IsEmpty());

            // overflow
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("A", 300, 1));
            ExecRowRecogMaxStatesEngineWide3Instance.AssertContextEnginePool(epService, stmtOne, handler.GetAndResetContexts(), 4, ExecRowRecogMaxStatesEngineWide3Instance.GetExpectedCountMap("S1", 2, "S2", 2));

            // terminate B
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 400, 2));
            EPAssertionUtil.AssertProps(listenerTwo.AssertOneGetNewAndReset(), fields, new object[] { 400 });

            // terminate one of A
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("A", 100, 2));
            EPAssertionUtil.AssertProps(listenerOne.AssertOneGetNewAndReset(), fields, new object[] { 100 });

            // fill up A
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("A", 300, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("A", 400, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("A", 500, 1));
            Assert.IsTrue(handler.Contexts.IsEmpty());

            // overflow
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 500, 1));
            ExecRowRecogMaxStatesEngineWide3Instance.AssertContextEnginePool(epService, stmtTwo, handler.GetAndResetContexts(), 4, ExecRowRecogMaxStatesEngineWide3Instance.GetExpectedCountMap("S1", 4, "S2", 0));

            // destroy statement-1 freeing up all "A"
            stmtOne.Dispose();

            // any number of B doesn't trigger overflow because of data window
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 600, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 700, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 800, 1));
            epService.EPRuntime.SendEvent(ExecRowRecogMaxStatesEngineWide3Instance.MakeBean("B", 900, 1));
            Assert.IsTrue(handler.Contexts.IsEmpty());
        }