public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            env.AdvanceTime(0);
            env.CompileDeploy("@Name('0') create schema StatementMetric as " + typeof(StatementMetric).FullName);
            env.CompileDeploy("@Name('A') create window MyWindow#lastevent as select * from SupportBean", path);
            env.CompileDeploy("@Name('B1') insert into MyWindow select * from SupportBean", path);
            env.CompileDeploy("@Name('B2') insert into MyWindow select * from SupportBean", path);
            env.CompileDeploy("@Name('C') select sum(IntPrimitive) from MyWindow", path);
            env.CompileDeploy("@Name('D') select sum(w1.IntPrimitive) from MyWindow w1, MyWindow w2", path);

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

            env.CompileDeploy("@Name('X') select * from " + typeof(StatementMetric).FullName).AddListener("X");
            var fields = new [] { "StatementName","NumInput" };
            
            env.SendEventBean(new SupportBean("E1", 1));
            env.AdvanceTime(1000);
            var received = ArrayHandlingUtil.Reorder("StatementName", env.Listener("X").NewDataListFlattened);
            foreach (var theEvent in received) {
                Log.Info(theEvent.Get("StatementName") + " = " + theEvent.Get("NumInput"));
            }

            EPAssertionUtil.AssertPropsPerRow(
                received,
                fields,
                new[] {
                    new object[] {"A", 2L},
                    new object[] {"B1", 1L},
                    new object[] {"B2", 1L},
                    new object[] {"C", 2L},
                    new object[] {"D", 2L},
                    new object[] {"M", 1L},
                    new object[] {"W", 1L}
                });

            env.UndeployAll();
        }
Beispiel #2
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            epService.EPAdministrator.CreateEPL("@Name('0') create schema StatementMetric as " + typeof(StatementMetric).FullName);
            epService.EPAdministrator.CreateEPL("@Name('A') create window MyWindow#lastevent as select * from SupportBean");
            epService.EPAdministrator.CreateEPL("@Name('B1') insert into MyWindow select * from SupportBean");
            epService.EPAdministrator.CreateEPL("@Name('B2') insert into MyWindow select * from SupportBean");
            epService.EPAdministrator.CreateEPL("@Name('C') select sum(IntPrimitive) from MyWindow");
            epService.EPAdministrator.CreateEPL("@Name('D') select sum(w1.IntPrimitive) from MyWindow w1, MyWindow w2");

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

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

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

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

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

            /* Comment-in for printout.
             * for (int i = 0; i < received.Length; i++) {
             *  EventBean @event = received[i];
             *  Log.Info(@event.Get("statementName") + " " + @event.Get("wallTime") + " " + @event.Get("numInput"));
             * }
             */
        }
Beispiel #3
0
        public void TestNamedWindowAndViewShare()
        {
            _epService = EPServiceProviderManager.GetDefaultProvider(GetConfig(-1, 1000, false));
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            _epService.EPAdministrator.CreateEPL("@Name('0') create schema StatementMetric as " + typeof(StatementMetric).FullName);
            _epService.EPAdministrator.CreateEPL("@Name('A') create window MyWindow.std:lastevent() as select * from SupportBean");
            _epService.EPAdministrator.CreateEPL("@Name('B1') insert into MyWindow select * from SupportBean");
            _epService.EPAdministrator.CreateEPL("@Name('B2') insert into MyWindow select * from SupportBean");
            _epService.EPAdministrator.CreateEPL("@Name('C') select sum(IntPrimitive) from MyWindow");
            _epService.EPAdministrator.CreateEPL("@Name('D') select sum(w1.IntPrimitive) from MyWindow w1, MyWindow w2");

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

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

            EPStatement stmt = _epService.EPAdministrator.CreateEPL("@Name('X') select * from StatementMetric");

            stmt.Events += _listener.Update;
            String[] fields = "StatementName,numInput".Split(',');

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000));
            EventBean[] received = ArrayHandlingUtil.Reorder("StatementName", _listener.GetNewDataListFlattened());

            received.ToList().ForEach(
                theEvent => Debug.WriteLine(theEvent.Get("StatementName") + " = " + theEvent.Get("numInput")));

            EPAssertionUtil.AssertPropsPerRow(
                received, fields,
                new Object[][]
            {
                new Object[] { "A", 2L },
                new Object[] { "B1", 1L },
                new Object[] { "B2", 1L },
                new Object[] { "C", 2L },
                new Object[] { "D", 2L },
                new Object[] { "M", 1L },
                new Object[] { "W", 1L }
            });

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }