Exemplo n.º 1
0
        private void RunAssertionDestroy(EPServiceProvider epService)
        {
            if (SupportConfigFactory.SkipTest(typeof(ExecClientIsolationUnit)))
            {
                return;
            }

            EPStatement stmtOne  = epService.EPAdministrator.CreateEPL("@Name('A') select * from SupportBean", null, null);
            var         listener = new SupportUpdateListener();

            stmtOne.Events += listener.Update;

            EPServiceProviderIsolated unit = epService.GetEPServiceIsolated("i1");

            EPStatement stmtTwo = unit.EPAdministrator.CreateEPL("@Name('B') select * from SupportBean", null, null);

            stmtTwo.Events += listener.Update;
            unit.EPAdministrator.AddStatement(stmtOne);

            unit.EPRuntime.SendEvent(new SupportBean());
            Assert.AreEqual(2, listener.GetNewDataListFlattened().Length);
            listener.Reset();

            unit.Dispose();

            unit.EPRuntime.SendEvent(new SupportBean());
            Assert.AreEqual(0, listener.GetNewDataListFlattened().Length);
            listener.Reset();

            epService.EPRuntime.SendEvent(new SupportBean());
            Assert.AreEqual(2, listener.GetNewDataListFlattened().Length);

            stmtOne.Dispose();
            stmtTwo.Dispose();
        }
Exemplo n.º 2
0
        public void TestDestroy()
        {
            EPStatement stmtOne = _epService.EPAdministrator.CreateEPL(
                "@Name('A') select * from SupportBean", null, null);

            stmtOne.Events += _listener.Update;

            EPServiceProviderIsolated unit = _epService.GetEPServiceIsolated("i1");

            EPStatement stmtTwo = unit.EPAdministrator.CreateEPL(
                "@Name('B') select * from SupportBean", null, null);

            stmtTwo.Events += _listener.Update;
            unit.EPAdministrator.AddStatement(stmtOne);

            unit.EPRuntime.SendEvent(new SupportBean());
            Assert.AreEqual(2, _listener.GetNewDataListFlattened().Length);
            _listener.Reset();

            unit.Dispose();

            unit.EPRuntime.SendEvent(new SupportBean());
            Assert.AreEqual(0, _listener.GetNewDataListFlattened().Length);
            _listener.Reset();

            _epService.EPRuntime.SendEvent(new SupportBean());
            Assert.AreEqual(2, _listener.GetNewDataListFlattened().Length);
            _listener.Reset();
        }
Exemplo n.º 3
0
        private void RunAssertionBatchWindowInsertInto(EPServiceProvider epService)
        {
            var    fields        = new string[] { "TheString", "IntPrimitive" };
            string statementText = "insert into MyStream select distinct TheString, IntPrimitive from SupportBean#length_batch(3)";

            epService.EPAdministrator.CreateEPL(statementText);

            statementText = "select * from MyStream";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(statementText);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1 });

            epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertProps(listener.GetNewDataListFlattened()[0], fields, new object[] { "E2", 2 });
            EPAssertionUtil.AssertProps(listener.GetNewDataListFlattened()[1], fields, new object[] { "E3", 3 });

            stmt.Dispose();
        }
Exemplo n.º 4
0
        public void TestEnabledDisableStatement()
        {
            var fields     = new String[] { "StatementName" };
            var statements = new EPStatement[5];
            var config     = GetConfig(-1, 10000, true);

            var configOne = new ConfigurationMetricsReporting.StmtGroupMetrics();

            configOne.Interval = -1;
            configOne.AddIncludeLike("%@METRIC%");
            config.EngineDefaults.MetricsReportingConfig.AddStmtGroup("metrics", configOne);

            _epService = EPServiceProviderManager.GetProvider("MyURI", config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            SendTimer(1000);

            statements[0]         = _epService.EPAdministrator.CreateEPL("select * from " + typeof(StatementMetric).FullName, "MyStatement@METRIC");
            statements[0].Events += _listenerStmtMetric.Update;

            statements[1] = _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive=1).win:keepall() where 2=2", "stmtone");
            SendEvent("E1", 1, CpuGoalOneNano);
            statements[2] = _epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive>0).std:lastevent() where 1=1", "stmttwo");
            SendEvent("E2", 1, CpuGoalOneNano);

            SendTimer(11000);
            EPAssertionUtil.AssertPropsPerRow(_listenerStmtMetric.GetNewDataListFlattened(), fields, new Object[][] { new Object[] { "stmtone" }, new Object[] { "stmttwo" } });
            _listenerStmtMetric.Reset();

            SendEvent("E1", 1, CpuGoalOneNano);
            SendTimer(21000);
            EPAssertionUtil.AssertPropsPerRow(_listenerStmtMetric.GetNewDataListFlattened(), fields, new Object[][] { new Object[] { "stmtone" }, new Object[] { "stmttwo" } });
            _listenerStmtMetric.Reset();

            _epService.EPAdministrator.Configuration.SetMetricsReportingStmtDisabled("stmtone");

            SendEvent("E1", 1, CpuGoalOneNano);
            SendTimer(31000);
            EPAssertionUtil.AssertPropsPerRow(_listenerStmtMetric.GetNewDataListFlattened(), fields, new Object[][] { new Object[] { "stmttwo" } });
            _listenerStmtMetric.Reset();

            _epService.EPAdministrator.Configuration.SetMetricsReportingStmtEnabled("stmtone");
            _epService.EPAdministrator.Configuration.SetMetricsReportingStmtDisabled("stmttwo");

            SendEvent("E1", 1, CpuGoalOneNano);
            SendTimer(41000);
            EPAssertionUtil.AssertPropsPerRow(_listenerStmtMetric.GetNewDataListFlattened(), fields, new Object[][] { new Object[] { "stmtone" } });
            _listenerStmtMetric.Reset();

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
Exemplo n.º 5
0
        private void TryAssertion(EPServiceProvider epService, SupportUpdateListener listener, long timestamp)
        {
            string[] fields = "engineURI,statementName".Split(',');

            Assert.AreEqual(4, listener.NewDataList.Count);
            EventBean[] received = listener.GetNewDataListFlattened();

            EPAssertionUtil.AssertProps(received[0], fields, new object[] { "default", "cpuStmtOne" });
            EPAssertionUtil.AssertProps(received[1], fields, new object[] { "default", "cpuStmtTwo" });
            EPAssertionUtil.AssertProps(received[2], fields, new object[] { "default", "wallStmtThree" });
            EPAssertionUtil.AssertProps(received[3], fields, new object[] { "default", "wallStmtFour" });

            long cpuOne  = received[0].Get("cpuTime").AsLong();
            long cpuTwo  = received[1].Get("cpuTime").AsLong();
            long wallOne = received[2].Get("wallTime").AsLong();
            long wallTwo = received[3].Get("wallTime").AsLong();

            Assert.IsTrue(cpuOne > CPU_GOAL_ONE_NANO, "cpuOne=" + cpuOne);
            Assert.IsTrue(cpuTwo > CPU_GOAL_TWO_NANO, "cpuTwo=" + cpuTwo);
            Assert.IsTrue((wallOne + 50) > WALL_GOAL_ONE_MSEC, "wallOne=" + wallOne);
            Assert.IsTrue((wallTwo + 50) > WALL_GOAL_TWO_MSEC, "wallTwo=" + wallTwo);

            for (int i = 0; i < 4; i++)
            {
                Assert.AreEqual(1L, received[i].Get("OutputIStreamCount"));
                Assert.AreEqual(0L, received[i].Get("OutputRStreamCount"));
                Assert.AreEqual(timestamp, received[i].Get("timestamp"));
            }

            listener.Reset();
        }
        private void RunAssertionBeacon(EPServiceProvider epService)
        {
            epService.EPAdministrator.CreateEPL("create objectarray schema MyEventBeacon(p0 string, p1 long)");

            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select * from MyEventBeacon");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                "" +
                                                "BeaconSource -> BeaconStream<MyEventBeacon> {" +
                                                "  iterations : 3," +
                                                "  p0 : 'abc'," +
                                                "  p1 : 1," +
                                                "}" +
                                                "EventBusSink(BeaconStream) {}");

            epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", null).Start();
            listener.WaitForInvocation(3000, 3);
            EventBean[] events = listener.GetNewDataListFlattened();

            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual("abc", events[i].Get("p0"));
                long val = (long)events[i].Get("p1");
                Assert.IsTrue(val > 0 && val < 10);
            }

            epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunAssertionAllTypes(EPServiceProvider epService, string typeName, object[] events)
        {
            string graph = "create dataflow MyGraph " +
                           "DefaultSupportSourceOp -> instream<" + typeName + ">{}" +
                           "EventBusSink(instream) {}";
            EPStatement stmtGraph = epService.EPAdministrator.CreateEPL(graph);

            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select * from " + typeName);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            var source  = new DefaultSupportSourceOp(events);
            var options = new EPDataFlowInstantiationOptions();

            options.OperatorProvider(new DefaultSupportGraphOpProvider(source));
            EPDataFlowInstance instance = epService.EPRuntime.DataFlowRuntime.Instantiate("MyGraph", options);

            instance.Run();

            EPAssertionUtil.AssertPropsPerRow(listener.GetNewDataListFlattened(), "myDouble,myInt,myString".Split(','), new object[][] { new object[] { 1.1d, 1, "one" }, new object[] { 2.2d, 2, "two" } });
            listener.Reset();

            stmtGraph.Dispose();
        }
Exemplo n.º 8
0
        public void TestIterateAndListen()
        {
            _epService.EPAdministrator.CreateEPL("@Name('ctx') create context MyCtx as initiated by SupportBean_S0 s0 terminated after 24 hours");

            var fields = "mycontextvar".Split(',');
            var listenerCreateVariable = new SupportUpdateListener();
            var stmtVar = _epService.EPAdministrator.CreateEPL("@Name('var') context MyCtx create variable int mycontextvar = 5");

            stmtVar.Events += listenerCreateVariable.Update;

            var listenerUpdate = new SupportUpdateListener();
            var stmtUpd        = _epService.EPAdministrator.CreateEPL("@Name('upd') context MyCtx on SupportBean(TheString = context.s0.p00) set mycontextvar = IntPrimitive");

            stmtUpd.Events += listenerUpdate.Update;

            _epService.EPRuntime.SendEvent(new SupportBean_S0(0, "P1"));   // allocate partition P1
            _epService.EPRuntime.SendEvent(new SupportBean("P1", 100));    // update
            EPAssertionUtil.AssertProps(listenerUpdate.AssertOneGetNewAndReset(), "mycontextvar".Split(','), new object[] { 100 });
            EPAssertionUtil.AssertPropsPerRow(EPAssertionUtil.EnumeratorToArray(stmtUpd.GetEnumerator()), fields, new object[][] { new object[] { 100 } });

            _epService.EPRuntime.SendEvent(new SupportBean_S0(0, "P2"));   // allocate partition P1
            _epService.EPRuntime.SendEvent(new SupportBean("P2", 101));    // update
            EPAssertionUtil.AssertProps(listenerUpdate.AssertOneGetNewAndReset(), "mycontextvar".Split(','), new object[] { 101 });
            EPAssertionUtil.AssertPropsPerRow(EPAssertionUtil.EnumeratorToArray(stmtUpd.GetEnumerator()), fields, new object[][] { new object[] { 100 }, new object[] { 101 } });

            var events = EPAssertionUtil.EnumeratorToArray(stmtVar.GetEnumerator());

            EPAssertionUtil.AssertPropsPerRowAnyOrder(events, "mycontextvar".SplitCsv(), new Object[][] { new Object[] { 100 }, new Object[] { 101 } });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(listenerCreateVariable.GetNewDataListFlattened(), "mycontextvar".SplitCsv(), new Object[][] { new Object[] { 100 }, new Object[] { 101 } });
        }
Exemplo n.º 9
0
        public void TestContextMultistmt()
        {
            // Test uses system time
            //
            var configuration = new Configuration();
            var engine        = EPServiceProviderManager.GetDefaultProvider(configuration);

            engine.Initialize();

            engine.EPAdministrator.Configuration.AddEventType(typeof(TestEvent));
            engine.EPAdministrator.CreateEPL("create context theContext " +
                                             " initiated by distinct(PartitionKey) TestEvent as test " +
                                             " terminated after 100 milliseconds");

            var stmt = engine.EPAdministrator.CreateEPL("context theContext " +
                                                        "select sum(Value) as thesum, count(*) as thecnt " +
                                                        "from TestEvent output snapshot when terminated");
            var listener = new SupportUpdateListener();

            stmt.AddListener(listener);

            var numLoops  = 2000000;
            var numEvents = numLoops * 4;

            for (var i = 0; i < numLoops; i++)
            {
                if (i % 100000 == 0)
                {
                    Console.WriteLine("Completed: " + i);
                }
                engine.EPRuntime.SendEvent(new TestEvent("TEST", 10));
                engine.EPRuntime.SendEvent(new TestEvent("TEST", -10));
                engine.EPRuntime.SendEvent(new TestEvent("TEST", 25));
                engine.EPRuntime.SendEvent(new TestEvent("TEST", -25));
            }

            int numDeliveries = listener.NewDataList.Count;

            Console.WriteLine("Done " + numLoops + " loops, have " + numDeliveries + " deliveries");
            Assert.IsTrue(numDeliveries > 3);

            Thread.Sleep(1000);

            var  sum   = 0;
            long count = 0;

            foreach (EventBean @event in listener.GetNewDataListFlattened())
            {
                var sumBatch = @event.Get("thesum").AsBoxedInt();
                // Comment-Me-In: Console.WriteLine(EventBeanUtility.summarize(event));
                if (sumBatch != null)   // can be null when there is nothing to deliver
                {
                    sum   += sumBatch.Value;
                    count += @event.Get("thecnt").AsLong();
                }
            }
            Console.WriteLine("count=" + count + "  sum=" + sum);
            Assert.AreEqual(numEvents, count);
            Assert.AreEqual(0, sum);
        }
Exemplo n.º 10
0
        private void RunAssertionCoercion(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBeanRange));
            string eplDeclare  = "create table varagg as (k0 int primary key, total sum(long))";
            string eplPopulate = "into table varagg select sum(LongPrimitive) as total from SupportBean group by IntPrimitive";
            string eplQuery    = "select total as value from SupportBeanRange unidirectional";

            var createIndexEmpty = new string[] {};
            var preloadedEvents  = new object[] { MakeEvent("G1", 10, 1000L), MakeEvent("G2", 20, 2000L),
                                                  MakeEvent("G3", 30, 3000L), MakeEvent("G4", 40, 4000L) };
            var listener = new SupportUpdateListener();

            var eventSendAssertion = new IndexAssertionEventSend(() => {
                epService.EPRuntime.SendEvent(new SupportBeanRange(20L));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(listener.GetNewDataListFlattened(), "value".Split(','),
                                                          new object[][] { new object[] { 2000L } });
                listener.Reset();
            });

            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexEmpty, preloadedEvents,
                              new IndexAssertion[] {
                new IndexAssertion("k0 = keyLong", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertion),
                new IndexAssertion("k0 = keyLong", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertion),
            }
                              );
        }
Exemplo n.º 11
0
        public void TestTimestamp()
        {
            _epService.EPAdministrator.Configuration.AddVariable("var1", typeof(long), "12");
            _epService.EPAdministrator.Configuration.AddVariable("var2", typeof(long), "2");
            _epService.EPAdministrator.Configuration.AddVariable("var3", typeof(long), null);

            long         startTime   = PerformanceObserver.MilliTime;
            const string stmtTextSet = "on pattern [every timer:interval(100 milliseconds)] set var1 = current_timestamp, var2 = var1 + 1, var3 = var1 + var2";
            EPStatement  stmtSet     = _epService.EPAdministrator.CreateEPL(stmtTextSet);

            stmtSet.Events += _listenerSet.Update;

            Thread.Sleep(1000);
            stmtSet.Dispose();

            EventBean[] received = _listenerSet.GetNewDataListFlattened();
            Assert.IsTrue(received.Length >= 5, "received : " + received.Length);

            for (int i = 0; i < received.Length; i++)
            {
                long var1 = received[i].Get("var1").AsLong();
                long var2 = received[i].Get("var2").AsLong();;
                long var3 = received[i].Get("var3").AsLong();;
                Assert.IsTrue(var1 >= startTime);
                Assert.AreEqual(var1, var2 - 1);
                Assert.AreEqual(var3, var2 + var1);
            }
        }
Exemplo n.º 12
0
        public void TryCount(int numThreads, int numMessages, String epl, GeneratorIteratorCallback generatorIteratorCallback)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var stmt       = _engine.EPAdministrator.CreateEPL(epl);
            var listener   = new SupportUpdateListener();

            stmt.Events += listener.Update;

            var future = new Future <object> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                future[i] = threadPool.Submit(new SendEventCallable(i, _engine, EventGenerator.MakeEvents(numMessages, generatorIteratorCallback)));
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault().AsBoolean());
            }

            Assert.AreEqual(numMessages * numThreads, listener.GetNewDataListFlattened().Length);
        }
        private void TryCount(
            EPServiceProvider epService, int numThreads, int numMessages, string epl,
            GeneratorIteratorCallback generatorIteratorCallback)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var stmt = epService.EPAdministrator.CreateEPL(epl);
            var listener = new SupportUpdateListener();
            stmt.Events += listener.Update;

            var future = new Future<bool>[numThreads];
            for (var i = 0; i < numThreads; i++)
            {
                future[i] = threadPool.Submit(
                    new SendEventCallable(
                        i, epService, new GeneratorIterator(numMessages, generatorIteratorCallback)));
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            for (var i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            Assert.AreEqual(numMessages * numThreads, listener.GetNewDataListFlattened().Length);
        }
        public override void Run(EPServiceProvider epService)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            epService.EPAdministrator.CreateEPL("create context MyCtx start @now end after 1 second");
            EPStatement stmt     = epService.EPAdministrator.CreateEPL("context MyCtx select count(*) as cnt from SupportBean output last when terminated");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            var latch = new AtomicBoolean(true);
            // With 0-sleep or 1-sleep the counts start to drop because the event is chasing the context partition.
            var t = new Thread(new MyTimeAdvancingRunnable(epService, latch, 10, -1).Run);

            t.Start();

            int numEvents = 10000;

            for (int i = 0; i < numEvents; i++)
            {
                epService.EPRuntime.SendEvent(new SupportBean());
            }
            latch.Set(false);
            t.Join();
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(int.MaxValue));

            long total = 0;

            EventBean[] deliveries = listener.GetNewDataListFlattened();
            foreach (EventBean @event in deliveries)
            {
                long count = (long)@event.Get("cnt");
                total += count;
            }
            Assert.AreEqual(numEvents, total);
        }
Exemplo n.º 15
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddVariable("var1", typeof(long), "12");
            epService.EPAdministrator.Configuration.AddVariable("var2", typeof(long), "2");
            epService.EPAdministrator.Configuration.AddVariable("var3", typeof(long), null);

            long        startTime   = DateTimeHelper.CurrentTimeMillis;
            string      stmtTextSet = "on pattern [every timer:interval(100 milliseconds)] set var1 = current_timestamp, var2 = var1 + 1, var3 = var1 + var2";
            EPStatement stmtSet     = epService.EPAdministrator.CreateEPL(stmtTextSet);
            var         listenerSet = new SupportUpdateListener();

            stmtSet.Events += listenerSet.Update;

            Thread.Sleep(1000);
            stmtSet.Dispose();

            EventBean[] received = listenerSet.GetNewDataListFlattened();
            Assert.IsTrue(received.Length >= 5, "received : " + received.Length);

            for (int i = 0; i < received.Length; i++)
            {
                long var1 = (long)received[i].Get("var1");
                long var2 = (long)received[i].Get("var2");
                long var3 = (long)received[i].Get("var3");
                Assert.IsTrue(var1 >= startTime);
                Assert.AreEqual(var1, var2 - 1);
                Assert.AreEqual(var3, var2 + var1);
            }
        }
Exemplo n.º 16
0
        private void TryChainedCountSum(int numThreads, int numEvents)
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.ThreadingConfig.IsInternalTimerEnabled = false;
            // This should fail all test in this class
            // config.EngineDefaults.ThreadingConfig.InsertIntoDispatchPreserveOrder = false;

            EPServiceProvider engine = EPServiceProviderManager.GetDefaultProvider(config);

            engine.Initialize();

            // setup statements
            EPStatement           stmtInsertOne   = engine.EPAdministrator.CreateEPL("insert into MyStreamOne select count(*) as cnt from " + typeof(SupportBean).FullName);
            EPStatement           stmtInsertTwo   = engine.EPAdministrator.CreateEPL("insert into MyStreamTwo select sum(cnt) as mysum from MyStreamOne");
            EPStatement           stmtInsertThree = engine.EPAdministrator.CreateEPL("select * from MyStreamTwo");
            SupportUpdateListener listener        = new SupportUpdateListener();

            stmtInsertThree.Events += listener.Update;
#if false
            stmtInsertThree.Events += (sender, eargs) =>
            {
                Console.WriteLine("Event: {0}", eargs.NewEvents[0].Get("mysum"));
            };
#endif

            // execute
            var threadPool      = Executors.NewFixedThreadPool(numThreads);
            var future          = new Future <bool> [numThreads];
            var sharedStartLock = ReaderWriterLockManager.CreateLock(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            using (sharedStartLock.AcquireWriteLock()) {
                for (int i = 0; i < numThreads; i++)
                {
                    future[i] = threadPool.Submit(
                        new SendEventRWLockCallable(i, sharedStartLock.ReadLock, engine, EnumerationGenerator.Create(numEvents)));
                }
                Thread.Sleep(100);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(new TimeSpan(0, 0, 10));

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue((bool)future[i].GetValueOrDefault());
            }

            // assert result
            EventBean[] newEvents = listener.GetNewDataListFlattened();
            for (int i = 0; i < numEvents - 1; i++)
            {
                long expected = Total(i + 1);
                Assert.AreEqual(expected, newEvents[i].Get("mysum"));
            }

            stmtInsertOne.Dispose();
            stmtInsertTwo.Dispose();
            stmtInsertThree.Dispose();
        }
        public override void Run(EPServiceProvider defaultEpService)
        {
            var configuration = new Configuration(SupportContainer.Instance);
            var epService     = EPServiceProviderManager.GetProvider(
                SupportContainer.Instance, GetType().FullName, configuration);

            epService.Initialize();
            Thread.Sleep(100); // allow time for start up

            epService.EPAdministrator.Configuration.AddEventType(typeof(TestEvent));
            epService.EPAdministrator.CreateEPL("create context theContext " +
                                                "context perPartition partition by PartitionKey from TestEvent," +
                                                "context per10Seconds start @now end after 100 milliseconds");

            EPStatement stmt = epService.EPAdministrator.CreateEPL("context theContext " +
                                                                   "select sum(Value) as thesum, count(*) as thecnt, context.perPartition.key1 as thekey " +
                                                                   "from TestEvent output snapshot when terminated");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            int numLoops  = 200000;
            int numEvents = numLoops * 4;

            for (int i = 0; i < numLoops; i++)
            {
                if (i % 100000 == 0)
                {
                    Log.Info("Completed: " + i);
                }
                epService.EPRuntime.SendEvent(new TestEvent("TEST", 10));
                epService.EPRuntime.SendEvent(new TestEvent("TEST", -10));
                epService.EPRuntime.SendEvent(new TestEvent("TEST", 25));
                epService.EPRuntime.SendEvent(new TestEvent("TEST", -25));
            }

            Thread.Sleep(250);

            int numDeliveries = listener.NewDataList.Count;

            Assert.IsTrue(numDeliveries >= 2, "Done " + numLoops + " loops, have " + numDeliveries + " deliveries");

            int  sum   = 0;
            long count = 0;

            foreach (EventBean @event in listener.GetNewDataListFlattened())
            {
                int?sumBatch = (int?)@event.Get("thesum");
                if (sumBatch != null)   // can be null when there is nothing to deliver
                {
                    sum   += sumBatch.Value;
                    count += (long)@event.Get("thecnt");
                }
            }
            Assert.AreEqual(0, sum);
            Assert.AreEqual(numEvents, count);
            epService.Dispose();
        }
Exemplo n.º 18
0
        private void RunAssertionJoinUnfiltered(EPServiceProvider epService)
        {
            string stmtText = "select (select id from S3#length(1000)) as idS3, (select id from S4#length(1000)) as idS4 from S0#keepall as s0, S1#keepall as s1 where s0.id = s1.id";

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

            stmt.Events += listener.Update;

            // check type
            Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("idS3"));
            Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("idS4"));

            // test no event, should return null
            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            epService.EPRuntime.SendEvent(new SupportBean_S1(0));
            EventBean theEvent = listener.AssertOneGetNewAndReset();

            Assert.AreEqual(null, theEvent.Get("idS3"));
            Assert.AreEqual(null, theEvent.Get("idS4"));

            // send one event
            epService.EPRuntime.SendEvent(new SupportBean_S3(-1));
            epService.EPRuntime.SendEvent(new SupportBean_S0(1));
            epService.EPRuntime.SendEvent(new SupportBean_S1(1));
            theEvent = listener.AssertOneGetNewAndReset();
            Assert.AreEqual(-1, theEvent.Get("idS3"));
            Assert.AreEqual(null, theEvent.Get("idS4"));

            // send one event
            epService.EPRuntime.SendEvent(new SupportBean_S4(-2));
            epService.EPRuntime.SendEvent(new SupportBean_S0(2));
            epService.EPRuntime.SendEvent(new SupportBean_S1(2));
            theEvent = listener.AssertOneGetNewAndReset();
            Assert.AreEqual(-1, theEvent.Get("idS3"));
            Assert.AreEqual(-2, theEvent.Get("idS4"));

            // send second event
            epService.EPRuntime.SendEvent(new SupportBean_S4(-2));
            epService.EPRuntime.SendEvent(new SupportBean_S0(3));
            epService.EPRuntime.SendEvent(new SupportBean_S1(3));
            theEvent = listener.AssertOneGetNewAndReset();
            Assert.AreEqual(-1, theEvent.Get("idS3"));
            Assert.AreEqual(null, theEvent.Get("idS4"));

            epService.EPRuntime.SendEvent(new SupportBean_S3(-2));
            epService.EPRuntime.SendEvent(new SupportBean_S0(3));
            epService.EPRuntime.SendEvent(new SupportBean_S1(3));
            EventBean[] events = listener.GetNewDataListFlattened();
            Assert.AreEqual(3, events.Length);
            for (int i = 0; i < events.Length; i++)
            {
                Assert.AreEqual(null, events[i].Get("idS3"));
                Assert.AreEqual(null, events[i].Get("idS4"));
            }

            stmt.Dispose();
        }
Exemplo n.º 19
0
        public void TestJoinUnfiltered()
        {
            var stmtText = "select (select id from S3.win:length(1000)) as idS3, (select id from S4.win:length(1000)) as idS4 from S0.win:keepall() as s0, S1.win:keepall() as s1 where s0.id = s1.id";

            var stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.Events += _listener.Update;

            // check type
            Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("idS3"));
            Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("idS4"));

            // test no event, should return null
            _epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            _epService.EPRuntime.SendEvent(new SupportBean_S1(0));
            var theEvent = _listener.AssertOneGetNewAndReset();

            Assert.AreEqual(null, theEvent.Get("idS3"));
            Assert.AreEqual(null, theEvent.Get("idS4"));

            // send one event
            _epService.EPRuntime.SendEvent(new SupportBean_S3(-1));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(1));
            _epService.EPRuntime.SendEvent(new SupportBean_S1(1));
            theEvent = _listener.AssertOneGetNewAndReset();
            Assert.AreEqual(-1, theEvent.Get("idS3"));
            Assert.AreEqual(null, theEvent.Get("idS4"));

            // send one event
            _epService.EPRuntime.SendEvent(new SupportBean_S4(-2));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(2));
            _epService.EPRuntime.SendEvent(new SupportBean_S1(2));
            theEvent = _listener.AssertOneGetNewAndReset();
            Assert.AreEqual(-1, theEvent.Get("idS3"));
            Assert.AreEqual(-2, theEvent.Get("idS4"));

            // send second event
            _epService.EPRuntime.SendEvent(new SupportBean_S4(-2));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(3));
            _epService.EPRuntime.SendEvent(new SupportBean_S1(3));
            theEvent = _listener.AssertOneGetNewAndReset();
            Assert.AreEqual(-1, theEvent.Get("idS3"));
            Assert.AreEqual(null, theEvent.Get("idS4"));

            _epService.EPRuntime.SendEvent(new SupportBean_S3(-2));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(3));
            _epService.EPRuntime.SendEvent(new SupportBean_S1(3));
            var events = _listener.GetNewDataListFlattened();

            Assert.AreEqual(3, events.Length);
            for (var i = 0; i < events.Length; i++)
            {
                Assert.AreEqual(null, events[i].Get("idS3"));
                Assert.AreEqual(null, events[i].Get("idS4"));
            }
        }
Exemplo n.º 20
0
        public void TestBatchWindowInsertInto()
        {
            String[] fields = new String[]
            {
                "TheString", "IntPrimitive"
            }
            ;
            String statementText = "insert into MyStream select distinct TheString, IntPrimitive from SupportBean.win:length_batch(3)";

            _epService.EPAdministrator.CreateEPL(statementText);

            statementText = "select * from MyStream";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(
                statementText);

            stmt.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[]
            {
                "E1", 1
            }
                                        );

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            _epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertProps(_listener.GetNewDataListFlattened()[0],
                                        fields, new Object[]
            {
                "E2", 2
            }
                                        );
            EPAssertionUtil.AssertProps(_listener.GetNewDataListFlattened()[1],
                                        fields, new Object[]
            {
                "E3", 3
            }
                                        );
        }
Exemplo n.º 21
0
        public override void Run(EPServiceProvider epService)
        {
            var fields     = new string[] { "statementName" };
            var statements = new EPStatement[5];

            SendTimer(epService, 1000);

            statements[0] = epService.EPAdministrator.CreateEPL("select * from " + typeof(StatementMetric).FullName, "MyStatement@METRIC");
            var listenerStmtMetric = new SupportUpdateListener();

            statements[0].Events += listenerStmtMetric.Update;

            statements[1] = epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive=1)#keepall where 2=2", "stmtone");
            SendEvent(epService, "E1", 1, CPUGOALONENANO);
            statements[2] = epService.EPAdministrator.CreateEPL("select * from SupportBean(IntPrimitive>0)#lastevent where 1=1", "stmttwo");
            SendEvent(epService, "E2", 1, CPUGOALONENANO);

            SendTimer(epService, 11000);
            EPAssertionUtil.AssertPropsPerRow(listenerStmtMetric.GetNewDataListFlattened(), fields, new object[][] { new object[] { "stmtone" }, new object[] { "stmttwo" } });
            listenerStmtMetric.Reset();

            SendEvent(epService, "E1", 1, CPUGOALONENANO);
            SendTimer(epService, 21000);
            EPAssertionUtil.AssertPropsPerRow(listenerStmtMetric.GetNewDataListFlattened(), fields, new object[][] { new object[] { "stmtone" }, new object[] { "stmttwo" } });
            listenerStmtMetric.Reset();

            epService.EPAdministrator.Configuration.SetMetricsReportingStmtDisabled("stmtone");

            SendEvent(epService, "E1", 1, CPUGOALONENANO);
            SendTimer(epService, 31000);
            EPAssertionUtil.AssertPropsPerRow(listenerStmtMetric.GetNewDataListFlattened(), fields, new object[][] { new object[] { "stmttwo" } });
            listenerStmtMetric.Reset();

            epService.EPAdministrator.Configuration.SetMetricsReportingStmtEnabled("stmtone");
            epService.EPAdministrator.Configuration.SetMetricsReportingStmtDisabled("stmttwo");

            SendEvent(epService, "E1", 1, CPUGOALONENANO);
            SendTimer(epService, 41000);
            EPAssertionUtil.AssertPropsPerRow(listenerStmtMetric.GetNewDataListFlattened(), fields, new object[][] { new object[] { "stmtone" } });
        }
 private void AssertPrio(String stringValue, int[] prioValues)
 {
     EventBean[] events = listener.GetNewDataListFlattened();
     Assert.AreEqual(prioValues.Length, events.Length);
     for (int i = 0; i < prioValues.Length; i++)
     {
         Assert.AreEqual(prioValues[i], events[i].Get("prio"));
         if (stringValue != null)
         {
             Assert.AreEqual(stringValue, events[i].Get("TheString"));
         }
     }
     listener.Reset();
 }
Exemplo n.º 23
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            epService.EPAdministrator.CreateEPL("@Name('0') create schema StatementMetric as " + typeof(StatementMetric).FullName);
            epService.EPAdministrator.CreateEPL("@Name('A') create window MyWindow#lastevent as select * from SupportBean");
            epService.EPAdministrator.CreateEPL("@Name('B1') insert into MyWindow select * from SupportBean");
            epService.EPAdministrator.CreateEPL("@Name('B2') insert into MyWindow select * from SupportBean");
            epService.EPAdministrator.CreateEPL("@Name('C') select sum(IntPrimitive) from MyWindow");
            epService.EPAdministrator.CreateEPL("@Name('D') select sum(w1.IntPrimitive) from MyWindow w1, MyWindow w2");

            string appModuleTwo = "@Name('W') create window SupportBeanWindow#keepall as SupportBean;" +
                                  "" +
                                  "@Name('M') on SupportBean oe\n" +
                                  "  merge SupportBeanWindow pw\n" +
                                  "  where pw.TheString = oe.TheString\n" +
                                  "  when not matched \n" +
                                  "    then insert select *\n" +
                                  "  when matched and oe.IntPrimitive=1\n" +
                                  "    then delete\n" +
                                  "  when matched\n" +
                                  "    then update set pw.IntPrimitive = oe.IntPrimitive";

            epService.EPAdministrator.DeploymentAdmin.ParseDeploy(appModuleTwo, null, null, null);

            EPStatement stmt     = epService.EPAdministrator.CreateEPL("@Name('X') select * from StatementMetric");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;
            string[] fields = "statementName,numInput".Split(',');

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000));
            EventBean[] received = ArrayHandlingUtil.Reorder("statementName", listener.GetNewDataListFlattened());
            foreach (EventBean theEvent in received)
            {
                Log.Info(theEvent.Get("statementName") + " = " + theEvent.Get("numInput"));
            }
            EPAssertionUtil.AssertPropsPerRow(received, fields, new object[][] { new object[] { "A", 2L }, new object[] { "B1", 1L }, new object[] { "B2", 1L }, new object[] { "C", 2L }, new object[] { "D", 2L }, new object[] { "M", 1L }, new object[] { "W", 1L } });

            /* Comment-in for printout.
             * for (int i = 0; i < received.Length; i++) {
             *  EventBean @event = received[i];
             *  Log.Info(@event.Get("statementName") + " " + @event.Get("wallTime") + " " + @event.Get("numInput"));
             * }
             */
        }
Exemplo n.º 24
0
        private void RunAssertionModelPono(EPServiceProvider epService)
        {
            var stmtCreateOne = epService.EPAdministrator.CreateEPL("create schema SupportBeanOne as " + typeof(SupportBean_ST0).FullName);

            Assert.AreEqual(typeof(SupportBean_ST0), stmtCreateOne.EventType.UnderlyingType);

            var stmtCreateTwo = epService.EPAdministrator.CreateEPL("create schema SupportBeanTwo as " + typeof(SupportBean_ST0).FullName);

            Assert.AreEqual(typeof(SupportBean_ST0), stmtCreateTwo.EventType.UnderlyingType);

            var stmtSelectOne = epService.EPAdministrator.CreateEPL("select * from SupportBeanOne");

            Assert.AreEqual(typeof(SupportBean_ST0), stmtSelectOne.EventType.UnderlyingType);
            var listener = new SupportUpdateListener();

            stmtSelectOne.Events += listener.Update;

            var stmtSelectTwo = epService.EPAdministrator.CreateEPL("select * from SupportBeanTwo");

            Assert.AreEqual(typeof(SupportBean_ST0), stmtSelectTwo.EventType.UnderlyingType);
            stmtSelectTwo.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean_ST0("E1", 2));
            EPAssertionUtil.AssertPropsPerRow(listener.GetNewDataListFlattened(), "id,p00".Split(','),
                                              new object[][] {
                new object[] { "E1", 2 },
                new object[] { "E1", 2 }
            });

            // assert type information
            var typeSPI = (EventTypeSPI)stmtSelectOne.EventType;

            Assert.AreEqual(TypeClass.APPLICATION, typeSPI.Metadata.TypeClass);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PublicName);
            Assert.IsTrue(typeSPI.Metadata.IsApplicationConfigured);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfiguredStatic);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PrimaryName);

            // test keyword
            TryInvalid(epService, "create schema MySchemaInvalid as com.mycompany.event.ABC",
                       "Error starting statement: Event type or class named 'com.mycompany.event.ABC' was not found");
            TryInvalid(epService, "create schema MySchemaInvalid as com.mycompany.events.ABC",
                       "Error starting statement: Event type or class named 'com.mycompany.events.ABC' was not found");
        }
        private void TryChainedCountSum(EPServiceProvider epService, int numThreads, int numEvents)
        {
            // setup statements
            EPStatement stmtInsertOne = epService.EPAdministrator.CreateEPL("insert into MyStreamOne select count(*) as cnt from " + typeof(SupportBean).FullName);
            EPStatement stmtInsertTwo = epService.EPAdministrator.CreateEPL("insert into MyStreamTwo select sum(cnt) as mysum from MyStreamOne");
            var         listener      = new SupportUpdateListener();

            stmtInsertTwo.Events += listener.Update;

            // execute
            var threadPool      = Executors.NewFixedThreadPool(numThreads);
            var future          = new Future <bool> [numThreads];
            var sharedStartLock = SupportContainer.Instance.RWLockManager().CreateDefaultLock();

            using (sharedStartLock.WriteLock.Acquire())
            {
                for (int i = 0; i < numThreads; i++)
                {
                    future[i] = threadPool.Submit(
                        new SendEventRWLockCallable(i, sharedStartLock.WriteLock, epService, new GeneratorIterator(numEvents)));
                }

                Thread.Sleep(100);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // assert result
            EventBean[] newEvents = listener.GetNewDataListFlattened();
            for (int i = 0; i < numEvents - 1; i++)
            {
                long expected = Total(i + 1);
                Assert.AreEqual(expected, newEvents[i].Get("mysum"));
            }

            stmtInsertOne.Dispose();
            stmtInsertTwo.Dispose();
        }
Exemplo n.º 26
0
        public void TestCreateSchemaModelAfter()
        {
            EnumHelper.ForEach <EventRepresentationChoice>(
                rep => RunAssertionCreateSchemaModelAfter(rep));

            // test model-after for PONO with inheritance
            _epService.EPAdministrator.CreateEPL("create window ParentWindow#keepall as select * from " + typeof(NWTypesParentClass).MaskTypeName());
            _epService.EPAdministrator.CreateEPL("insert into ParentWindow select * from " + typeof(NWTypesParentClass).MaskTypeName());
            _epService.EPAdministrator.CreateEPL("create window ChildWindow#keepall as select * from " + typeof(NWTypesChildClass).MaskTypeName());
            _epService.EPAdministrator.CreateEPL("insert into ChildWindow select * from " + typeof(NWTypesChildClass).MaskTypeName());

            var listener    = new SupportUpdateListener();
            var parentQuery = "@Name('Parent') select parent from ParentWindow as parent";

            _epService.EPAdministrator.CreateEPL(parentQuery).AddListener(listener);

            _epService.EPRuntime.SendEvent(new NWTypesChildClass());
            Assert.AreEqual(1, listener.GetNewDataListFlattened().Length);
        }
Exemplo n.º 27
0
        private void RunAssertionGroupByHaving(bool join)
        {
            string epl = !join ?
                         "select * from SupportBean.win:length_batch(3) group by TheString having count(*) > 1" :
                         "select TheString, IntPrimitive from SupportBean_S0.std:lastevent(), SupportBean.win:length_batch(3) group by TheString having count(*) > 1";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

            stmt.AddListener(_testListener);

            _epService.EPRuntime.SendEvent(new SupportBean_S0(1));
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 10));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 20));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 21));

            EventBean[] received = _testListener.GetNewDataListFlattened();
            EPAssertionUtil.AssertPropsPerRow(received, "TheString,IntPrimitive".Split(','),
                                              new object[][] { new object[] { "E2", 20 }, new object[] { "E2", 21 } });
            _testListener.Reset();
            stmt.Dispose();
        }
        private void RunAssertionGroupByHaving(EPServiceProvider epService, bool join)
        {
            string epl = !join ?
                         "select * from SupportBean#length_batch(3) group by TheString having count(*) > 1" :
                         "select TheString, IntPrimitive from SupportBean_S0#lastevent, SupportBean#length_batch(3) group by TheString having count(*) > 1";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(epl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean_S0(1));
            epService.EPRuntime.SendEvent(new SupportBean("E1", 10));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 20));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 21));

            EventBean[] received = listener.GetNewDataListFlattened();
            EPAssertionUtil.AssertPropsPerRow(received, "TheString,IntPrimitive".Split(','),
                                              new object[][] { new object[] { "E2", 20 }, new object[] { "E2", 21 } });
            listener.Reset();
            stmt.Dispose();
        }
Exemplo n.º 29
0
        private void RunAssertionCreateSchemaModelAfter(EPServiceProvider epService)
        {
            foreach (EventRepresentationChoice rep in EnumHelper.GetValues <EventRepresentationChoice>())
            {
                TryAssertionCreateSchemaModelAfter(epService, rep);
            }

            // test model-after for PONO with inheritance
            epService.EPAdministrator.CreateEPL("create window ParentWindow#keepall as select * from " + typeof(NWTypesParentClass).MaskTypeName());
            epService.EPAdministrator.CreateEPL("insert into ParentWindow select * from " + typeof(NWTypesParentClass).MaskTypeName());
            epService.EPAdministrator.CreateEPL("create window ChildWindow#keepall as select * from " + typeof(NWTypesChildClass).MaskTypeName());
            epService.EPAdministrator.CreateEPL("insert into ChildWindow select * from " + typeof(NWTypesChildClass).MaskTypeName());

            var    listener    = new SupportUpdateListener();
            string parentQuery = "@Name('Parent') select parent from ParentWindow as parent";

            epService.EPAdministrator.CreateEPL(parentQuery).Events += listener.Update;

            epService.EPRuntime.SendEvent(new NWTypesChildClass());
            Assert.AreEqual(1, listener.GetNewDataListFlattened().Length);

            epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunAssertionMeasurePresence(EPServiceProvider engine, long baseTime, string select, object value)
        {
            engine.EPRuntime.SendEvent(new CurrentTimeEvent(baseTime));
            string epl = "select * from SupportBean  " +
                         "match_recognize (" +
                         "    measures A as a, A.TheString as id, " + select + " as val " +
                         "    pattern (A B*) " +
                         "    interval 1 minute " +
                         "    define " +
                         "        A as (A.IntPrimitive=1)," +
                         "        B as (B.IntPrimitive=2))";
            SupportUpdateListener listener = new SupportUpdateListener();

            engine.EPAdministrator.CreateEPL(epl).AddListener(listener);

            engine.EPRuntime.SendEvent(new SupportBean("E1", 1));
            engine.EPRuntime.SendEvent(new SupportBean("E2", 2));

            engine.EPRuntime.SendEvent(new CurrentTimeSpanEvent(baseTime + 60 * 1000 * 2));
            Assert.AreEqual(value, listener.GetNewDataListFlattened()[0].Get("val"));

            engine.EPAdministrator.DestroyAllStatements();
        }