Exemplo n.º 1
0
        private void TrySource(Supplier <AdapterInputSource> sourceSupplier)
        {
            var source = sourceSupplier.Invoke();
            var spec   = new CSVInputAdapterSpec(source, "TypeC");

            _runtime = EPRuntimeProvider.GetRuntime("testPlayFromInputStream", MakeConfig("TypeC"));
            _runtime.Initialize();
            InputAdapter feed = new CSVInputAdapter(_runtime, spec);

            var stmt     = CompileDeploy(_runtime, "select * from TypeC#length(100)").Statements[0];
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            feed.Start();
            Assert.AreEqual(1, listener.GetNewDataList().Count);

            source = sourceSupplier.Invoke();

            // test graph
            var graph = "create dataflow ReadCSV " +
                        "FileSource -> mystream<TypeC> { hasTitleLine: true }" +
                        "DefaultSupportCaptureOp(mystream) {}";
            var deployment = CompileDeploy(_runtime, graph);

            var outputOp = new DefaultSupportCaptureOp();
            var options  = new EPDataFlowInstantiationOptions();

            options.OperatorProvider  = new DefaultSupportGraphOpProvider(outputOp);
            options.ParameterProvider = new DefaultSupportGraphParamProvider(Collections.SingletonDataMap("adapterInputSource", source));
            var instance = _runtime.DataFlowService.Instantiate(deployment.DeploymentId, "ReadCSV", options);

            instance.Run();
            var received = outputOp.GetAndReset()[0].ToArray();

            Assert.AreEqual(1, received.Length);
        }
Exemplo n.º 2
0
        public void TestEngineThread1000PerSec()
        {
            EPService = EPServiceProviderManager.GetProvider("testExistingTypeNoOptions", MakeConfig("TypeA"));
            EPService.Initialize();

            EPStatement stmt =
                EPService.EPAdministrator.CreateEPL("select symbol, price, volume from TypeA.win:length(100)");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            var spec = new CSVInputAdapterSpec(new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE),
                                               "TypeA");

            spec.EventsPerSec        = 1000;
            spec.IsUsingEngineThread = true;

            InputAdapter inputAdapter = new CSVInputAdapter(EPService, spec);

            inputAdapter.Start();
            Thread.Sleep(1000);

            Assert.AreEqual(1, listener.GetNewDataList().Count);
        }