Example #1
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();
        }
        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();
        }
Example #3
0
            public void Run(RegressionEnvironment env)
            {
                if (env.IsHA) {
                    return;
                }

                var graph = "@Name('flow') 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" +
                            "DefaultSupportCaptureOp(outstream) {}\n";
                env.AdvanceTime(0);
                env.CompileDeploy(graph);

                var capture = new DefaultSupportCaptureOp();
                var operators = CollectionUtil.PopulateNameValueMap("DefaultSupportCaptureOp", capture);

                var options =
                    new EPDataFlowInstantiationOptions().WithOperatorProvider(
                        new DefaultSupportGraphOpProviderByOpName(operators));
                var instance = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MySelect", options);
                var captive = instance.StartCaptive();
                var emitter = captive.Emitters.Get("emitterS0");

                env.AdvanceTime(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);

                env.AdvanceTime(60000 + 5000);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    (object[]) capture.GetCurrentAndReset()[0],
                    new [] { "sumInt" },
                    new object[] {14});

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

                env.AdvanceTime(120000 + 5000);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    (object[]) capture.GetCurrentAndReset()[0],
                    new [] { "sumInt" },
                    new object[] {14 + 9});

                instance.Cancel();

                emitter.Submit(new SupportBean("E5", 6));
                env.AdvanceTime(240000 + 5000);
                Assert.AreEqual(0, capture.GetCurrentAndReset().Length);

                env.UndeployAll();
            }
        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();
        }
Example #5
0
            public void Run(RegressionEnvironment env)
            {
                if (env.IsHA) {
                    return;
                }

                var graph = "@Name('flow') 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" +
                            "DefaultSupportCaptureOp(outstream) {}\n";
                env.CompileDeploy(graph);

                var capture = new DefaultSupportCaptureOp();
                var operators = CollectionUtil.PopulateNameValueMap("DefaultSupportCaptureOp", capture);

                var options =
                    new EPDataFlowInstantiationOptions().WithOperatorProvider(
                        new DefaultSupportGraphOpProviderByOpName(operators));
                var instance = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MySelect", options);

                var captive = instance.StartCaptive();

                captive.Emitters.Get("emitterS0").Submit(new SupportBean_S0(1, "S0_1"));
                EPAssertionUtil.AssertProps(
                    env.Container,
                    (object[]) capture.GetCurrentAndReset()[0],
                    new [] { "P00","P11" },
                    new object[] {"S0_1", null});

                instance.Cancel();
                env.UndeployAll();
            }
        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();
        }
Example #7
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();
        }
Example #8
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();
        }
Example #9
0
 private static void AssertDataflowIds(
     EPDataFlowInstanceCaptive captive,
     string id,
     long[] longs,
     DefaultSupportCaptureOp<object> capture,
     string csv)
 {
     captive.Emitters.Get("emitterS0").Submit(new SupportEventWithLongArray(id, longs));
     var received = (string[]) ((object[]) capture.GetCurrentAndReset()[0])[0];
     EPAssertionUtil.AssertEqualsAnyOrder(csv.SplitCsv(), received);
 }
        public void Run(RegressionEnvironment env)
        {
            if (env.IsHA) {
                return;
            }

            var epl = "@Name('flow') 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#time(30) group by word)\n" +
                      "}\n" +
                      "Select(wordcount) -> wordranks { // Rank of words\n" +
                      "  select: (select window(*) as rankedWords from wordcount#sort(3, wordcount desc) output snapshot every 2 seconds)\n" +
                      "}\n" +
                      "DefaultSupportCaptureOp(wordranks) {}";
            env.EventService.AdvanceTime(0);
            env.CompileDeploy(epl);

            // prepare test
            var capture = new DefaultSupportCaptureOp();
            var options = new EPDataFlowInstantiationOptions();
            options.WithOperatorProvider(new DefaultSupportGraphOpProvider(capture));

            var instanceOne = env.Runtime.DataFlowService.Instantiate(
                env.DeploymentId("flow"),
                "RollingTopWords",
                options);
            var emitter = instanceOne.StartCaptive().Emitters.Get("a");

            foreach (var word in new[] {"this", "is", "a", "test", "that", "is", "a", "word", "test"}) {
                emitter.Submit(new object[] {word});
            }

            Assert.AreEqual(0, capture.GetCurrentAndReset().Length);

            env.AdvanceTime(2000);
            Assert.AreEqual(1, capture.Current.Length);
            var row = capture.Current[0].UnwrapIntoArray<object>();
            var rows = row[0].UnwrapIntoArray<object>();
            EPAssertionUtil.AssertPropsPerRow(
                env.Container,
                rows,
                new[] {"word", "count"},
                new[] {
                    new object[] {"is", 2L},
                    new object[] {"a", 2L},
                    new object[] {"test", 2L}
                });

            instanceOne.Cancel();

            env.UndeployAll();
        }
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddImport(GetType().FullName);

            var 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#time(30) group by word)\n" +
                      "}\n" +
                      "Select(wordcount) -> wordranks { // Rank of words\n" +
                      "  select: (select window(*) as rankedWords from wordcount#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
            var capture = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager());
            var options = new EPDataFlowInstantiationOptions();

            options.OperatorProvider(new DefaultSupportGraphOpProvider(capture));

            var instanceOne = epService.EPRuntime.DataFlowRuntime.Instantiate("RollingTopWords", options);
            var emitter     = instanceOne.StartCaptive().Emitters.Get("a");

            foreach (var 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.Current.Length);
            var map  = (IDictionary <string, object>)capture.Current[0];
            var rows = map.Get("rankedWords").UnwrapIntoList <object[]>();

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

            instanceOne.Cancel();
        }
Example #12
0
        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();
        }
Example #13
0
        private static void RunAssertionAllTypes(
            RegressionEnvironment env,
            string typeName,
            SendableEvent[] events)
        {
            env.CompileDeploy(
                "@Name('flow') create dataflow MyDataFlowOne " +
                "EventBusSource -> ReceivedStream<" + typeName + "> {} " +
                "DefaultSupportCaptureOp(ReceivedStream) {}");

            var future = new DefaultSupportCaptureOp();
            var options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(future));
            var eventService = (EventServiceSendEventCommon) env.EventService;

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

            var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);

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

            df.Start();

            // send events
            for (var i = 0; i < events.Length; i++) {
                events[i].Send(eventService);
            }

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

            df.Cancel();

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

            env.UndeployAll();
        }
Example #14
0
            private void TryAssertionJoinOrder(
                RegressionEnvironment env,
                string fromClause)
            {
                var graph = "@Name('flow') 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" +
                            "DefaultSupportCaptureOp(outstream) {}\n";
                env.CompileDeploy(graph);

                var capture = new DefaultSupportCaptureOp();
                var operators = CollectionUtil.PopulateNameValueMap("DefaultSupportCaptureOp", capture);

                var options =
                    new EPDataFlowInstantiationOptions().WithOperatorProvider(
                        new DefaultSupportGraphOpProviderByOpName(operators));
                var instance = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MySelect", options);

                var 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.Current.Length);

                captive.Emitters.Get("emitterS2").Submit(new SupportBean_S2(100));
                Assert.AreEqual(1, capture.Current.Length);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    (object[]) capture.GetCurrentAndReset()[0],
                    new [] { "s0Id","s1Id","s2Id" },
                    new object[] {1, 10, 100});

                instance.Cancel();

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

                env.UndeployAll();
            }
        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();
        }
        public void TestStatementFilter()
        {
            _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
            var 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();
            var options   = new EPDataFlowInstantiationOptions();
            var myFilter  = new MyFilter();

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

            df.Start();

            _epService.EPRuntime.SendEvent(new SupportBean_B("B1"));
            captureOp.WaitForInvocation(200, 1);
            EPAssertionUtil.AssertProps(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(captureOp.GetCurrentAndReset()[0], "TheString,IntPrimitive".Split(','), new Object[] { "E1", 1 });

            var stmtTwo = _epService.EPAdministrator.CreateEPL("select id from SupportBean_A");

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

            stmtTwo.Stop();

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

            stmtTwo.Start();

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

            _epService.EPRuntime.SendEvent(new SupportBean_B("B2"));
            captureOp.WaitForInvocation(200, 1);
            EPAssertionUtil.AssertProps(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.GetCurrent().Length);
        }
Example #17
0
            public void Run(RegressionEnvironment env)
            {
                // one statement exists before the data flow
                env.CompileDeploy("select Id from SupportBean_B");

                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowOne " +
                    "create schema AllObjects as System.Object," +
                    "EPStatementSource -> thedata<AllObjects> {} " +
                    "DefaultSupportCaptureOp(thedata) {}");

                var captureOp = new DefaultSupportCaptureOp(env.Container.LockManager());
                var options = new EPDataFlowInstantiationOptions();
                var myFilter = new MyFilter();
                options.WithParameterProvider(
                    new DefaultSupportGraphParamProvider(
                        Collections.SingletonMap<string, object>("statementFilter", myFilter)));
                options.WithOperatorProvider(new DefaultSupportGraphOpProvider(captureOp));
                var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);
                df.Start();

                env.SendEventBean(new SupportBean_B("B1"));
                captureOp.WaitForInvocation(200, 1);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    captureOp.GetCurrentAndReset()[0],
                    new [] { "Id" },
                    new object[] {"B1"});

                env.CompileDeploy("select TheString, IntPrimitive from SupportBean");
                env.SendEventBean(new SupportBean("E1", 1));
                captureOp.WaitForInvocation(200, 1);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    captureOp.GetCurrentAndReset()[0],
                    new [] { "TheString","IntPrimitive" },
                    new object[] {"E1", 1});

                env.CompileDeploy("@Name('s2') select Id from SupportBean_A");
                env.SendEventBean(new SupportBean_A("A1"));
                captureOp.WaitForInvocation(200, 1);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    captureOp.GetCurrentAndReset()[0],
                    new [] { "Id" },
                    new object[] {"A1"});

                env.UndeployModuleContaining("s2");

                env.SendEventBean(new SupportBean_A("A2"));
                Sleep(50);
                Assert.AreEqual(0, captureOp.Current.Length);

                env.CompileDeploy("@Name('s2') select Id from SupportBean_A");

                env.SendEventBean(new SupportBean_A("A3"));
                captureOp.WaitForInvocation(200, 1);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    captureOp.GetCurrentAndReset()[0],
                    new [] { "Id" },
                    new object[] {"A3"});

                env.SendEventBean(new SupportBean_B("B2"));
                captureOp.WaitForInvocation(200, 1);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    captureOp.GetCurrentAndReset()[0],
                    new [] { "Id" },
                    new object[] {"B2"});

                df.Cancel();

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

                env.UndeployAll();
            }
Example #18
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowOne " +
                    "create map schema SingleProp (Id string), " +
                    "EPStatementSource -> thedata<SingleProp> {" +
                    "  statementDeploymentId : 'MyDeploymentId'," +
                    "  statementName : 'MyStatement'," +
                    "} " +
                    "DefaultSupportCaptureOp(thedata) {}");

                var captureOp = new DefaultSupportCaptureOp();
                var options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProvider(captureOp));

                var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);
                Assert.IsNull(df.UserObject);
                Assert.IsNull(df.InstanceId);
                df.Start();

                env.SendEventBean(new SupportBean("E1", 1));
                Assert.AreEqual(0, captureOp.Current.Length);

                var epl = "@Name('MyStatement') select TheString as Id from SupportBean";
                var compiled = env.Compile(epl);
                try {
                    env.Deployment.Deploy(compiled, new DeploymentOptions().WithDeploymentId("MyDeploymentId"));
                }
                catch (EPDeployException e) {
                    Assert.Fail(e.Message);
                }

                env.SendEventBean(new SupportBean("E2", 2));
                captureOp.WaitForInvocation(100, 1);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    captureOp.GetCurrentAndReset()[0],
                    new [] { "Id" },
                    new object[] {"E2"});

                env.UndeployModuleContaining("MyStatement");

                env.SendEventBean(new SupportBean("E3", 3));
                Assert.AreEqual(0, captureOp.Current.Length);

                try {
                    env.Deployment.Deploy(compiled, new DeploymentOptions().WithDeploymentId("MyDeploymentId"));
                }
                catch (EPDeployException e) {
                    Assert.Fail(e.Message);
                }

                env.SendEventBean(new SupportBean("E4", 4));
                captureOp.WaitForInvocation(100, 1);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    captureOp.GetCurrentAndReset()[0],
                    new [] { "Id" },
                    new object[] {"E4"});

                env.UndeployModuleContaining("MyStatement");

                env.SendEventBean(new SupportBean("E5", 5));
                Assert.AreEqual(0, captureOp.Current.Length);

                compiled = env.Compile("@Name('MyStatement') select 'X'||TheString||'X' as Id from SupportBean");
                try {
                    env.Deployment.Deploy(compiled, new DeploymentOptions().WithDeploymentId("MyDeploymentId"));
                }
                catch (EPDeployException e) {
                    Assert.Fail(e.Message);
                }

                env.SendEventBean(new SupportBean("E6", 6));
                captureOp.WaitForInvocation(100, 1);
                EPAssertionUtil.AssertProps(
                    env.Container,
                    captureOp.GetCurrentAndReset()[0],
                    new [] { "Id" },
                    new object[] {"XE6X"});

                df.Cancel();
                env.UndeployAll();
            }