Example #1
0
        private void RunAssertionFactorial(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddImport(typeof(MyFactorialOp));

            string epl = "create dataflow FactorialGraph \n" +
                         "" +
                         "create objectarray schema InputSchema (number int),\n" +
                         "create objectarray schema TempSchema (current int, temp long),\n" +
                         "create objectarray schema FinalSchema (result long),\n" +
                         "\n" +
                         "BeaconSource -> InputData<InputSchema> {number:5, iterations:1}\n" +
                         "\n" +
                         "MyFactorialOp(InputData as Input, TempResult as Temp) -> TempResult<TempSchema>, FinalResult<FinalSchema>{}\n" +
                         "\n" +
                         "DefaultSupportCaptureOp(FinalResult) {}\n";

            epService.EPAdministrator.CreateEPL(epl);

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

            epService.EPRuntime.DataFlowRuntime.Instantiate("FactorialGraph", options).Start();

            object[] result = future.GetValue(3, TimeUnit.SECONDS);
            Assert.AreEqual(1, result.Length);
            Assert.AreEqual((long)5 * 4 * 3 * 2, ((object[])result[0])[0]);

            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();
        }
Example #3
0
        private void RunAssertionFastCompleteNonBlocking(EPServiceProvider epService)
        {
            // declare
            epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "BeaconSource -> BeaconStream {iterations : 1}" +
                "DefaultSupportCaptureOp(BeaconStream) {}");

            // instantiate
            var future = new DefaultSupportCaptureOp(1, SupportContainer.Instance.LockManager());
            var options =
                new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(future));
            var dfOne = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);
            Assert.AreEqual("MyDataFlowOne", dfOne.DataFlowName);
            Assert.AreEqual(EPDataFlowState.INSTANTIATED, dfOne.State);
            Assert.IsFalse(future.IsDone());

            // non-blocking run, spinning wait
            dfOne.Start();
            var start = PerformanceObserver.MilliTime;
            while (dfOne.State != EPDataFlowState.COMPLETE)
            {
                if (PerformanceObserver.MilliTime - start > 1000)
                {
                    Assert.Fail();
                }
            }

            Assert.AreEqual(1, future.GetValue(TimeSpan.Zero).Length);

            // assert past-exec
            TryAssertionAfterExec(dfOne);
            epService.EPAdministrator.DestroyAllStatements();
        }
Example #4
0
        private void RunAssertionFastCompleteBlocking(EPServiceProvider epService)
        {
            // declare
            epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "BeaconSource -> BeaconStream {iterations : 1}" +
                "DefaultSupportCaptureOp(BeaconStream) {}");

            // instantiate
            var future = new DefaultSupportCaptureOp(1, SupportContainer.Instance.LockManager());
            var options =
                new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(future));
            var dfOne = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);
            Assert.AreEqual("MyDataFlowOne", dfOne.DataFlowName);
            Assert.AreEqual(EPDataFlowState.INSTANTIATED, dfOne.State);

            // has not run
            Thread.Sleep(1000);
            Assert.IsFalse(future.IsDone());

            // blocking run
            dfOne.Run();
            Assert.AreEqual(EPDataFlowState.COMPLETE, dfOne.State);
            Assert.AreEqual(1, future.GetValue(TimeSpan.Zero).Length);

            // assert past-exec
            TryAssertionAfterExec(dfOne);

            epService.EPAdministrator.DestroyAllStatements();
        }
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create Schema SomeEvent()", path);
                env.CompileDeploy("create variable int var_iterations=3", path);
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowOne " +
                    "BeaconSource -> BeaconStream<SomeEvent> {" +
                    "  iterations : var_iterations" +
                    "}" +
                    "DefaultSupportCaptureOp(BeaconStream) {}",
                    path);

                var future = new DefaultSupportCaptureOp(3, env.Container.LockManager());
                var options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProvider(future));
                var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);
                df.Start();
                object[] output;
                try {
                    output = future.GetValue(2, TimeUnit.SECONDS);
                }
                catch (Exception t) {
                    throw new EPException(t);
                }

                Assert.AreEqual(3, output.Length);
                env.UndeployAll();
            }
        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();
        }
        public void Run(RegressionEnvironment env)
        {
            var epl = "@Name('flow') create dataflow WordCount " +
                      "MyLineFeedSource -> LineOfTextStream {} " +
                      "MyTokenizerCounter(LineOfTextStream) -> SingleLineCountStream {}" +
                      "MyWordCountAggregator(SingleLineCountStream) -> WordCountStream {}" +
                      "DefaultSupportCaptureOp(WordCountStream) {}";
            env.CompileDeploy(epl);

            var future = new DefaultSupportCaptureOp(1, env.Container.LockManager());
            var source = new MyLineFeedSource(Arrays.AsList("Test this code", "Test line two").GetEnumerator());

            var options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(future, source));

            env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "WordCount", options).Start();

            var received = new object[0];
            try {
                received = future.GetValue(3, TimeUnit.SECONDS);
            }
            catch (Exception t) {
                throw new EPException(t);
            }

            Assert.AreEqual(1, received.Length);
            var stats = (MyWordCountStats) received[0];
            Assert.AreEqual(2, stats.Lines);
            Assert.AreEqual(6, stats.Words);
            Assert.AreEqual(23, stats.Chars);

            env.UndeployAll();
        }
Example #8
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();
        }
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddImport(typeof(MyTokenizerCounter).Namespace);
            epService.EPAdministrator.Configuration.AddImport(typeof(DefaultSupportCaptureOp).Namespace);

            var epl = "create dataflow WordCount " +
                      "MyLineFeedSource -> LineOfTextStream {} " +
                      "MyTokenizerCounter(LineOfTextStream) -> SingleLineCountStream {}" +
                      "MyWordCountAggregator(SingleLineCountStream) -> WordCountStream {}" +
                      "DefaultSupportCaptureOp(WordCountStream) {}";

            epService.EPAdministrator.CreateEPL(epl);

            var future = new DefaultSupportCaptureOp(1, SupportContainer.Instance.LockManager());
            var source = new MyLineFeedSource(Collections.List("Test this code", "Test line two").GetEnumerator());

            var options = new EPDataFlowInstantiationOptions()
                          .OperatorProvider(new DefaultSupportGraphOpProvider(future, source));

            epService.EPRuntime.DataFlowRuntime.Instantiate("WordCount", options).Start();

            var received = future.GetValue(3, TimeUnit.SECONDS);

            Assert.AreEqual(1, received.Length);
            var stats = (MyWordCountStats)received[0];

            EPAssertionUtil.AssertProps(
                epService.Container, stats, "Lines,Words,Chars".Split(','), new object[] { 2, 6, 23 });
        }
Example #10
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('flow') create dataflow FactorialGraph \n" +
                          "" +
                          "create objectarray schema InputSchema (number int),\n" +
                          "create objectarray schema TempSchema (current int, temp long),\n" +
                          "create objectarray schema FinalSchema (result long),\n" +
                          "\n" +
                          "BeaconSource -> InputData<InputSchema> {number:5, iterations:1}\n" +
                          "\n" +
                          "MyFactorialOp(InputData as Input, TempResult as Temp) -> TempResult<TempSchema>, FinalResult<FinalSchema>{}\n" +
                          "\n" +
                          "DefaultSupportCaptureOp(FinalResult) {}\n";
                env.CompileDeploy(epl);

                var future = new DefaultSupportCaptureOp(1, env.Container.LockManager());
                var options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProvider(future));

                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "FactorialGraph", options).Start();

                object[] result;
                try {
                    result = future.GetValue(3, TimeUnit.SECONDS);
                }
                catch (Exception t) {
                    throw new EPException(t);
                }

                Assert.AreEqual(1, result.Length);
                Assert.AreEqual((long) 5 * 4 * 3 * 2, ((object[]) result[0])[0]);

                env.UndeployAll();
            }
        private static object RunAssertionBeans(
            RegressionEnvironment env,
            string typeName)
        {
            env.CompileDeploy(
                "@Name('flow') create dataflow MyDataFlowOne " +
                "" +
                "BeaconSource -> BeaconStream<" +
                typeName +
                "> {" +
                "  Myfield : 'abc', iterations : 1" +
                "}" +
                "DefaultSupportCaptureOp(BeaconStream) {}");

            var future = new DefaultSupportCaptureOp(1, env.Container.LockManager());
            var options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(future));
            var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);
            df.Start();
            var output = new object[0];
            try {
                output = future.GetValue(2, TimeUnit.SECONDS);
            }
            catch (Exception t) {
                throw new EPException(t);
            }

            Assert.AreEqual(1, output.Length);
            env.UndeployAll();
            return output[0];
        }
Example #12
0
        private static void RunAssertion(RegressionEnvironment env)
        {
            var future = new DefaultSupportCaptureOp(1, env.Container.LockManager());
            var source = new MyObjectArrayGraphSource(
                Arrays.AsList(
                        new object[] {"trade", "GE", 100d, 1000L, null, null}, // vwap = 100, minPrice=100
                        new object[] {"quote", "GE", null, null, 99.5d, 2000L} //
                    )
                    .GetEnumerator());

            var options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(future, source));

            env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "VWAPSample", options).Start();

            object[] received;
            try {
                received = future.GetValue(5, TimeUnit.SECONDS);
            }
            catch (Exception t) {
                throw new EPException(t);
            }

            Assert.AreEqual(1, received.Length);

            var receivedArray = received[0].UnwrapIntoArray<object>();
            EPAssertionUtil.AssertProps(
                env.Container,
                receivedArray,
                new string[] { "index" },
                new object[] { 2000 * Math.Exp(100 - 99.5) });

            env.UndeployAll();
        }
        public void TestFactorial()
        {
            _epService.EPAdministrator.Configuration.AddImport(typeof(MyFactorialOp).FullName);
            _epService.EPAdministrator.Configuration.AddImport(typeof(DefaultSupportCaptureOp));

            String epl = "create dataflow FactorialGraph \n" +
                         "" +
                         "create objectarray schema InputSchema (number int),\n" +
                         "create objectarray schema TempSchema (current int, temp long),\n" +
                         "create objectarray schema FinalSchema (result long),\n" +
                         "\n" +
                         "BeaconSource -> InputData<InputSchema> {number:5, iterations:1}\n" +
                         "\n" +
                         "MyFactorialOp(InputData as Input, TempResult as Temp) -> TempResult<TempSchema>, FinalResult<FinalSchema>{}\n" +
                         "\n" +
                         "DefaultSupportCaptureOp(FinalResult) {}\n";

            _epService.EPAdministrator.CreateEPL(epl);

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

            _epService.EPRuntime.DataFlowRuntime.Instantiate("FactorialGraph", options).Start();

            Object[] result = future.GetValue(TimeSpan.FromSeconds(3));
            Assert.AreEqual(1, result.Length);
            Assert.AreEqual((long)5 * 4 * 3 * 2, ((Object[])result[0])[0]);
        }
        private void RunAssertionStatementNameExists(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);
            var options   = new EPDataFlowInstantiationOptions()
                            .OperatorProvider(new DefaultSupportGraphOpProvider(captureOp));

            var df = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            df.Start();

            var sender = _epService.EPRuntime.GetEventSender(typeName);

            foreach (var theEvent in events)
            {
                sender.SendEvent(theEvent);
            }

            captureOp.GetValue(TimeSpan.FromSeconds(1));
            EPAssertionUtil.AssertEqualsExactOrder(events, captureOp.GetCurrent());

            df.Cancel();
            _epService.EPAdministrator.DestroyAllStatements();
        }
Example #15
0
        public void TestFastCompleteNonBlocking()
        {
            // declare
            _epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "BeaconSource -> BeaconStream {iterations : 1}" +
                "DefaultSupportCaptureOp(BeaconStream) {}");

            // instantiate
            var future = new DefaultSupportCaptureOp(1);
            EPDataFlowInstantiationOptions options =
                new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(future));
            EPDataFlowInstance dfOne = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

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

            // non-blocking run, spinning wait
            dfOne.Start();
            long start = Environment.TickCount;

            while (dfOne.State != EPDataFlowState.COMPLETE)
            {
                if (Environment.TickCount - start > 1000)
                {
                    Assert.Fail();
                }
            }
            Assert.AreEqual(1, future.GetValue(TimeSpan.MaxValue).Length);

            // assert past-exec
            RunAssertionAfterExec(dfOne);
        }
Example #16
0
        public void TestFastCompleteBlocking()
        {
            // declare
            _epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "BeaconSource -> BeaconStream {iterations : 1}" +
                "DefaultSupportCaptureOp(BeaconStream) {}");

            // instantiate
            var future = new DefaultSupportCaptureOp(1);
            EPDataFlowInstantiationOptions options =
                new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(future));
            EPDataFlowInstance dfOne = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

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

            // has not run
            Thread.Sleep(1000);
            Assert.IsFalse(future.IsDone());

            // blocking run
            dfOne.Run();
            Assert.AreEqual(EPDataFlowState.COMPLETE, dfOne.State);
            Assert.AreEqual(1, future.GetValue(TimeSpan.MaxValue).Length);

            // assert past-exec
            RunAssertionAfterExec(dfOne);
        }
Example #17
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('flow') create dataflow MultiInMultiOutGraph \n" +
                          "" +
                          "create objectarray schema SchemaOne (p1 string),\n" +
                          "create objectarray schema SchemaTwo (p2 int),\n" +
                          "\n" +
                          "BeaconSource -> InOne<SchemaOne> {p1:'A1', iterations:1}\n" +
                          "BeaconSource -> InTwo<SchemaOne> {p1:'A2', iterations:1}\n" +
                          "\n" +
                          "BeaconSource -> InThree<SchemaTwo> {p2:10, iterations:1}\n" +
                          "BeaconSource -> InFour<SchemaTwo> {p2:20, iterations:1}\n" +
                          "MyCustomOp((InOne, InTwo) as S0, (InThree, InFour) as S1) -> OutOne<SchemaTwo>, OutTwo<SchemaOne>{}\n" +
                          "\n" +
                          "DefaultSupportCaptureOp(OutOne) { name : 'SupportOpCountFutureOneA' }\n" +
                          "DefaultSupportCaptureOp(OutOne) { name : 'SupportOpCountFutureOneB' }\n" +
                          "DefaultSupportCaptureOp(OutTwo) { name : 'SupportOpCountFutureTwoA' }\n" +
                          "DefaultSupportCaptureOp(OutTwo) { name : 'SupportOpCountFutureTwoB' }\n";
                env.CompileDeploy(epl);

                var futureOneA = new DefaultSupportCaptureOp(2, env.Container.LockManager());
                var futureOneB = new DefaultSupportCaptureOp(2, env.Container.LockManager());
                var futureTwoA = new DefaultSupportCaptureOp(2, env.Container.LockManager());
                var futureTwoB = new DefaultSupportCaptureOp(2, env.Container.LockManager());

                IDictionary<string, object> operators = new Dictionary<string, object>();
                operators.Put("SupportOpCountFutureOneA", futureOneA);
                operators.Put("SupportOpCountFutureOneB", futureOneB);
                operators.Put("SupportOpCountFutureTwoA", futureTwoA);
                operators.Put("SupportOpCountFutureTwoB", futureTwoB);

                var options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));

                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MultiInMultiOutGraph", options)
                    .Start();

                try {
                    EPAssertionUtil.AssertEqualsAnyOrder(
                        new[] {new object[] {"S1-10"}, new object[] {"S1-20"}},
                        futureOneA.GetValue(3, TimeUnit.SECONDS));
                    EPAssertionUtil.AssertEqualsAnyOrder(
                        new[] {new object[] {"S1-10"}, new object[] {"S1-20"}},
                        futureOneB.GetValue(3, TimeUnit.SECONDS));
                    EPAssertionUtil.AssertEqualsAnyOrder(
                        new[] {new object[] {"S0-A1"}, new object[] {"S0-A2"}},
                        futureTwoA.GetValue(3, TimeUnit.SECONDS));
                    EPAssertionUtil.AssertEqualsAnyOrder(
                        new[] {new object[] {"S0-A1"}, new object[] {"S0-A2"}},
                        futureTwoB.GetValue(3, TimeUnit.SECONDS));
                }
                catch (Exception t) {
                    throw new EPException(t);
                }

                env.UndeployAll();
            }
        private void RunAssertionFields(EventRepresentationEnum representationEnum, bool eventbean)
        {
            EPDataFlowInstantiationOptions options;

            _epService.EPAdministrator.CreateEPL("create " + representationEnum.GetOutputTypeCreateSchemaName() + " schema MyEvent(p0 string, p1 long, p2 double)");
            var stmtGraph = _epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                                 "" +
                                                                 "BeaconSource -> BeaconStream<" + (eventbean ? "EventBean<MyEvent>" : "MyEvent") + "> {" +
                                                                 "  iterations : 3," +
                                                                 "  p0 : 'abc'," +
                                                                 "  p1 : MyMath.Round(MyMath.Random() * 10) + 1," +
                                                                 "  p2 : 1d," +
                                                                 "}" +
                                                                 "DefaultSupportCaptureOp(BeaconStream) {}");

            var future = new DefaultSupportCaptureOp(3);

            options = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(future));
            var df = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            df.Start();
            Object[] output = future.GetValue(TimeSpan.FromSeconds(2));
            Assert.AreEqual(3, output.Length);
            for (var i = 0; i < 3; i++)
            {
                if (!eventbean)
                {
                    if (representationEnum.IsObjectArrayEvent())
                    {
                        var row = (Object[])output[i];
                        Assert.AreEqual("abc", row[0]);
                        long val = row[1].AsLong();
                        Assert.IsTrue(val >= 0 && val <= 11, "val=" + val);
                        Assert.AreEqual(1d, row[2]);
                    }
                    else
                    {
                        var row = (DataMap)output[i];
                        Assert.AreEqual("abc", row.Get("p0"));
                        long val = row.Get("p1").AsLong();
                        Assert.IsTrue(val >= 0 && val <= 11, "val=" + val);
                        Assert.AreEqual(1d, row.Get("p2"));
                    }
                }
                else
                {
                    var row = (EventBean)output[i];
                    Assert.AreEqual("abc", row.Get("p0"));
                }
            }

            stmtGraph.Dispose();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyEvent", true);
        }
Example #19
0
            public void Run(RegressionEnvironment env)
            {
                if (env.IsHA) {
                    return;
                }

                var epl = "@Name('flow') create dataflow MyGraph \n" +
                          "" +
                          "create objectarray schema SchemaOne (p1 string),\n" +
                          "\n" +
                          "BeaconSource -> InStream<SchemaOne> {p1:'A1', iterations:1}\n" +
                          "select(InStream) -> out_1 { select: (select p1 from InStream) }\n" +
                          "select(out_1) -> out_2 { select: (select p1 from out_1) }\n" +
                          "select(out_2) -> out_3 { select: (select p1 from out_2) }\n" +
                          "select(out_3) -> out_4 { select: (select p1 from out_3) }\n" +
                          "select(out_4) -> out_5 { select: (select p1 from out_4) }\n" +
                          "select(out_5) -> out_6 { select: (select p1 from out_5) }\n" +
                          "select(out_6) -> out_7 { select: (select p1 from out_6) }\n" +
                          "select(out_7) -> out_8 { select: (select p1 from out_7) }\n" +
                          "select(out_8) -> out_9 { select: (select p1 from out_8) }\n" +
                          "select(out_9) -> out_10 { select: (select p1 from out_9) }\n" +
                          "select(out_10) -> out_11 { select: (select p1 from out_10) }\n" +
                          "select(out_11) -> out_12 { select: (select p1 from out_11) }\n" +
                          "select(out_12) -> out_13 { select: (select p1 from out_12) }\n" +
                          "select(out_13) -> out_14 { select: (select p1 from out_13) }\n" +
                          "select(out_14) -> out_15 { select: (select p1 from out_14) }\n" +
                          "select(out_15) -> out_16 { select: (select p1 from out_15) }\n" +
                          "select(out_16) -> out_17 { select: (select p1 from out_16) }\n" +
                          "\n" +
                          "DefaultSupportCaptureOp(out_17) {}\n";
                env.CompileDeploy(epl);

                var futureOneA = new DefaultSupportCaptureOp(1, env.Container.LockManager());
                IDictionary<string, object> operators = new Dictionary<string, object>();
                operators.Put("DefaultSupportCaptureOp", futureOneA);

                var options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));

                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyGraph", options).Start();

                object[] result;
                try {
                    result = futureOneA.GetValue(3, TimeUnit.SECONDS);
                }
                catch (Exception t) {
                    throw new EPException(t);
                }

                EPAssertionUtil.AssertEqualsAnyOrder(new[] {new object[] {"A1"}}, result);

                env.UndeployAll();
            }
Example #20
0
        private void RunAssertion()
        {
            var future = new DefaultSupportCaptureOp(1);
            var source = new MyLineFeedSource(Collections.List("Test this code", "Test line two").GetEnumerator());
            var options = new EPDataFlowInstantiationOptions()
                    .OperatorProvider(new DefaultSupportGraphOpProvider(future, source));
    
            _epService.EPRuntime.DataFlowRuntime.Instantiate("WordCount", options).Start();

            var received = future.GetValue(TimeSpan.FromSeconds(3));
            Assert.AreEqual(1, received.Length);
            var stats = (MyWordCountStats) received[0];
            EPAssertionUtil.AssertProps(stats, "Lines,Words,Chars".Split(','), new Object[] {2,6,23});
        }
        private void RunAssertion(EPServiceProvider epService)
        {
            var future = new DefaultSupportCaptureOp(1, SupportContainer.Instance.LockManager());
            var source = new MyObjectArrayGraphSource(Collections.List(
                                                          new object[] { "trade", "GE", 100d, 1000L, null, null }, // vwap = 100, minPrice=100
                                                          new object[] { "quote", "GE", null, null, 99.5d, 2000L } //
                                                          ).GetEnumerator());

            var options = new EPDataFlowInstantiationOptions()
                          .OperatorProvider(new DefaultSupportGraphOpProvider(future, source));

            epService.EPRuntime.DataFlowRuntime.Instantiate("VWAPSample", options).Start();

            object[] received = future.GetValue(5, TimeUnit.SECONDS);
            Assert.AreEqual(1, received.Length);
            EPAssertionUtil.AssertProps(
                epService.Container, received[0], "index".Split(','), new object[] { 2000 * Math.Exp(100 - 99.5) });
        }
Example #22
0
        private void RunAssertion()
        {
            var future = new DefaultSupportCaptureOp(1);
            var source = new MyObjectArrayGraphSource(Collections.List(
                                                          new Object[] { "trade", "GE", 100d, 1000L, null, null }, // vwap = 100, minPrice=100
                                                          new Object[] { "quote", "GE", null, null, 99.5d, 2000L } //
                                                          ).GetEnumerator());

            var options = new EPDataFlowInstantiationOptions()
                          .OperatorProvider(new DefaultSupportGraphOpProvider(future, source));

            _epService.EPRuntime.DataFlowRuntime.Instantiate("VWAPSample", options).Start();

            var received = future.GetValue(TimeSpan.FromSeconds(5));

            Assert.AreEqual(1, received.Length);
            EPAssertionUtil.AssertProps(received[0], "index".Split(','), new Object[] { 2000 * Math.Exp(100 - 99.5) });
        }
Example #23
0
        private void RunAssertionLargeNumOpsDataFlow(EPServiceProvider epService)
        {
            string epl = "create dataflow MyGraph \n" +
                         "" +
                         "create objectarray schema SchemaOne (p1 string),\n" +
                         "\n" +
                         "BeaconSource -> InStream<SchemaOne> {p1:'A1', iterations:1}\n" +
                         "Select(InStream) -> out_1 { select: (select p1 from InStream) }\n" +
                         "Select(out_1) -> out_2 { select: (select p1 from out_1) }\n" +
                         "Select(out_2) -> out_3 { select: (select p1 from out_2) }\n" +
                         "Select(out_3) -> out_4 { select: (select p1 from out_3) }\n" +
                         "Select(out_4) -> out_5 { select: (select p1 from out_4) }\n" +
                         "Select(out_5) -> out_6 { select: (select p1 from out_5) }\n" +
                         "Select(out_6) -> out_7 { select: (select p1 from out_6) }\n" +
                         "Select(out_7) -> out_8 { select: (select p1 from out_7) }\n" +
                         "Select(out_8) -> out_9 { select: (select p1 from out_8) }\n" +
                         "Select(out_9) -> out_10 { select: (select p1 from out_9) }\n" +
                         "Select(out_10) -> out_11 { select: (select p1 from out_10) }\n" +
                         "Select(out_11) -> out_12 { select: (select p1 from out_11) }\n" +
                         "Select(out_12) -> out_13 { select: (select p1 from out_12) }\n" +
                         "Select(out_13) -> out_14 { select: (select p1 from out_13) }\n" +
                         "Select(out_14) -> out_15 { select: (select p1 from out_14) }\n" +
                         "Select(out_15) -> out_16 { select: (select p1 from out_15) }\n" +
                         "Select(out_16) -> out_17 { select: (select p1 from out_16) }\n" +
                         "\n" +
                         "SupportOpCountFutureOneA(out_17) {}\n";

            epService.EPAdministrator.CreateEPL(epl);

            var futureOneA = new DefaultSupportCaptureOp(1, SupportContainer.Instance.LockManager());
            var operators  = new Dictionary <string, Object>();

            operators.Put("SupportOpCountFutureOneA", futureOneA);

            var options = new EPDataFlowInstantiationOptions()
                          .OperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));

            epService.EPRuntime.DataFlowRuntime.Instantiate("MyGraph", options).Start();

            object[] result = futureOneA.GetValue(3, TimeUnit.SECONDS);
            EPAssertionUtil.AssertEqualsAnyOrder(new[] { new object[] { "A1" } }, result);

            epService.EPAdministrator.DestroyAllStatements();
        }
Example #24
0
        private static void RunAssertionOA(
            RegressionEnvironment env,
            RegressionPath path,
            bool underlying)
        {
            env.CompileDeploy(
                "@Name('flow') create dataflow MyDataFlowOne " +
                "EventBusSource -> ReceivedStream<" + (underlying ? "MyEventOA" : "EventBean<MyEventOA>") + "> {} " +
                "DefaultSupportCaptureOp(ReceivedStream) {}",
                path);

            var future = new DefaultSupportCaptureOp(1, env.Container.LockManager());
            var options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(future));

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

            env.SendEventObjectArray(new object[] {"abc", 100L}, "MyEventOA");
            var rows = new object[0];
            try {
                rows = future.GetValue(1, TimeUnit.SECONDS);
            }
            catch (Exception t) {
                throw new EPException(t);
            }

            Assert.AreEqual(1, rows.Length);
            if (underlying) {
                EPAssertionUtil.AssertEqualsExactOrder(
                    (object[]) rows[0],
                    new object[] {"abc", 100L});
            }
            else {
                EPAssertionUtil.AssertProps(
                    (EventBean) rows[0],
                    new [] { "p0","p1" },
                    new object[] {"abc", 100L});
            }

            instance.Cancel();
            env.UndeployModuleContaining("flow");
        }
        public void TestLargeNumOpsDataFlow()
        {
            String epl = "create dataflow MyGraph \n" +
                         "" +
                         "create objectarray schema SchemaOne (p1 string),\n" +
                         "\n" +
                         "BeaconSource -> InStream<SchemaOne> {p1:'A1', iterations:1}\n" +
                         "Select(InStream) -> out_1 { select: (select p1 from InStream) }\n" +
                         "Select(out_1) -> out_2 { select: (select p1 from out_1) }\n" +
                         "Select(out_2) -> out_3 { select: (select p1 from out_2) }\n" +
                         "Select(out_3) -> out_4 { select: (select p1 from out_3) }\n" +
                         "Select(out_4) -> out_5 { select: (select p1 from out_4) }\n" +
                         "Select(out_5) -> out_6 { select: (select p1 from out_5) }\n" +
                         "Select(out_6) -> out_7 { select: (select p1 from out_6) }\n" +
                         "Select(out_7) -> out_8 { select: (select p1 from out_7) }\n" +
                         "Select(out_8) -> out_9 { select: (select p1 from out_8) }\n" +
                         "Select(out_9) -> out_10 { select: (select p1 from out_9) }\n" +
                         "Select(out_10) -> out_11 { select: (select p1 from out_10) }\n" +
                         "Select(out_11) -> out_12 { select: (select p1 from out_11) }\n" +
                         "Select(out_12) -> out_13 { select: (select p1 from out_12) }\n" +
                         "Select(out_13) -> out_14 { select: (select p1 from out_13) }\n" +
                         "Select(out_14) -> out_15 { select: (select p1 from out_14) }\n" +
                         "Select(out_15) -> out_16 { select: (select p1 from out_15) }\n" +
                         "Select(out_16) -> out_17 { select: (select p1 from out_16) }\n" +
                         "\n" +
                         "SupportOpCountFutureOneA(out_17) {}\n";

            _epService.EPAdministrator.CreateEPL(epl);

            DefaultSupportCaptureOp     futureOneA = new DefaultSupportCaptureOp(1);
            Dictionary <String, Object> operators  = new Dictionary <String, Object>();

            operators.Put("SupportOpCountFutureOneA", futureOneA);

            EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions()
                                                     .OperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));

            _epService.EPRuntime.DataFlowRuntime.Instantiate("MyGraph", options).Start();

            Object[] result = futureOneA.GetValue(TimeSpan.FromSeconds(3));
            EPAssertionUtil.AssertEqualsAnyOrder(new Object[][] { new Object[] { "A1" } }, result);
        }
Example #26
0
        private static void RunAssertionStatementNameExists(
            RegressionEnvironment env,
            string typeName,
            object[] events)
        {
            env.CompileDeploy("@Name('MyStatement') select * from " + typeName);

            env.CompileDeploy(
                "@Name('flow') create dataflow MyDataFlowOne " +
                "create schema AllObject System.Object," +
                "EPStatementSource -> thedata<AllObject> {" +
                "  statementDeploymentId : '" +
                env.DeploymentId("MyStatement") +
                "'," +
                "  statementName : 'MyStatement'," +
                "} " +
                "DefaultSupportCaptureOp(thedata) {}");

            var captureOp = new DefaultSupportCaptureOp(2, env.Container.LockManager());
            var options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(captureOp));

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

            var sender = env.EventService.GetEventSender(typeName);
            foreach (var @event in events) {
                sender.SendEvent(@event);
            }

            try {
                captureOp.GetValue(1, TimeUnit.SECONDS);
            }
            catch (Exception t) {
                throw new EPException(t);
            }

            EPAssertionUtil.AssertEqualsExactOrder(events, captureOp.Current);

            df.Cancel();
            env.UndeployAll();
        }
        private Object RunAssertionBeans(String typeName)
        {
            var stmtGraph = _epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                                 "" +
                                                                 "BeaconSource -> BeaconStream<" + typeName + "> {" +
                                                                 "  Myfield : 'abc', iterations : 1" +
                                                                 "}" +
                                                                 "DefaultSupportCaptureOp(BeaconStream) {}");

            var future  = new DefaultSupportCaptureOp(1);
            var options = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(future));
            var df      = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            df.Start();
            var output = future.GetValue(TimeSpan.FromSeconds(2));

            Assert.AreEqual(1, output.Length);
            stmtGraph.Dispose();
            return(output[0]);
        }
        private Object RunAssertionBeans(EPServiceProvider epService, string typeName)
        {
            var stmtGraph = epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "BeaconSource -> BeaconStream<" + typeName + "> {" +
                "  Myfield : 'abc', iterations : 1" +
                "}" +
                "DefaultSupportCaptureOp(BeaconStream) {}");

            var future  = new DefaultSupportCaptureOp(1, SupportContainer.Instance.LockManager());
            var options = new EPDataFlowInstantiationOptions()
                          .OperatorProvider(new DefaultSupportGraphOpProvider(future));
            var df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            df.Start();
            object[] output = future.GetValue(2, TimeUnit.SECONDS);
            Assert.AreEqual(1, output.Length);
            stmtGraph.Dispose();
            return(output[0]);
        }
Example #29
0
        public void TestVariable()
        {
            _epService.EPAdministrator.CreateEPL("create Schema SomeEvent()");
            _epService.EPAdministrator.CreateEPL("create variable int var_iterations=3");
            EPStatement stmtGraph = _epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "BeaconSource -> BeaconStream<SomeEvent> {" +
                "  iterations : var_iterations" +
                "}" +
                "DefaultSupportCaptureOp(BeaconStream) {}");

            var future  = new DefaultSupportCaptureOp(3);
            var options = new EPDataFlowInstantiationOptions()
                          .OperatorProvider(new DefaultSupportGraphOpProvider(future));
            EPDataFlowInstance df = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            df.Start();
            Object[] output = future.GetValue(TimeSpan.FromSeconds(2));
            Assert.AreEqual(3, output.Length);
            stmtGraph.Dispose();
        }
        private void RunAssertionVariable(EPServiceProvider epService)
        {
            epService.EPAdministrator.CreateEPL("create Schema SomeEvent()");
            epService.EPAdministrator.CreateEPL("create variable int var_iterations=3");
            var stmtGraph = epService.EPAdministrator.CreateEPL(
                "create dataflow MyDataFlowOne " +
                "BeaconSource -> BeaconStream<SomeEvent> {" +
                "  iterations : var_iterations" +
                "}" +
                "DefaultSupportCaptureOp(BeaconStream) {}");

            var future  = new DefaultSupportCaptureOp(3, SupportContainer.Instance.LockManager());
            var options = new EPDataFlowInstantiationOptions()
                          .OperatorProvider(new DefaultSupportGraphOpProvider(future));
            var df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            df.Start();
            object[] output = future.GetValue(2, TimeUnit.SECONDS);
            Assert.AreEqual(3, output.Length);
            stmtGraph.Dispose();
        }