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 }); }
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 RunAssertionFlowGraphOperator(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); epService.EPAdministrator.Configuration.AddImport(typeof(MyLineFeedSource)); epService.EPAdministrator.Configuration.AddImport(typeof(SupportOperator)); SupportGraphSource.GetAndResetLifecycle(); epService.EPAdministrator.CreateEPL("create dataflow MyDataFlow MyLineFeedSource -> outstream {} SupportOperator(outstream) {propOne:'abc'}"); Assert.AreEqual(0, SupportOperator.GetAndResetLifecycle().Count); // instantiate var src = new MyLineFeedSource(Collections.List("abc", "def").GetEnumerator()); var options = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(src)); EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlow", options); IList <object> events = SupportOperator.GetAndResetLifecycle(); Assert.AreEqual(3, events.Count); Assert.AreEqual("instantiated", events[0]); // instantiated Assert.AreEqual("setPropOne=abc", events[1]); // injected properties Assert.IsTrue(events[2] is DataFlowOpInitializateContext); // called initialize DataFlowOpInitializateContext initContext = (DataFlowOpInitializateContext)events[2]; Assert.IsNotNull(initContext.AgentInstanceContext); Assert.IsNotNull(initContext.RuntimeEventSender); Assert.IsNotNull(initContext.ServicesContext); Assert.IsNotNull(initContext.StatementContext); Assert.IsNull(initContext.DataflowInstanceId); Assert.IsNull(initContext.DataflowInstanceUserObject); Assert.AreEqual(1, initContext.InputPorts.Count); Assert.AreEqual("[line]", CompatExtensions.Render(initContext.InputPorts[0].TypeDesc.EventType.PropertyNames)); Assert.AreEqual("[outstream]", CompatExtensions.Render(initContext.InputPorts[0].StreamNames.ToArray())); Assert.AreEqual(0, initContext.OutputPorts.Count); // run df.Run(); events = SupportOperator.GetAndResetLifecycle(); Assert.AreEqual(4, events.Count); Assert.IsTrue(events[0] is DataFlowOpOpenContext); // called open (GraphSource only) Assert.AreEqual("abc", ((object[])events[1])[0]); Assert.AreEqual("def", ((object[])events[2])[0]); Assert.IsTrue(events[3] is DataFlowOpCloseContext); // called close (GraphSource only) epService.EPAdministrator.DestroyAllStatements(); }