public void TestEngineThread1PerSec() { _runtime = EPRuntimeProvider.GetRuntime("testExistingTypeNoOptions", MakeConfig("TypeA")); _runtime.Initialize(); var stmt = CompileDeploy(_runtime, "select symbol, price, volume from TypeA#length(100)").Statements[0]; var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var spec = new CSVInputAdapterSpec(new AdapterInputSource(_container, CSV_FILENAME_ONELINE_TRADE_MULTIPLE), "TypeA"); spec.EventsPerSec = 1; spec.IsUsingEngineThread = true; InputAdapter inputAdapter = new CSVInputAdapter(_runtime, spec); inputAdapter.Start(); Thread.Sleep(1500); Assert.AreEqual(1, listener.GetNewDataList().Count); listener.Reset(); Thread.Sleep(300); Assert.AreEqual(0, listener.GetNewDataList().Count); Thread.Sleep(2000); Assert.IsTrue(listener.GetNewDataList().Count >= 2); }
public void SetUp() { _container = SupportContainer.Reset(); _propertyTypes = new Dictionary<String, Object>(); _propertyTypes.Put("MyInt", typeof(int?)); _propertyTypes.Put("MyDouble", typeof(double?)); _propertyTypes.Put("MyString", typeof(String)); _eventTypeName = "mapEvent"; var configuration = new Configuration(_container); configuration.Runtime.Threading.IsInternalTimerEnabled = false; configuration.Common.AddEventType(_eventTypeName, _propertyTypes); configuration.Common.AddEventType("myNonMapEvent", typeof(Type).FullName); _runtime = EPRuntimeProvider.GetRuntime("CSVProvider", configuration); _runtime.Initialize(); var statementText = "select * from mapEvent#length(5)"; var statement = CompileDeploy(_runtime, statementText).Statements[0]; _listener = new SupportUpdateListener(); statement.Events += _listener.Update; // Set the clock to 0 _currentTime = 0; SendTimeEvent(0); _propertyOrderNoTimestamps = new[] {"MyInt", "MyDouble", "MyString"}; _propertyOrderTimestamps = new[] {"timestamp", "MyInt", "MyDouble", "MyString"}; }
public void TestReadWritePropsBean() { var configuration = new Configuration(_container); configuration.Common.AddEventType("ExampleMarketDataBeanReadWrite", typeof(ExampleMarketDataBeanReadWrite)); //configuration.Common.AddImportNamespace(typeof(FileSourceCSV)); configuration.Common.AddImportNamespace(typeof(DefaultSupportCaptureOp)); _runtime = EPRuntimeProvider.GetRuntime("testExistingTypeNoOptions", configuration); _runtime.Initialize(); var stmt = CompileUtil.CompileDeploy(_runtime, "select * from ExampleMarketDataBeanReadWrite#length(100)").Statements[0]; var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var inputAdapter = new CSVInputAdapter( _runtime, // _baseUseCase.Runtime, new AdapterInputSource(_container, TestCSVAdapterUseCases.CSV_FILENAME_ONELINE_TRADE), "ReadWrite"); inputAdapter.Start(); Assert.AreEqual(1, listener.GetNewDataList().Count); var eb = listener.GetNewDataList()[0][0]; Assert.IsTrue(typeof(ExampleMarketDataBeanReadWrite) == eb.Underlying.GetType()); Assert.AreEqual(55.5 * 1000, eb.Get("value")); }
public void SetUp() { _container = SupportContainer.Reset(); IDictionary <String, Object> propertyTypes = new LinkedHashMap <String, Object>(); propertyTypes.Put("myInt", typeof(int)); propertyTypes.Put("myDouble", typeof(double?)); propertyTypes.Put("myString", typeof(String)); _eventTypeName = "mapEvent"; var configuration = new Configuration(_container); configuration.Runtime.Threading.IsInternalTimerEnabled = false; configuration.Common.AddEventType(_eventTypeName, propertyTypes); _runtime = EPRuntimeProvider.GetRuntime("Adapter", configuration); _runtime.Initialize(); var statementText = "select * from mapEvent#length(5)"; var statement = CompileUtil.CompileDeploy(_runtime, statementText).Statements[0]; _listener = new SupportUpdateListener(); statement.Events += _listener.Update; // Set the clock to 0 _currentTime = 0; SendTimeEvent(0); _coordinator = new AdapterCoordinatorImpl(_runtime, true); _propertyOrderNoTimestamp = new[] { "myInt", "myDouble", "myString" }; var propertyOrderTimestamp = new[] { "timestamp", "myInt", "myDouble", "myString" }; // A CSVPlayer for a file with timestamps, not looping _timestampsNotLooping = new CSVInputAdapterSpec(new AdapterInputSource(_container, "regression/timestampOne.csv"), _eventTypeName); _timestampsNotLooping.IsUsingEngineThread = true; _timestampsNotLooping.PropertyOrder = propertyOrderTimestamp; _timestampsNotLooping.TimestampColumn = "timestamp"; // A CSVAdapter for a file with timestamps, looping _timestampsLooping = new CSVInputAdapterSpec(new AdapterInputSource(_container, "regression/timestampTwo.csv"), _eventTypeName); _timestampsLooping.IsLooping = true; _timestampsLooping.IsUsingEngineThread = true; _timestampsLooping.PropertyOrder = propertyOrderTimestamp; _timestampsLooping.TimestampColumn = "timestamp"; // A CSVAdapter that sends 10 events per sec, not looping _noTimestampsNotLooping = new CSVInputAdapterSpec(new AdapterInputSource(_container, "regression/noTimestampOne.csv"), _eventTypeName); _noTimestampsNotLooping.EventsPerSec = 10; _noTimestampsNotLooping.PropertyOrder = _propertyOrderNoTimestamp; _noTimestampsNotLooping.IsUsingEngineThread = true; // A CSVAdapter that sends 5 events per sec, looping _noTimestampsLooping = new CSVInputAdapterSpec(new AdapterInputSource(_container, "regression/noTimestampTwo.csv"), _eventTypeName); _noTimestampsLooping.EventsPerSec = 5; _noTimestampsLooping.IsLooping = true; _noTimestampsLooping.PropertyOrder = _propertyOrderNoTimestamp; _noTimestampsLooping.IsUsingEngineThread = true; }
public void SetUp() { var container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); var configuration = new Configuration(container); configuration.Runtime.Threading.IsInternalTimerEnabled = false; configuration.Common.AddEventType("MarketDataEvent", typeof(MarketDataEvent).FullName); configuration.Common.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; _runtime = EPRuntimeProvider.GetRuntime("TestTicksPerSecondStatement", configuration); _runtime.Initialize(); _runtime.EventService.AdvanceTime(0); TicksPerSecondStatement.Create(_runtime); var stmt = TicksFalloffStatement.Create(_runtime); _listener = new SupportUpdateListener(); stmt.Events += _listener.Update; // Use external clocking for the test _runtime.EventService.ClockExternal(); }
public void SetUp() { var container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); var configuration = new Configuration(container); configuration.Common.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.Common.AddEventType("StockTick", typeof(StockTick).FullName); _runtime = EPRuntimeProvider.GetRuntime("TestStockTickerRSI", configuration); _runtime.Initialize(); _stockListener = new RSIStockTickerListener(_runtime, PERIOD); _expressionText = "every tick=StockTick(stockSymbol='" + SYMBOL + "')"; //_expressionText = "every tick1=StockTick(stockSymbol='GOOG') -> tick2=StockTick(stockSymbol='GOOG')"; _factory = _runtime.CompileDeploy(_expressionText).Statements[0]; _factory.Events += _stockListener.Update; var rsiEvent = typeof(RSIEvent).FullName; var viewExpr = "select * from " + rsiEvent + ".win:length(1)"; _rsiListener = new RSIListener(); _factory = _runtime.CompileDeploy(viewExpr).Statements[0]; _factory.Events += _rsiListener.Update; _rsiListener.Reset(); }
public void TestDynamicType() { var spec = new CSVInputAdapterSpec( new AdapterInputSource(_container, CSV_FILENAME_ONELINE_TRADE), "TypeB"); var config = new Configuration(_container); config.Runtime.Threading.IsInternalTimerEnabled = false; _runtime = EPRuntimeProvider.GetDefaultRuntime(config); _runtime.Initialize(); CompileDeploy(_runtime, "@public @buseventtype create schema TypeB(symbol string, price string, volume string)"); InputAdapter feed = new CSVInputAdapter(_runtime, spec); var stmt = CompileDeploy(_runtime, "select symbol, price, volume from TypeB#length(100)").Statements[0]; var listener = new SupportUpdateListener(); stmt.Events += listener.Update; Assert.AreEqual(typeof(string), stmt.EventType.GetPropertyType("symbol")); Assert.AreEqual(typeof(string), stmt.EventType.GetPropertyType("price")); Assert.AreEqual(typeof(string), stmt.EventType.GetPropertyType("volume")); feed.Start(); Assert.AreEqual(1, listener.GetNewDataList().Count); }
public void SetUp() { var configuration = new Configuration(SupportContainer.Reset()); configuration.Runtime.Threading.IsInternalTimerEnabled = false; configuration.Common.AddImportNamespace(typeof(FileSinkFactory)); configuration.Common.AddImportNamespace(typeof(DefaultSupportSourceOpForge)); DefaultSupportGraphEventUtil.AddTypeConfiguration(configuration); runtime = EPRuntimeProvider.GetDefaultRuntime(configuration); runtime.Initialize(); }
public void SetUp() { var configuration = new Configuration(); configuration.Runtime.Threading.IsInternalTimerEnabled = false; configuration.Common.AddImportType(typeof(FileSourceForge)); configuration.Common.AddImportType(typeof(DefaultSupportCaptureOpForge)); configuration.Common.AddEventType("MyLineEvent", typeof(MyLineEvent)); configuration.Common.AddEventType("MyInvalidEvent", typeof(MyInvalidEvent)); runtime = EPRuntimeProvider.GetDefaultRuntime(configuration); runtime.Initialize(); }
public void TestExistingTypeNoOptions() { _runtime = EPRuntimeProvider.GetRuntime("testExistingTypeNoOptions", MakeConfig("TypeA", _useBean)); _runtime.Initialize(); var stmt = CompileDeploy(_runtime, "select symbol, price, volume from TypeA#length(100)").Statements[0]; var listener = new SupportUpdateListener(); stmt.Events += listener.Update; (new CSVInputAdapter(_runtime, new AdapterInputSource(_container, CSV_FILENAME_ONELINE_TRADE), "TypeA")).Start(); Assert.AreEqual(1, listener.GetNewDataList().Count); }
public void TestReadWritePropsBean() { var configuration = new Configuration(_container); configuration.Common.AddEventType("ExampleMarketDataBeanReadWrite", typeof(ExampleMarketDataBeanReadWrite)); configuration.Common.AddImportNamespace(typeof(FileSourceCSV)); configuration.Common.AddImportNamespace(typeof(DefaultSupportCaptureOp)); _runtime = EPRuntimeProvider.GetRuntime("testExistingTypeNoOptions", configuration); _runtime.Initialize(); var stmt = CompileUtil.CompileDeploy(_runtime, "select * from ExampleMarketDataBeanReadWrite#length(100)").Statements[0]; var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var inputAdapter = new CSVInputAdapter( _runtime, new AdapterInputSource(_container, CSV_FILENAME_ONELINE_TRADE), "ExampleMarketDataBeanReadWrite"); inputAdapter.Start(); Assert.AreEqual(1, listener.GetNewDataList().Count); var eb = listener.GetNewDataList()[0][0]; Assert.IsTrue(typeof(ExampleMarketDataBeanReadWrite) == eb.Underlying.GetType()); Assert.AreEqual(55.5 * 1000, eb.Get("value")); // test graph var graph = "create dataflow ReadCSV " + "FileSource -> mystream<ExampleMarketDataBeanReadWrite> { file: '" + CSV_FILENAME_ONELINE_TRADE + "', hasTitleLine: true }" + "DefaultSupportCaptureOp(mystream) {}"; var deployment = CompileUtil.CompileDeploy(_runtime, graph); var outputOp = new DefaultSupportCaptureOp(); var instance = _runtime.DataFlowService.Instantiate( deployment.DeploymentId, "ReadCSV", new EPDataFlowInstantiationOptions().WithOperatorProvider(new DefaultSupportGraphOpProvider(outputOp))); instance.Run(); var received = outputOp.GetAndReset()[0].ToArray(); Assert.That(received.Length, Is.EqualTo(1)); Assert.That(received[0], Is.InstanceOf <ExampleMarketDataBean>()); Assert.That( ((ExampleMarketDataBeanReadWrite)received[0]).Value, Is.EqualTo(55.5 * 1000.0)); }
public virtual void SetUp() { var container = ContainerExtensions.CreateDefaultContainer(); var configuration = new Configuration(container); configuration.Common.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.Common.AddEventType("TxnEventA", typeof(TxnEventA)); configuration.Common.AddEventType("TxnEventB", typeof(TxnEventB)); configuration.Common.AddEventType("TxnEventC", typeof(TxnEventC)); _runtime = EPRuntimeProvider.GetRuntime("TestStmtBase", configuration); _runtime.Initialize(); _eventService = _runtime.EventService; }
private void TrySource(AdapterInputSource source) { var spec = new CSVInputAdapterSpec(source, "TypeC"); _runtime = EPRuntimeProvider.GetRuntime("testPlayFromInputStream", MakeConfig("TypeC")); _runtime.Initialize(); InputAdapter feed = new CSVInputAdapter(_runtime, spec); var stmt = CompileUtil.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); }
public void SetUp() { _container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); var url = _container.ResourceManager().ResolveResourceURL("esper.examples.cfg.xml"); var config = new Configuration(_container); config.Configure(url); _runtime = EPRuntimeProvider.GetRuntime("AutoIdSim", config); _runtime.Initialize(); _listener = new SupportUpdateListener(); var rfidStmt = RFIDTagsPerSensorStmt.Create(_runtime); rfidStmt.Events += _listener.Update; }
public void SetUp() { var configuration = new Configuration(); configuration.Runtime.Threading.IsInternalTimerEnabled = false; configuration.Common.AddImportType(typeof(FileSourceForge)); configuration.Common.AddImportType(typeof(DefaultSupportCaptureOpForge)); var propertyTypes = new Dictionary <string, object>(); propertyTypes.Put("MyInt", typeof(int?)); propertyTypes.Put("MyDouble", typeof(double?)); propertyTypes.Put("MyString", typeof(string)); configuration.Common.AddEventType("MyMapEvent", propertyTypes); configuration.Common.AddEventType( "MyOAType", "P0,P1".SplitCsv(), new object[] { typeof(DateTime), typeof(DateTimeEx) }); runtime = EPRuntimeProvider.GetDefaultRuntime(configuration); runtime.Initialize(); }
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); }
public void TestCoordinated() { IDictionary <string, object> priceProps = new Dictionary <string, object>(); priceProps.Put("timestamp", typeof(long?)); priceProps.Put("symbol", typeof(string)); priceProps.Put("price", typeof(double?)); IDictionary <string, object> tradeProps = new Dictionary <string, object>(); tradeProps.Put("timestamp", typeof(long?)); tradeProps.Put("symbol", typeof(string)); tradeProps.Put("notional", typeof(double?)); var config = new Configuration(_container); config.Common.AddEventType("TradeEvent", tradeProps); config.Common.AddEventType("PriceEvent", priceProps); _runtime = EPRuntimeProvider.GetRuntime("testCoordinated", config); _runtime.Initialize(); _runtime.EventService.ClockExternal(); _runtime.EventService.AdvanceTime(0); var sourcePrices = new AdapterInputSource(_container, CSV_FILENAME_TIMESTAMPED_PRICES); var inputPricesSpec = new CSVInputAdapterSpec(sourcePrices, "PriceEvent"); inputPricesSpec.TimestampColumn = "timestamp"; inputPricesSpec.PropertyTypes = priceProps; var inputPrices = new CSVInputAdapter(inputPricesSpec); var sourceTrades = new AdapterInputSource(_container, CSV_FILENAME_TIMESTAMPED_TRADES); var inputTradesSpec = new CSVInputAdapterSpec(sourceTrades, "TradeEvent"); inputTradesSpec.TimestampColumn = "timestamp"; inputTradesSpec.PropertyTypes = tradeProps; var inputTrades = new CSVInputAdapter(inputTradesSpec); var stmtPrices = CompileDeploy(_runtime, "select symbol, price from PriceEvent#length(100)").Statements[0]; var listenerPrice = new SupportUpdateListener(); stmtPrices.Events += listenerPrice.Update; var stmtTrade = CompileDeploy(_runtime, "select symbol, notional from TradeEvent#length(100)").Statements[0]; var listenerTrade = new SupportUpdateListener(); stmtTrade.Events += listenerTrade.Update; AdapterCoordinator coordinator = new AdapterCoordinatorImpl(_runtime, true); coordinator.Coordinate(inputPrices); coordinator.Coordinate(inputTrades); coordinator.Start(); _runtime.EventService.AdvanceTime(400); Assert.IsFalse(listenerTrade.IsInvoked()); Assert.IsFalse(listenerPrice.IsInvoked()); // invoke read of events at 500 (see CSV) _runtime.EventService.AdvanceTime(1000); Assert.AreEqual(1, listenerTrade.GetNewDataList().Count); Assert.AreEqual(1, listenerPrice.GetNewDataList().Count); listenerTrade.Reset(); listenerPrice.Reset(); // invoke read of price events at 1500 (see CSV) _runtime.EventService.AdvanceTime(2000); Assert.AreEqual(0, listenerTrade.GetNewDataList().Count); Assert.AreEqual(1, listenerPrice.GetNewDataList().Count); listenerTrade.Reset(); listenerPrice.Reset(); // invoke read of trade events at 2500 (see CSV) _runtime.EventService.AdvanceTime(3000); Assert.AreEqual(1, listenerTrade.GetNewDataList().Count); Assert.AreEqual(0, listenerPrice.GetNewDataList().Count); listenerTrade.Reset(); listenerPrice.Reset(); }