public static EPStatement Create(EPAdministrator admin) { var stmt = "insert into TicksPerSecond " + "select Feed as feed, count(*) as cnt from MarketDataEvent.win:time_batch(1 sec) group by Feed"; return(admin.CreateEPL(stmt)); }
public override void Start() { EPAdministrator epAdmin = _epService.EPAdministrator; try { String consultaEsper = "insert into EventoLOFAgrupado( instrumento, plataforma, cabecalho, LivroOfertasCompra, LivroOfertasVenda) "; consultaEsper += " select * from EventoAtualizacaoLivroOfertas "; consultaEsper += " select * from EventoAtualizacaoLivroOfertas "; EPStatement comandoEsper = epAdmin.CreateEPL(consultaEsper); UpdateListener listenerLivro = new GroupedLOFListenerClass1(); // new BovespaLivroOfertasListener( // this._dadosGlobais, this._config.NumeroItensLivroOfertas); comandoEsper.AddListener(listenerLivro); logger.Info("Consulta [" + consultaEsper + "] cadastrada no ESPER!"); } catch (EPException epex) { logger.Error("Exception in createEPL - " + epex.Message); return; } }
public void SetUp() { 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(); configuration.AddEventType(eventTypeName, propertyTypes); configuration.AddEventType("myNonMapEvent", typeof(Type).FullName); epService = EPServiceProviderManager.GetProvider("CSVProvider", configuration); epService.Initialize(); EPAdministrator administrator = epService.EPAdministrator; String statementText = "select * from mapEvent#length(5)"; EPStatement statement = administrator.CreateEPL(statementText); listener = new SupportUpdateListener(); statement.Events += listener.Update; // Turn off external clocking epService.EPRuntime.SendEvent(new TimerControlEvent(TimerControlEvent.ClockTypeEnum.CLOCK_EXTERNAL)); // Set the clock to 0 currentTime = 0; SendTimeEvent(0); propertyOrderNoTimestamps = new[] { "myInt", "myDouble", "myString" }; propertyOrderTimestamps = new[] { "timestamp", "myInt", "myDouble", "myString" }; }
/// <summary> /// Initializes Esper and prepares event listeners. /// </summary> static void InitializeEsper() { var serviceProvider = EPServiceProviderManager.GetDefaultProvider(); _runtime = serviceProvider.EPRuntime; _administrator = serviceProvider.EPAdministrator; // You must tell esper about your events, failure to do so means you will be using // the fully qualified names of your events. There are many ways to do that, but // this one is short-hand which makes the name of your event aliased to the fully // qualified name of your type. var typeDefinition = new Dictionary <string, object> { { "Symbol", typeof(string) }, { "Price", "double" }, { "Quantity", "int" } }; _administrator.Configuration.AddEventType("TradeEvent", typeDefinition); // Create a statement or pattern; these are the bread and butter of esper. This // method creates a statement. You want to hang on to the statement if you intend // to listen directly to the results. var statement = _administrator.CreateEPL("select * from TradeEvent where Price > 700.0"); // Hook up an event handler to the statement statement.Events += new UpdateEventHandler(HandleEvent); }
public ZoneHumidityStmt(EPAdministrator admin) { string stmt = "select max(dtime), objuri, humidity " + "from ZoneHumidity.win:time(10 sec) group by objuri"; statement = admin.CreateEPL(stmt); }
public override void Start() { EPAdministrator epAdmin = _epService.EPAdministrator; try { String consultaEsper = "select * from EventoBMF where Tipo='" + ConstantesMDS.TIPO_REQUISICAO_BMF_INSTRUMENTO + "' or Tipo='" + ConstantesMDS.TIPO_REQUISICAO_BMF_LIVRO_OFERTAS_COMPRA + "' or Tipo='" + ConstantesMDS.TIPO_REQUISICAO_BMF_LIVRO_OFERTAS_VENDA + "'"; EPStatement comandoEsper = epAdmin.CreateEPL(consultaEsper); UpdateListener listenerLivro = new BMFLivroOfertasListener(this._dadosGlobais, this._config.NumeroItensLivroOfertas); comandoEsper.AddListener(listenerLivro); logger.Info("Consulta [" + consultaEsper + "] cadastrada no ESPER!"); } catch (EPException epex) { logger.Error("Exception in createEPL - " + epex.Message, epex); return; } }
private void RunAssertionCorrel(EPServiceProvider epService) { // further math tests can be found in the view unit test EPAdministrator admin = epService.EPAdministrator; admin.Configuration.AddEventType("Market", typeof(SupportMarketDataBean)); EPStatement statement = admin.CreateEPL ("select * from Market#groupwin(symbol)#length(1000000)#correl(Price, Volume, Feed)"); var listener = new SupportUpdateListener(); statement.Events += listener.Update; Assert.AreEqual(typeof(double?), statement.EventType.GetPropertyType("correlation")); var fields = new string[] { "symbol", "correlation", "Feed" }; epService.EPRuntime.SendEvent(new SupportMarketDataBean("ABC", 10.0, 1000L, "f1")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "ABC", Double.NaN, "f1" }); epService.EPRuntime.SendEvent(new SupportMarketDataBean("DEF", 1.0, 2L, "f2")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "DEF", Double.NaN, "f2" }); epService.EPRuntime.SendEvent(new SupportMarketDataBean("DEF", 2.0, 4L, "f3")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "DEF", 1.0, "f3" }); epService.EPRuntime.SendEvent(new SupportMarketDataBean("ABC", 20.0, 2000L, "f4")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "ABC", 1.0, "f4" }); statement.Dispose(); }
public void SetUp() { 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"; Configuration configuration = new Configuration(); configuration.AddEventType(eventTypeName, propertyTypes); epService = EPServiceProviderManager.GetProvider("Adapter", configuration); epService.Initialize(); EPAdministrator administrator = epService.EPAdministrator; String statementText = "select * from mapEvent.win:length(5)"; EPStatement statement = administrator.CreateEPL(statementText); listener = new SupportUpdateListener(); statement.Events += listener.Update; // Turn off external clocking epService.EPRuntime.SendEvent(new TimerControlEvent(TimerControlEvent.ClockTypeEnum.CLOCK_EXTERNAL)); // Set the clock to 0 currentTime = 0; SendTimeEvent(0); coordinator = new AdapterCoordinatorImpl(epService, true); propertyOrderNoTimestamp = new String[] { "myInt", "myDouble", "myString" }; String[] propertyOrderTimestamp = new String[] { "timestamp", "myInt", "myDouble", "myString" }; // A CSVPlayer for a file with timestamps, not looping timestampsNotLooping = new CSVInputAdapterSpec(new AdapterInputSource("/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("/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("/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("/regression/noTimestampTwo.csv"), eventTypeName); noTimestampsLooping.EventsPerSec = 5; noTimestampsLooping.IsLooping = true; noTimestampsLooping.PropertyOrder = propertyOrderNoTimestamp; noTimestampsLooping.IsUsingEngineThread = true; }
public void TearDown() { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } _epAdmin = null; }
public static EPStatement Create(EPAdministrator admin) { String stmt = "select feed, avg(cnt) as avgCnt, cnt as feedCnt from TicksPerSecond.win:time(10 sec) " + "group by feed, cnt " + "having cnt < avg(cnt) * 0.75 "; return(admin.CreateEPL(stmt)); }
public static EPStatement MaxDeviationFromIndexStatement(this EPAdministrator admin) { var statement = "select symbol, max(deviation) as maxDeviation " + "from DeviationFromIndex.std:groupwin(symbol).win:length(1)"; return(admin.CreateEPL(statement)); }
public static EPStatement Create(EPAdministrator admin) { string stmt = "select ID as sensorId, coalesce(sum(countTags), 0) as numTagsPerSensor " + "from AutoIdRFIDExample.win:time(60 sec) " + "where Observation[0].Command = 'READ_PALLET_TAGS_ONLY' " + "group by ID"; return(admin.CreateEPL(stmt)); }
public static EPStatement DeviationFromIndexStatement(this EPAdministrator admin) { var statement = "insert into DeviationFromIndex " + "select p.symbol as symbol, Math.Abs(i.averageNormPrice - p.normPrice) as deviation " + "from EqualWeightIndex as i, NormalizedPrice as p unidirectional"; return(admin.CreateEPL(statement)); }
public static EPStatement EqualWeightIndexStatement(this EPAdministrator admin) { var statement = "insert into EqualWeightIndex " + "select avg(normPrice) as averageNormPrice " + "from NormalizedPrice.std:groupwin(symbol).win:length(1)"; return(admin.CreateEPL(statement)); }
public static EPStatement NormalizedPriceStatement(this EPAdministrator admin) { var statement = "insert into NormalizedPrice " + "select t.symbol as symbol, (t.trade - a.aveClose)/sd.stdClose as normPrice " + "from Tick as t unidirectional, Average as a, StandardDeviation as sd " + "where t.symbol = a.symbol and t.symbol = sd.symbol"; return(admin.CreateEPL(statement)); }
/// <summary> /// Creates an EPStatement for each configuration entry /// </summary> /// <param name="sectionName">the name of the configuration section to look for</param> /// <param name="admin">the EPAdministrator which will create the statements</param> /// <param name="epService">the EPServiceProvider used to build the JSONEventRenderers</param> void CreateStatements(string sectionName, EPAdministrator admin, EPServiceProvider epService) { var queries = ConfigurationManager.GetSection(sectionName) as NameValueCollection; foreach (var c in queries.AllKeys) { var s = admin.CreateEPL(queries[c], c); _statements.Add(s); _eventRenderers.Add(c, epService.EPRuntime.EventRenderer.GetJSONRenderer(s.EventType)); } }
public static void Start() { _admin = EPServiceProviderManager.GetDefaultProvider().EPAdministrator; var eventName = typeof(LatencyLimit).FullName; var latencyAlert = _admin.CreatePattern("every newlimit=" + eventName); latencyAlert.Events += (sender, e) => { new DynaLatencySpikeMonitor((LatencyLimit)e.NewEvents[0]["newlimit"]); }; }
public static EPStatement AverageStatement(this EPAdministrator admin, int length) { var statement = "insert into Average " + "select Symbol as symbol, avg(Close) as aveClose " + "from Bar.win:length(" + length + ") " + "group by symbol"; return(admin.CreateEPL(statement)); }
public static EPStatement StandardDeviationStatement(this EPAdministrator admin, int length) { var statement = "insert into StandardDeviation " + "select Symbol as symbol, stddev(Close) as stdClose " + "from Bar.win:length(" + length + ") " + "group by symbol"; return(admin.CreateEPL(statement)); }
public void ConfigureEngine(EPAdministrator administrator) { var averageStatement = administrator.AverageStatement(WindowLength); var standardDeviationStatement = administrator.StandardDeviationStatement(WindowLength); var normalizedPriceStatement = administrator.NormalizedPriceStatement(); var equalWeightIndexStatement = administrator.EqualWeightIndexStatement(); var deviationFromIndexStatement = administrator.DeviationFromIndexStatement(); var maxDeviationFromIndexStatement = administrator.MaxDeviationFromIndexStatement(); maxDeviationFromIndexStatement.Events += new UpdateEventHandler(maxDeviationFromIndexStatement_Events); }
public AverageLatencyMonitor() { EPAdministrator admin = EPServiceProviderManager.GetDefaultProvider().EPAdministrator; EPStatement statView = admin.CreateEPL( "select * from " + typeof(OperationMeasurement).FullName + ".std:groupby('CustomerId').std:groupby('OperationName')" + ".win:length(100).stat:uni('Latency')"); statView.Events += (sender, e) => MonitorLatency(e, 10000); }
public MotionStatusStmt(EPAdministrator admin) { /*string stmt = "select zoneuri, count(distinct objuri) as numObjsPerZone " + * "from ObjLocation.win:time(60 sec) "+ * "group by zoneuri"; */ string stmt = "select count(distinct objuri) as cnt, zoneuri " + "from ObjLocation.win:time(60 sec) group by zoneuri"; statement = admin.CreateEPL(stmt); }
public ObjTempStmt(EPAdministrator admin) { /*string stmt = "select zoneuri, count(distinct objuri) as numObjsPerZone " + * "from ObjLocation.win:time(60 sec) "+ * "group by zoneuri"; */ string stmt = "select max(dtime), objuri, temperature, elemType " + "from ObjTemperature.win:time(10 sec) group by objuri"; statement = admin.CreateEPL(stmt); }
public void Init(int sleepListenerMillis) { Configuration configuration = new Configuration(); configuration.EngineDefaults.EventMetaConfig.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.AddEventType("Market", typeof(MarketData)); EPServiceProvider epService = EPServiceProviderManager.GetProvider("benchmark", configuration); epAdministrator = epService.EPAdministrator; epRuntime = epService.EPRuntime; sleepMillis = sleepListenerMillis; }
public AverageLatencyMonitor() { EPAdministrator admin = EPServiceProviderManager.GetDefaultProvider().EPAdministrator; EPStatement statView = admin.CreateEPL( "select * from " + typeof(OperationMeasurement).FullName + "#groupwin(CustomerId)" + "#groupwin(OperationName)" + "#length(100)" + "#uni(Latency)"); statView.Events += (sender, e) => MonitorLatency(e, 10000); }
public ServiceHealthMonitor() { EPAdministrator admin = EPServiceProviderManager.GetDefaultProvider().EPAdministrator; String eventBean = typeof(OperationMeasurement).FullName; EPStatement statView = admin.CreatePattern("every (" + eventBean + "(success=false)->" + eventBean + "(success=false)->" + eventBean + "(success=false))"); statView.Events += (newEvents, oldEvents) => Log.Debug(".update Alert, detected 3 erros in a row"); }
public ErrorRateMonitor() { EPAdministrator admin = EPServiceProviderManager.GetDefaultProvider().EPAdministrator; EPStatement pattern = admin.CreatePattern("every timer:at(*, *, *, *, *, */10)"); EPStatement view = admin.CreateEPL("select count(*) as size from " + typeof(OperationMeasurement).FullName + "(success=false).win:time(10 min).std:size()"); pattern.Events += delegate { var count = (long)view.First()["size"]; Log.Info(".update Info, error rate in the last 10 minutes is " + count); }; }
public void SetUp() { Configuration config = SupportConfigFactory.GetConfiguration(); String pkg = typeof(SupportBean).Namespace; config.AddEventTypeAutoName(pkg); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _epAdmin = _epService.EPAdministrator; }
public AlarmStmt(EPAdministrator admin) { /*string stmt = "select zoneuri, count(distinct objuri) as numObjsPerZone " + * "from ObjLocation.win:time(60 sec) "+ * "group by zoneuri"; */ /*string stmt = "select max(dtime), zoneuri, objuri, isStill, elemType " + * "from ObjLocation.win:time(60 sec) group by zoneuri, objuri";*/ string stmt = "SELECT ObjTemperature.objuri as objuri, ObjTemperature.temperature as temperature, ObjLocation.isStill as isStill " + "FROM ObjTemperature.win:length(1),ObjLocation.win:length(1) " + "WHERE (ObjTemperature.temperature > 26) AND (ObjLocation.isStill = 'M' AND ObjTemperature.objuri = ObjLocation.objuri) "; statement = admin.CreateEPL(stmt); }
/// <summary> /// Setup the esper. /// </summary> static void SetupEsper() { Configuration configuration = new Configuration(); configuration.AddEventType <BidData>(); configuration.EngineDefaults.ExpressionConfig.IsUdfCache = true; configuration.EngineDefaults.LoggingConfig.IsEnableExecutionDebug = false; configuration.EngineDefaults.LoggingConfig.IsEnableTimerDebug = false; configuration.EngineDefaults.MetricsReportingConfig.IsEnableMetricsReporting = false; configuration.EngineDefaults.MetricsReportingConfig.IsThreading = false; _espServiceProvider = (EPServiceProviderSPI)EPServiceProviderManager.GetDefaultProvider(configuration); _espAdministrator = _espServiceProvider.EPAdministrator; _espRuntime = _espServiceProvider.EPRuntime; }
public static EPStatement Create(EPAdministrator admin) { // We need to take in events A, B and C and produce a single, combined event String stmt = "insert into CombinedEvent(transactionId, customerId, supplierId, latencyAC, latencyBC, latencyAB)" + "select C.TransactionId," + "CustomerId," + "SupplierId," + "C.Timestamp - A.Timestamp," + "C.Timestamp - B.Timestamp," + "B.Timestamp - A.Timestamp " + "from TxnEventA.win:time(30 min) A," + "TxnEventB.win:time(30 min) B," + "TxnEventC.win:time(30 min) C " + "where A.TransactionId = B.TransactionId and B.TransactionId = C.TransactionId"; return(admin.CreateEPL(stmt)); }
/// <summary> /// Creates a new instance of the EP /// </summary> /// <param name="sectionName"></param> /// <param name="admin"></param> public QueryConfiguration(string sectionName, EPAdministrator admin, EPServiceProvider epService) { _statements = new List<EPStatement>(); _eventRenderers = new Dictionary<string, JSONEventRenderer>(); CreateStatements(sectionName, admin, epService); }