Exemple #1
0
        public void TestInvalidJoinRun()
        {
            _epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "BeaconSource -> BeaconStream {iterations : 1}");

            var source = new DefaultSupportSourceOp(
                new Object[]
            {
                5000
            });
            EPDataFlowInstantiationOptions options =
                new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(source));
            EPDataFlowInstance dfOne = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            // invalid join
            try
            {
                dfOne.Join();
                Assert.Fail();
            }
            catch (IllegalStateException ex)
            {
                Assert.AreEqual(
                    "Data flow 'MyDataFlowOne' instance has not been executed, please use join after start or run",
                    ex.Message);
            }

            // cancel
            dfOne.Cancel();

            // invalid run and start
            try
            {
                dfOne.Run();
                Assert.Fail();
            }
            catch (IllegalStateException ex)
            {
                Assert.AreEqual(
                    "Data flow 'MyDataFlowOne' instance has been cancelled and cannot be run or started", ex.Message);
            }

            try
            {
                dfOne.Start();
                Assert.Fail();
            }
            catch (IllegalStateException ex)
            {
                Assert.AreEqual(
                    "Data flow 'MyDataFlowOne' instance has been cancelled and cannot be run or started", ex.Message);
            }

            // cancel again
            dfOne.Cancel();
        }
        private void RunAssertionOuterJoinMultirow(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>();
            epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_S1));

            string graph = "create dataflow MySelect\n" +
                           "Emitter -> instream_s0<SupportBean_S0>{name: 'emitterS0'}\n" +
                           "Emitter -> instream_s1<SupportBean_S1>{name: 'emitterS1'}\n" +
                           "Select(instream_s0 as S0, instream_s1 as S1) -> outstream {\n" +
                           "  select: (select p00, p10 from S0#keepall full outer join S1#keepall)\n" +
                           "}\n" +
                           "CaptureOp(outstream) {}\n";

            epService.EPAdministrator.CreateEPL(graph);

            var capture = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager());
            IDictionary <string, Object> operators = CollectionUtil.PopulateNameValueMap("CaptureOp", capture);

            var options = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
            EPDataFlowInstance instance = epService.EPRuntime.DataFlowRuntime.Instantiate("MySelect", options);

            EPDataFlowInstanceCaptive captive = instance.StartCaptive();

            captive.Emitters.Get("emitterS0").Submit(new SupportBean_S0(1, "S0_1"));
            EPAssertionUtil.AssertProps(
                epService.Container, capture.GetCurrentAndReset()[0], "p00,p11".Split(','), new object[] { "S0_1", null });

            instance.Cancel();
            epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunAssertionAllTypes(EPServiceProvider epService, string typeName, object[] events)
        {
            string graph = "create dataflow MySelect\n" +
                           "DefaultSupportSourceOp -> instream<" + typeName + ">{}\n" +
                           "Select(instream as ME) -> outstream {select: (select myString, sum(myInt) as total from ME)}\n" +
                           "DefaultSupportCaptureOp(outstream) {}";
            EPStatement stmtGraph = epService.EPAdministrator.CreateEPL(graph);

            var source  = new DefaultSupportSourceOp(events);
            var capture = new DefaultSupportCaptureOp(2, SupportContainer.Instance.LockManager());
            var options = new EPDataFlowInstantiationOptions();

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

            instance.Run();

            object[] result = capture.GetAndReset()[0].ToArray();
            EPAssertionUtil.AssertPropsPerRow(
                epService.Container, result, "myString,total".Split(','), new object[][] { new object[] { "one", 1 }, new object[] { "two", 3 } });

            instance.Cancel();

            stmtGraph.Dispose();
        }
Exemple #4
0
        private static void RunAssertionAfterExec(EPDataFlowInstance df)
        {
            // cancel and join ignored
            df.Join();

            // can't start or run again
            try
            {
                df.Run();
                Assert.Fail();
            }
            catch (IllegalStateException ex)
            {
                Assert.AreEqual(
                    "Data flow 'MyDataFlowOne' instance has already completed, please use instantiate to run the data flow again",
                    ex.Message);
            }

            try
            {
                df.Start();
                Assert.Fail();
            }
            catch (IllegalStateException ex)
            {
                Assert.AreEqual(
                    "Data flow 'MyDataFlowOne' instance has already completed, please use instantiate to run the data flow again",
                    ex.Message);
            }

            df.Cancel();
            df.Join();
        }
Exemple #5
0
        public void RunAssertionJoinOrder(String fromClause)
        {
            String graph = "create dataflow MySelect\n" +
                           "Emitter -> instream_s0<SupportBean_S0>{name: 'emitterS0'}\n" +
                           "Emitter -> instream_s1<SupportBean_S1>{name: 'emitterS1'}\n" +
                           "Emitter -> instream_s2<SupportBean_S2>{name: 'emitterS2'}\n" +
                           "Select(instream_s0 as S0, instream_s1 as S1, instream_s2 as S2) -> outstream {\n" +
                           "  select: (select s0.id as s0id, s1.id as s1id, s2.id as s2id " + fromClause + ")\n" +
                           "}\n" +
                           "CaptureOp(outstream) {}\n";
            EPStatement stmtGraph = _epService.EPAdministrator.CreateEPL(graph);

            DefaultSupportCaptureOp      capture   = new DefaultSupportCaptureOp();
            IDictionary <String, Object> operators = CollectionUtil.PopulateNameValueMap("CaptureOp", capture);

            EPDataFlowInstantiationOptions options  = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
            EPDataFlowInstance             instance = _epService.EPRuntime.DataFlowRuntime.Instantiate("MySelect", options);

            EPDataFlowInstanceCaptive captive = instance.StartCaptive();

            captive.Emitters.Get("emitterS0").Submit(new SupportBean_S0(1));
            captive.Emitters.Get("emitterS1").Submit(new SupportBean_S1(10));
            Assert.AreEqual(0, capture.GetCurrent().Length);

            captive.Emitters.Get("emitterS2").Submit(new SupportBean_S2(100));
            Assert.AreEqual(1, capture.GetCurrent().Length);
            EPAssertionUtil.AssertProps(capture.GetCurrentAndReset()[0], "s0id,s1id,s2id".Split(','), new Object[] { 1, 10, 100 });

            instance.Cancel();

            captive.Emitters.Get("emitterS2").Submit(new SupportBean_S2(101));
            Assert.AreEqual(0, capture.GetCurrent().Length);

            stmtGraph.Dispose();
        }
Exemple #6
0
        private void RunAssertionOA(bool underlying)
        {
            EPStatement stmtGraph = _epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                                         "EventBusSource -> ReceivedStream<" + (underlying ? "MyEvent" : "EventBean<MyEvent>") + "> {} " +
                                                                         "DefaultSupportCaptureOp(ReceivedStream) {}");

            DefaultSupportCaptureOp        future  = new DefaultSupportCaptureOp(1);
            EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions()
                                                     .OperatorProvider(new DefaultSupportGraphOpProvider(future));

            EPDataFlowInstance instance = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            instance.Start();

            _epService.EPRuntime.SendEvent(new Object[] { "abc", 100L }, "MyEvent");
            Object[] rows = future.GetValue(TimeSpan.FromSeconds(1));
            Assert.AreEqual(1, rows.Length);
            if (underlying)
            {
                EPAssertionUtil.AssertEqualsExactOrder((Object[])rows[0], new Object[] { "abc", 100L });
            }
            else
            {
                EPAssertionUtil.AssertProps((EventBean)rows[0], "p0,p1".Split(','), new Object[] { "abc", 100L });
            }

            instance.Cancel();
            stmtGraph.Dispose();
        }
        private void RunAssertionStatementNameExists(EPServiceProvider epService, string typeName, object[] events)
        {
            epService.EPAdministrator.CreateEPL("@Name('MyStatement') select * from " + typeName);

            epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                "create schema AllObject System.Object," +
                                                "EPStatementSource -> thedata<AllObject> {" +
                                                "  statementName : 'MyStatement'," +
                                                "} " +
                                                "DefaultSupportCaptureOp(thedata) {}");

            var captureOp = new DefaultSupportCaptureOp(2, SupportContainer.Instance.LockManager());
            var options   = new EPDataFlowInstantiationOptions()
                            .OperatorProvider(new DefaultSupportGraphOpProvider(captureOp));

            EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            df.Start();

            EventSender sender = epService.EPRuntime.GetEventSender(typeName);

            foreach (Object @event in events)
            {
                sender.SendEvent(@event);
            }

            captureOp.GetValue(1, TimeUnit.SECONDS);
            EPAssertionUtil.AssertEqualsExactOrder(events, captureOp.Current);

            df.Cancel();
            epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunAssertionOA(EPServiceProvider epService, bool underlying)
        {
            EPStatement stmtGraph = epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                                        "EventBusSource -> ReceivedStream<" + (underlying ? "MyEventOA" : "EventBean<MyEventOA>") + "> {} " +
                                                                        "DefaultSupportCaptureOp(ReceivedStream) {}");

            var future  = new DefaultSupportCaptureOp(1, SupportContainer.Instance.LockManager());
            var options = new EPDataFlowInstantiationOptions()
                          .OperatorProvider(new DefaultSupportGraphOpProvider(future));

            EPDataFlowInstance instance = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            instance.Start();

            epService.EPRuntime.SendEvent(new object[] { "abc", 100L }, "MyEventOA");
            object[] rows = future.GetValue(1, TimeUnit.SECONDS);
            Assert.AreEqual(1, rows.Length);
            if (underlying)
            {
                EPAssertionUtil.AssertEqualsExactOrder((object[])rows[0], new object[] { "abc", 100L });
            }
            else
            {
                EPAssertionUtil.AssertProps((EventBean)rows[0], "p0,p1".Split(','), new object[] { "abc", 100L });
            }

            instance.Cancel();
            stmtGraph.Dispose();
        }
Exemple #9
0
        private void RunAssertionAllTypes(String typeName, Object[] events)
        {
            String graph = "create dataflow MySelect\n" +
                           "DefaultSupportSourceOp -> instream.with.dot<" + typeName + ">{}\n" +
                           "Filter(instream.with.dot) -> outstream.dot {filter: myString = 'two'}\n" +
                           "DefaultSupportCaptureOp(outstream.dot) {}";
            EPStatement stmtGraph = _epService.EPAdministrator.CreateEPL(graph);

            DefaultSupportSourceOp         source  = new DefaultSupportSourceOp(events);
            DefaultSupportCaptureOp        capture = new DefaultSupportCaptureOp(2);
            EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();

            options.SetDataFlowInstanceUserObject("myuserobject");
            options.SetDataFlowInstanceId("myinstanceid");

            options.OperatorProvider(new DefaultSupportGraphOpProvider(source, capture));
            EPDataFlowInstance instance = _epService.EPRuntime.DataFlowRuntime.Instantiate("MySelect", options);

            Assert.AreEqual("myuserobject", instance.UserObject);
            Assert.AreEqual("myinstanceid", instance.InstanceId);

            instance.Run();

            Object[] result = capture.GetAndReset()[0].ToArray();
            Assert.AreEqual(1, result.Length);
            Assert.AreSame(events[1], result[0]);

            instance.Cancel();

            stmtGraph.Dispose();
        }
Exemple #10
0
        public void TestTimeWindowTriggered()
        {
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            String graph = "create dataflow MySelect\n" +
                           "Emitter -> instream_s0<SupportBean>{name: 'emitterS0'}\n" +
                           "Select(instream_s0) -> outstream {\n" +
                           "  select: (select sum(IntPrimitive) as sumInt from instream_s0.win:time(1 minute))\n" +
                           "}\n" +
                           "CaptureOp(outstream) {}\n";

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            _epService.EPAdministrator.CreateEPL(graph);

            DefaultSupportCaptureOp      capture   = new DefaultSupportCaptureOp();
            IDictionary <String, Object> operators = CollectionUtil.PopulateNameValueMap("CaptureOp", capture);

            EPDataFlowInstantiationOptions options  = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
            EPDataFlowInstance             instance = _epService.EPRuntime.DataFlowRuntime.Instantiate("MySelect", options);
            EPDataFlowInstanceCaptive      captive  = instance.StartCaptive();

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(5000));
            captive.Emitters.Get("emitterS0").Submit(new SupportBean("E1", 2));
            EPAssertionUtil.AssertProps(capture.GetCurrentAndReset()[0], "sumInt".Split(','), new Object[] { 2 });

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(10000));
            captive.Emitters.Get("emitterS0").Submit(new SupportBean("E2", 5));
            EPAssertionUtil.AssertProps(capture.GetCurrentAndReset()[0], "sumInt".Split(','), new Object[] { 7 });

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(65000));
            EPAssertionUtil.AssertProps(capture.GetCurrentAndReset()[0], "sumInt".Split(','), new Object[] { 5 });

            instance.Cancel();
        }
Exemple #11
0
        public void TestOuterJoinMultirow()
        {
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_S0));
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_S1));

            String graph = "create dataflow MySelect\n" +
                           "Emitter -> instream_s0<SupportBean_S0>{name: 'emitterS0'}\n" +
                           "Emitter -> instream_s1<SupportBean_S1>{name: 'emitterS1'}\n" +
                           "Select(instream_s0 as S0, instream_s1 as S1) -> outstream {\n" +
                           "  select: (select p00, p10 from S0.win:keepall() full outer join S1.win:keepall())\n" +
                           "}\n" +
                           "CaptureOp(outstream) {}\n";

            _epService.EPAdministrator.CreateEPL(graph);

            DefaultSupportCaptureOp      capture   = new DefaultSupportCaptureOp();
            IDictionary <String, Object> operators = CollectionUtil.PopulateNameValueMap("CaptureOp", capture);

            EPDataFlowInstantiationOptions options  = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
            EPDataFlowInstance             instance = _epService.EPRuntime.DataFlowRuntime.Instantiate("MySelect", options);

            EPDataFlowInstanceCaptive captive = instance.StartCaptive();

            captive.Emitters.Get("emitterS0").Submit(new SupportBean_S0(1, "S0_1"));
            EPAssertionUtil.AssertProps(capture.GetCurrentAndReset()[0], "p00,p11".Split(','), new Object[] { "S0_1", null });

            instance.Cancel();
        }
Exemple #12
0
        public override void Run(EPServiceProvider epService)
        {
            MyExceptionHandler.Contexts.Clear();
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            // test exception by graph source
            EPStatement stmtGraph = epService.EPAdministrator.CreateEPL("create dataflow MyDataFlow DefaultSupportSourceOp -> outstream<SupportBean> {}");

            var op      = new DefaultSupportSourceOp(new object[] { new EPRuntimeException("My-Exception-Is-Here") });
            var options = new EPDataFlowInstantiationOptions();

            options.OperatorProvider(new DefaultSupportGraphOpProvider(op));
            var handler = new MyExceptionHandler();

            options.ExceptionHandler(handler);
            EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlow", options);

            df.Start();
            Thread.Sleep(100);
            Assert.AreEqual(EPDataFlowState.COMPLETE, df.State);

            Assert.AreEqual(1, MyExceptionHandler.Contexts.Count);
            EPDataFlowExceptionContext context = MyExceptionHandler.Contexts[0];

            Assert.AreEqual("MyDataFlow", context.DataFlowName);
            Assert.AreEqual("DefaultSupportSourceOp", context.OperatorName);
            Assert.AreEqual(0, context.OperatorNumber);
            Assert.AreEqual("DefaultSupportSourceOp#0() -> outstream<SupportBean>", context.OperatorPrettyPrint);
            Assert.AreEqual("Support-graph-source generated exception: My-Exception-Is-Here", context.Exception.Message);
            df.Cancel();
            stmtGraph.Dispose();
            MyExceptionHandler.Contexts.Clear();

            // test exception by operator
            epService.EPAdministrator.Configuration.AddImport(typeof(MyExceptionOp));
            epService.EPAdministrator.CreateEPL("create dataflow MyDataFlow DefaultSupportSourceOp -> outstream<SupportBean> {}" +
                                                "MyExceptionOp(outstream) {}");

            var opTwo      = new DefaultSupportSourceOp(new object[] { new SupportBean("E1", 1) });
            var optionsTwo = new EPDataFlowInstantiationOptions();

            optionsTwo.OperatorProvider(new DefaultSupportGraphOpProvider(opTwo));
            var handlerTwo = new MyExceptionHandler();

            optionsTwo.ExceptionHandler(handlerTwo);
            EPDataFlowInstance dfTwo = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlow", optionsTwo);

            dfTwo.Start();
            Thread.Sleep(100);

            Assert.AreEqual(1, MyExceptionHandler.Contexts.Count);
            EPDataFlowExceptionContext contextTwo = MyExceptionHandler.Contexts[0];

            Assert.AreEqual("MyDataFlow", contextTwo.DataFlowName);
            Assert.AreEqual("MyExceptionOp", contextTwo.OperatorName);
            Assert.AreEqual(1, contextTwo.OperatorNumber);
            Assert.AreEqual("MyExceptionOp#1(outstream)", contextTwo.OperatorPrettyPrint);
            Assert.AreEqual("Operator-thrown-exception", contextTwo.Exception.Message);
        }
        private void RunAssertionStmtNameDynamic(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                "create map schema SingleProp (id string), " +
                                                "EPStatementSource -> thedata<SingleProp> {" +
                                                "  statementName : 'MyStatement'," +
                                                "} " +
                                                "DefaultSupportCaptureOp(thedata) {}");

            var captureOp = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager());
            var options   = new EPDataFlowInstantiationOptions()
                            .OperatorProvider(new DefaultSupportGraphOpProvider(captureOp));

            EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            Assert.IsNull(df.UserObject);
            Assert.IsNull(df.InstanceId);
            df.Start();

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.AreEqual(0, captureOp.Current.Length);

            EPStatement stmt = epService.EPAdministrator.CreateEPL("@Name('MyStatement') select TheString as id from SupportBean");

            epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            captureOp.WaitForInvocation(100, 1);
            EPAssertionUtil.AssertProps(
                epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "E2" });

            stmt.Stop();

            epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            Assert.AreEqual(0, captureOp.Current.Length);

            stmt.Start();

            epService.EPRuntime.SendEvent(new SupportBean("E4", 4));
            captureOp.WaitForInvocation(100, 1);
            EPAssertionUtil.AssertProps(
                epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "E4" });

            stmt.Dispose();

            epService.EPRuntime.SendEvent(new SupportBean("E5", 5));
            Assert.AreEqual(0, captureOp.Current.Length);

            epService.EPAdministrator.CreateEPL("@Name('MyStatement') select 'X'||TheString||'X' as id from SupportBean");

            epService.EPRuntime.SendEvent(new SupportBean("E6", 6));
            captureOp.WaitForInvocation(100, 1);
            EPAssertionUtil.AssertProps(
                epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "XE6X" });

            df.Cancel();
            epService.EPAdministrator.DestroyAllStatements();
        }
Exemple #14
0
        public void TestBlockingCancel()
        {
            // declare
            _epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "SourceOne -> outstream<SomeType> {}" +
                "OutputOp(outstream) {}");

            // instantiate
            var latchOne = new CountDownLatch(1);
            IDictionary <String, Object> ops = new Dictionary <String, Object>();

            ops.Put(
                "SourceOne", new DefaultSupportSourceOp(
                    new Object[]
            {
                latchOne, new Object[]
                {
                    1
                }
            }));
            var output = new DefaultSupportCaptureOp();

            ops["OutputOp"] = output;

            EPDataFlowInstantiationOptions options =
                new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProviderByOpName(ops));
            EPDataFlowInstance dfOne = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            var cancellingThread = new Thread(
                () =>
            {
                try
                {
                    Thread.Sleep(300);
                    dfOne.Cancel();
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e.StackTrace);
                }
            });

            cancellingThread.Start();

            try
            {
                dfOne.Run();
                Assert.Fail();
            }
            catch (EPDataFlowCancellationException ex)
            {
                Assert.AreEqual("Data flow 'MyDataFlowOne' execution was cancelled", ex.Message);
            }
            Assert.AreEqual(EPDataFlowState.CANCELLED, dfOne.State);
            Assert.AreEqual(0, output.GetAndReset().Count);
        }
Exemple #15
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddImport(typeof(DefaultSupportCaptureOp).Name);

            string[] fields = "p0,p1".Split(',');
            epService.EPAdministrator.Configuration.AddEventType("MyOAEventType", fields, new object[] { typeof(string), typeof(int) });

            epService.EPAdministrator.CreateEPL("create dataflow MyDataFlow " +
                                                "Emitter -> outstream<MyOAEventType> {name:'src1'}" +
                                                "DefaultSupportCaptureOp(outstream) {}");

            var container = epService.Container;
            var captureOp = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager());
            var options   = new EPDataFlowInstantiationOptions();

            options.OperatorProvider(new DefaultSupportGraphOpProvider(captureOp));

            EPDataFlowInstance        instance     = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlow", options);
            EPDataFlowInstanceCaptive captiveStart = instance.StartCaptive();

            Assert.AreEqual(0, captiveStart.Runnables.Count);
            Assert.AreEqual(1, captiveStart.Emitters.Count);
            Emitter emitter = captiveStart.Emitters.Get("src1");

            Assert.AreEqual(EPDataFlowState.RUNNING, instance.State);

            emitter.Submit(new object[] { "E1", 10 });
            EPAssertionUtil.AssertPropsPerRow(container, captureOp.Current, fields, new object[][] { new object[] { "E1", 10 } });

            emitter.Submit(new object[] { "E2", 20 });
            EPAssertionUtil.AssertPropsPerRow(container, captureOp.Current, fields, new object[][] { new object[] { "E1", 10 }, new object[] { "E2", 20 } });

            emitter.SubmitSignal(new EPDataFlowSignalFinalMarkerImpl());
            EPAssertionUtil.AssertPropsPerRow(container, captureOp.Current, fields, new Object[0][]);
            EPAssertionUtil.AssertPropsPerRow(container, captureOp.GetAndReset()[0].ToArray(), fields, new object[][] { new object[] { "E1", 10 }, new object[] { "E2", 20 } });

            emitter.Submit(new object[] { "E3", 30 });
            EPAssertionUtil.AssertPropsPerRow(container, captureOp.Current, fields, new object[][] { new object[] { "E3", 30 } });

            // stays running until cancelled (no transition to complete)
            Assert.AreEqual(EPDataFlowState.RUNNING, instance.State);

            instance.Cancel();
            Assert.AreEqual(EPDataFlowState.CANCELLED, instance.State);

            // test doc sample
            string epl = "create dataflow HelloWorldDataFlow\n" +
                         "  create schema SampleSchema(text string),\t// sample type\t\t\n" +
                         "\t\n" +
                         "  Emitter -> helloworld.stream<SampleSchema> { name: 'myemitter' }\n" +
                         "  LogSink(helloworld.stream) {}";

            epService.EPAdministrator.CreateEPL(epl);
            epService.EPRuntime.DataFlowRuntime.Instantiate("HelloWorldDataFlow");
        }
        private void RunAssertionOutputRateLimit(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            string graph = "create dataflow MySelect\n" +
                           "Emitter -> instream_s0<SupportBean>{name: 'emitterS0'}\n" +
                           "Select(instream_s0) -> outstream {\n" +
                           "  select: (select sum(IntPrimitive) as sumInt from instream_s0 output snapshot every 1 minute)\n" +
                           "}\n" +
                           "CaptureOp(outstream) {}\n";

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            epService.EPAdministrator.CreateEPL(graph);

            var capture = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager());
            IDictionary <string, Object> operators = CollectionUtil.PopulateNameValueMap("CaptureOp", capture);

            var options = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
            EPDataFlowInstance        instance = epService.EPRuntime.DataFlowRuntime.Instantiate("MySelect", options);
            EPDataFlowInstanceCaptive captive  = instance.StartCaptive();
            Emitter emitter = captive.Emitters.Get("emitterS0");

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(5000));
            emitter.Submit(new SupportBean("E1", 5));
            emitter.Submit(new SupportBean("E2", 3));
            emitter.Submit(new SupportBean("E3", 6));
            Assert.AreEqual(0, capture.GetCurrentAndReset().Length);

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(60000 + 5000));
            EPAssertionUtil.AssertProps(
                epService.Container, capture.GetCurrentAndReset()[0], "sumInt".Split(','), new object[] { 14 });

            emitter.Submit(new SupportBean("E4", 3));
            emitter.Submit(new SupportBean("E5", 6));
            Assert.AreEqual(0, capture.GetCurrentAndReset().Length);

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(120000 + 5000));
            EPAssertionUtil.AssertProps(
                epService.Container, capture.GetCurrentAndReset()[0], "sumInt".Split(','), new object[] { 14 + 9 });

            instance.Cancel();

            emitter.Submit(new SupportBean("E5", 6));
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(240000 + 5000));
            Assert.AreEqual(0, capture.GetCurrentAndReset().Length);

            epService.EPAdministrator.DestroyAllStatements();
        }
        public void TestGraph()
        {
            String epl = "create dataflow RollingTopWords\n" +
                         "create objectarray schema WordEvent (word string),\n" +
                         "Emitter -> wordstream<WordEvent> {name:'a'} // Produces word stream\n" +
                         "Select(wordstream) -> wordcount { // Sliding time window count per word\n" +
                         "  select: (select word, Count(*) as wordcount from wordstream.win:time(30) group by word)\n" +
                         "}\n" +
                         "Select(wordcount) -> wordranks { // Rank of words\n" +
                         "  select: (select Window(*) as rankedWords from wordcount.ext:sort(3, wordcount desc) output snapshot every 2 seconds)\n" +
                         "}\n" +
                         "DefaultSupportCaptureOp(wordranks) {}";

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            _epService.EPAdministrator.CreateEPL(epl);

            // prepare test
            DefaultSupportCaptureOp        capture = new DefaultSupportCaptureOp();
            EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();

            options.OperatorProvider(new DefaultSupportGraphOpProvider(capture));

            EPDataFlowInstance instanceOne = _epService.EPRuntime.DataFlowRuntime.Instantiate("RollingTopWords", options);
            Emitter            emitter     = instanceOne.StartCaptive().Emitters.Get("a");

            foreach (String word in new String[] { "this", "is", "a", "test", "that", "is", "a", "word", "test" })
            {
                emitter.Submit(new Object[] { word });
            }
            Assert.AreEqual(0, capture.GetCurrentAndReset().Length);

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(2000));
            Assert.AreEqual(1, capture.GetCurrent().Length);
            Map map = (Map)capture.GetCurrent()[0];
            IList <Object[]> rows = (Object[][])map.Get("rankedWords");

            EPAssertionUtil.AssertPropsPerRow(
                rows,
                "word,count".Split(','),
                new Object[][]
            {
                new Object[] { "is", 2L },
                new Object[] { "a", 2L },
                new Object[] { "test", 2L }
            });

            instanceOne.Cancel();
        }
        private void RunAssertionAllTypes(EPServiceProvider epService, string typeName, SendableEvent[] events)
        {
            EPStatement stmtGraph = epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                                        "EventBusSource -> ReceivedStream<" + typeName + "> {} " +
                                                                        "DefaultSupportCaptureOp(ReceivedStream) {}");

            var future  = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager());
            var options = new EPDataFlowInstantiationOptions()
                          .OperatorProvider(new DefaultSupportGraphOpProvider(future));

            events[0].Send(epService.EPRuntime);
            Assert.AreEqual(0, future.Current.Length);

            EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            events[0].Send(epService.EPRuntime);
            Assert.AreEqual(0, future.Current.Length);

            df.Start();

            // send events
            for (int i = 0; i < events.Length; i++)
            {
                events[i].Send(epService.EPRuntime);
            }

            // assert
            future.WaitForInvocation(200, events.Length);
            object[] rows = future.GetCurrentAndReset();
            Assert.AreEqual(events.Length, rows.Length);
            for (int i = 0; i < events.Length; i++)
            {
                Assert.AreSame(events[i].Underlying, rows[i]);
            }

            df.Cancel();

            events[0].Send(epService.EPRuntime);
            Thread.Sleep(50);
            Assert.AreEqual(0, future.Current.Length);

            stmtGraph.Dispose();
        }
Exemple #19
0
        public void TestNonBlockingJoinCancel()
        {
            _epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "DefaultSupportSourceOp -> outstream<SomeType> {}" +
                "DefaultSupportCaptureOp(outstream) {}");

            var latchOne = new CountDownLatch(1);
            var src      = new DefaultSupportSourceOp(
                new Object[]
            {
                latchOne
            });
            var output = new DefaultSupportCaptureOp();
            EPDataFlowInstantiationOptions options =
                new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(src, output));
            EPDataFlowInstance dfOne = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            dfOne.Start();

            var cancellingThread = new Thread(
                () =>
            {
                try
                {
                    Thread.Sleep(300);
                    dfOne.Cancel();
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e.StackTrace);
                }
            });

            cancellingThread.Start();
            dfOne.Join();

            Assert.AreEqual(EPDataFlowState.CANCELLED, dfOne.State);
            Assert.AreEqual(0, output.GetAndReset().Count);
        }
        private void RunAssertionIterateFinalMarker(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            string graph = "create dataflow MySelect\n" +
                           "Emitter -> instream_s0<SupportBean>{name: 'emitterS0'}\n" +
                           "@Audit Select(instream_s0 as ALIAS) -> outstream {\n" +
                           "  select: (select TheString, sum(IntPrimitive) as sumInt from ALIAS group by TheString order by TheString asc),\n" +
                           "  iterate: true" +
                           "}\n" +
                           "CaptureOp(outstream) {}\n";

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            epService.EPAdministrator.CreateEPL(graph);

            var capture = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager());
            IDictionary <string, Object> operators = CollectionUtil.PopulateNameValueMap("CaptureOp", capture);

            var options = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
            EPDataFlowInstance        instance = epService.EPRuntime.DataFlowRuntime.Instantiate("MySelect", options);
            EPDataFlowInstanceCaptive captive  = instance.StartCaptive();

            Emitter emitter = captive.Emitters.Get("emitterS0");

            emitter.Submit(new SupportBean("E3", 4));
            emitter.Submit(new SupportBean("E2", 3));
            emitter.Submit(new SupportBean("E1", 1));
            emitter.Submit(new SupportBean("E2", 2));
            emitter.Submit(new SupportBean("E1", 5));
            Assert.AreEqual(0, capture.Current.Length);

            emitter.SubmitSignal(new EPDataFlowSignalFinalMarkerImpl());
            EPAssertionUtil.AssertPropsPerRow(
                epService.Container, capture.Current,
                "TheString,sumInt".Split(','),
                new[] { new object[] { "E1", 6 }, new object[] { "E2", 5 }, new object[] { "E3", 4 } });

            instance.Cancel();
            epService.EPAdministrator.DestroyAllStatements();
        }
Exemple #21
0
        public void TestNonBlockingCancel()
        {
            // declare
            _epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "SourceOne -> outstream<SomeType> {}" +
                "OutputOp(outstream) {}");

            // instantiate
            var latchOne = new CountDownLatch(1);
            IDictionary <String, Object> ops = new Dictionary <String, Object>();

            ops.Put(
                "SourceOne", new DefaultSupportSourceOp(
                    new Object[]
            {
                latchOne, new Object[]
                {
                    1
                }
            }));
            var output = new DefaultSupportCaptureOp();

            ops["OutputOp"] = output;

            EPDataFlowInstantiationOptions options =
                new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProviderByOpName(ops));
            EPDataFlowInstance dfOne = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            dfOne.Start();
            Assert.AreEqual(EPDataFlowState.RUNNING, dfOne.State);

            dfOne.Cancel();

            latchOne.CountDown();
            Thread.Sleep(100);
            Assert.AreEqual(EPDataFlowState.CANCELLED, dfOne.State);
            Assert.AreEqual(0, output.GetAndReset().Count);
        }
Exemple #22
0
        public void TestNonBlockingJoinSingleRunnable()
        {
            // declare
            _epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "DefaultSupportSourceOp -> outstream<SomeType> {}" +
                "DefaultSupportCaptureOp(outstream) {}");

            // instantiate
            var latch  = new CountDownLatch(1);
            var source = new DefaultSupportSourceOp(
                new Object[]
            {
                latch, new Object[]
                {
                    1
                }
            });
            var future = new DefaultSupportCaptureOp(1);
            EPDataFlowInstantiationOptions options =
                new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(source, future));
            EPDataFlowInstance dfOne = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            Assert.AreEqual("MyDataFlowOne", dfOne.DataFlowName);
            Assert.AreEqual(EPDataFlowState.INSTANTIATED, dfOne.State);

            dfOne.Start();
            Thread.Sleep(100);
            Assert.AreEqual(EPDataFlowState.RUNNING, dfOne.State);

            latch.CountDown();
            dfOne.Join();
            Assert.AreEqual(EPDataFlowState.COMPLETE, dfOne.State);
            Assert.AreEqual(1, future.GetAndReset()[0].Count);
            Assert.AreEqual(2, source.GetCurrentCount());

            dfOne.Cancel();
            Assert.AreEqual(EPDataFlowState.COMPLETE, dfOne.State);
        }
Exemple #23
0
        private void RunAssertion(EPServiceProvider epService, string format, bool?log, string layout, string title, bool?linefeed)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            string graph = "create dataflow MyConsoleOut\n" +
                           "Emitter -> instream<SupportBean>{name : 'e1'}\n" +
                           "LogSink(instream) {\n" +
                           (format == null ? "" : "  format: '" + format + "',\n") +
                           (log == null ? "" : "  log: " + log + ",\n") +
                           (layout == null ? "" : "  layout: '" + layout + "',\n") +
                           (title == null ? "" : "  title: '" + title + "',\n") +
                           (linefeed == null ? "" : "  linefeed: " + linefeed + ",\n") +
                           "}";
            EPStatement stmtGraph = epService.EPAdministrator.CreateEPL(graph);

            EPDataFlowInstance instance = epService.EPRuntime.DataFlowRuntime.Instantiate("MyConsoleOut");

            Emitter emitter = instance.StartCaptive().Emitters.Get("e1");

            emitter.Submit(new SupportBean("E1", 1));

            instance.Cancel();
            stmtGraph.Dispose();
        }
        private void RunAssertionStatementFilter(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_A));
            epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_B));

            // one statement Exists before the data flow
            EPStatement stmt = epService.EPAdministrator.CreateEPL("select id from SupportBean_B");

            epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                "create schema AllObjects Object," +
                                                "EPStatementSource -> thedata<AllObjects> {} " +
                                                "DefaultSupportCaptureOp(thedata) {}");

            var captureOp = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager());
            var options   = new EPDataFlowInstantiationOptions();
            var myFilter  = new MyFilter();

            options.ParameterProvider(new DefaultSupportGraphParamProvider(Collections.SingletonDataMap("statementFilter", myFilter)));
            options.OperatorProvider(new DefaultSupportGraphOpProvider(captureOp));
            EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            df.Start();

            epService.EPRuntime.SendEvent(new SupportBean_B("B1"));
            captureOp.WaitForInvocation(200, 1);
            EPAssertionUtil.AssertProps(
                epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "B1" });

            epService.EPAdministrator.CreateEPL("select TheString, IntPrimitive from SupportBean");
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            captureOp.WaitForInvocation(200, 1);
            EPAssertionUtil.AssertProps(
                epService.Container, captureOp.GetCurrentAndReset()[0], "TheString,IntPrimitive".Split(','), new object[] { "E1", 1 });

            EPStatement stmtTwo = epService.EPAdministrator.CreateEPL("select id from SupportBean_A");

            epService.EPRuntime.SendEvent(new SupportBean_A("A1"));
            captureOp.WaitForInvocation(200, 1);
            EPAssertionUtil.AssertProps(
                epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "A1" });

            stmtTwo.Stop();

            epService.EPRuntime.SendEvent(new SupportBean_A("A2"));
            Thread.Sleep(50);
            Assert.AreEqual(0, captureOp.Current.Length);

            stmtTwo.Start();

            epService.EPRuntime.SendEvent(new SupportBean_A("A3"));
            captureOp.WaitForInvocation(200, 1);
            EPAssertionUtil.AssertProps(
                epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "A3" });

            epService.EPRuntime.SendEvent(new SupportBean_B("B2"));
            captureOp.WaitForInvocation(200, 1);
            EPAssertionUtil.AssertProps(
                epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "B2" });

            df.Cancel();

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean_A("A1"));
            epService.EPRuntime.SendEvent(new SupportBean_B("B3"));
            Assert.AreEqual(0, captureOp.Current.Length);

            epService.EPAdministrator.DestroyAllStatements();
        }
Exemple #25
0
        private void RunAssertionAudit(EPServiceProvider epService)
        {
            // stream, and test audit callback
            var callback = new SupportAuditCallback();

            AuditPath.AuditCallback = callback.Audit;
            AUDITLOG.Info("*** Stream: ");
            EPStatement stmtInput = epService.EPAdministrator.CreateEPL("@Name('ABC') @Audit('stream') select * from SupportBean(TheString = 'E1')");

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.AreEqual(1, callback.Audits.Count);
            AuditContext cb = callback.Audits[0];

            Assert.AreEqual("SupportBean(TheString=...) inserted SupportBean[SupportBean(E1, 1)]", cb.Message);
            Assert.AreEqual("ABC", cb.StatementName);
            Assert.AreEqual(EPServiceProviderConstants.DEFAULT_ENGINE_URI, cb.EngineURI);
            Assert.AreEqual(AuditEnum.STREAM, cb.Category);
            AuditPath.AuditCallback = null;
            stmtInput.Dispose();

            AUDITLOG.Info("*** Named Window And Insert-Into: ");
            EPStatement stmtNW        = epService.EPAdministrator.CreateEPL("@Name('create') @Audit create window WinOne#keepall as SupportBean");
            EPStatement stmtInsertNW  = epService.EPAdministrator.CreateEPL("@Name('insert') @Audit insert into WinOne select * from SupportBean");
            EPStatement stmtConsumeNW = epService.EPAdministrator.CreateEPL("@Name('select') @Audit select * from WinOne");

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            stmtNW.Dispose();
            stmtInsertNW.Dispose();
            stmtConsumeNW.Dispose();

            AUDITLOG.Info("*** Insert-Into: ");
            EPStatement stmtInsertInto = epService.EPAdministrator.CreateEPL("@Name('insert') @Audit insert into ABC select * from SupportBean");

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            stmtInsertInto.Dispose();

            AUDITLOG.Info("*** Schedule: ");
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            EPStatement stmtSchedule = epService.EPAdministrator.CreateEPL("@Name('ABC') @Audit('schedule') select irstream * from SupportBean#time(1 sec)");
            var         listener     = new SupportUpdateListener();

            stmtSchedule.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            listener.Reset();
            Log.Info("Sending time");
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(2000));
            Assert.IsTrue(listener.IsInvoked);
            listener.Reset();
            stmtSchedule.Dispose();

            // exprdef-instances
            AUDITLOG.Info("*** Expression-Def: ");
            EPStatement stmtExprDef = epService.EPAdministrator.CreateEPL("@Name('ABC') @Audit('exprdef') " +
                                                                          "expression DEF { 1 } " +
                                                                          "expression INN {  x => x.TheString }" +
                                                                          "expression OUT { x => INN(x) } " +
                                                                          "select DEF(), OUT(sb) from SupportBean sb");

            stmtExprDef.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.AreEqual(1, listener.AssertOneGetNewAndReset().Get("DEF()"));
            stmtExprDef.Dispose();

            // pattern-instances
            AUDITLOG.Info("*** Pattern-Lifecycle: ");
            EPStatement stmtPatternLife = epService.EPAdministrator.CreateEPL("@Name('ABC') @Audit('pattern-instances') select a.IntPrimitive as val0 from pattern [every a=SupportBean -> (b=SupportBean_ST0 and not SupportBean_ST1)]");

            stmtPatternLife.Events += listener.Update;
            Log.Info("Sending E1");
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Log.Info("Sending E2");
            epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            Log.Info("Sending E3");
            epService.EPRuntime.SendEvent(new SupportBean_ST1("E3", 3));
            stmtPatternLife.Dispose();

            // pattern
            AUDITLOG.Info("*** Pattern: ");
            EPStatement stmtPattern = epService.EPAdministrator.CreateEPL("@Name('ABC') @Audit('pattern') select a.IntPrimitive as val0 from pattern [a=SupportBean -> b=SupportBean_ST0]");

            stmtPattern.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean_ST0("E2", 2));
            Assert.AreEqual(1, listener.AssertOneGetNewAndReset().Get("val0"));
            stmtPattern.Dispose();

            // view
            AUDITLOG.Info("*** View: ");
            EPStatement stmtView = epService.EPAdministrator.CreateEPL("@Name('ABC') @Audit('view') select IntPrimitive from SupportBean#lastevent");

            stmtView.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 50));
            Assert.AreEqual(50, listener.AssertOneGetNewAndReset().Get("IntPrimitive"));
            stmtView.Dispose();

            EPStatement stmtGroupedView = epService.EPAdministrator.CreateEPL("@Audit Select * From SupportBean#groupwin(TheString)#length(2)");

            stmtGroupedView.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 50));
            listener.Reset();
            stmtGroupedView.Dispose();

            EPStatement stmtGroupedWIntersectionView = epService.EPAdministrator.CreateEPL("@Audit Select * From SupportBean#groupwin(TheString)#length(2)#unique(IntPrimitive)");

            stmtGroupedWIntersectionView.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 50));
            listener.Reset();
            stmtGroupedWIntersectionView.Dispose();

            // expression
            AUDITLOG.Info("*** Expression: ");
            EPStatement stmtExpr = epService.EPAdministrator.CreateEPL("@Name('ABC') @Audit('expression') select IntPrimitive*100 as val0, sum(IntPrimitive) as val1 from SupportBean");

            stmtExpr.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 50));
            Assert.AreEqual(5000, listener.AssertOneGetNew().Get("val0"));
            Assert.AreEqual(50, listener.AssertOneGetNewAndReset().Get("val1"));
            stmtExpr.Dispose();

            // expression-detail
            AUDITLOG.Info("*** Expression-Nested: ");
            EPStatement stmtExprNested = epService.EPAdministrator.CreateEPL("@Name('ABC') @Audit('expression-nested') select ('A'||TheString)||'X' as val0 from SupportBean");

            stmtExprNested.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 50));
            Assert.AreEqual("AE1X", listener.AssertOneGetNewAndReset().Get("val0"));
            stmtExprNested.Dispose();

            // property
            AUDITLOG.Info("*** Property: ");
            EPStatement stmtProp = epService.EPAdministrator.CreateEPL("@Name('ABC') @Audit('property') select IntPrimitive from SupportBean");

            stmtProp.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 50));
            Assert.AreEqual(50, listener.AssertOneGetNewAndReset().Get("IntPrimitive"));
            stmtProp.Dispose();

            // with aggregation
            epService.EPAdministrator.CreateEPL("@Audit @Name ('create') create window MyWindow#keepall as SupportBean");
            string      eplWithAgg  = "@Audit @Name('S0') on SupportBean as sel select count(*) from MyWindow as win having count(*)=3 order by win.IntPrimitive";
            EPStatement stmtWithAgg = epService.EPAdministrator.CreateEPL(eplWithAgg);

            stmtWithAgg.Dispose();

            // data flow
            EPStatement stmtDataflow = epService.EPAdministrator.CreateEPL("@Audit @Name('df') create dataflow MyFlow " +
                                                                           "EventBusSource -> a<SupportBean> {filter:TheString like 'I%'} " +
                                                                           "Filter(a) -> b {filter: true}" +
                                                                           "LogSink(b) {log:false}");
            EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyFlow");

            df.Start();
            epService.EPRuntime.SendEvent(new SupportBean("I1", 1));
            df.Cancel();

            // context partitions
            epService.EPAdministrator.CreateEPL("create context WhenEventArrives " +
                                                "initiated by SupportBean_ST0 as st0 " +
                                                "terminated by SupportBean_ST1(id=st0.id)");
            epService.EPAdministrator.CreateEPL("@Audit('ContextPartition') context WhenEventArrives select * from SupportBean");
            epService.EPRuntime.SendEvent(new SupportBean_ST0("E1", 0));
            epService.EPRuntime.SendEvent(new SupportBean_ST1("E1", 0));
            stmtDataflow.Dispose();

            // table
            AUDITLOG.Info("*** Table And Insert-Into and Into-table: ");
            EPStatement stmtTable       = epService.EPAdministrator.CreateEPL("@Name('create-table') @Audit create table TableOne(c0 string primary key, cnt count(*))");
            EPStatement stmtIntoTable   = epService.EPAdministrator.CreateEPL("@Name('into-table') @Audit into table TableOne select count(*) as cnt from SupportBean group by TheString");
            EPStatement stmtAccessTable = epService.EPAdministrator.CreateEPL("@Name('access-table') @Audit select TableOne[id].cnt from SupportBean_ST0");

            stmtAccessTable.Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean_ST0("E1", 0));
            stmtTable.Dispose();
            stmtIntoTable.Dispose();
            stmtAccessTable.Dispose();
        }