Esper - Complex Event Processing

Esper - Complex Event Processing

8e0ede7586a03357acfe3eb3ac362c28?s=128

Aparna Chaudhary

April 02, 2009
Tweet

Transcript

  1. 1.

    JTeam Innovating J2EE Development Esper T h e P o

    w e r t o P r e d i c t Wednesday, April 1, 2009
  2. 2.

    JTeam Innovating J2EE Development Agenda • Predictive Business • Complex

    Event Processing • Esper • Demo • Questions JTeam Innovating J2EE Development Wednesday, April 1, 2009
  3. 3.

    JTeam Innovating J2EE Development Predictive Business JTeam Innovating J2EE Development

    "In the future, every company must be able to recognize what is coming early enough to take evasive action or steer towards an emerging opportunity."[Frederick W. Smith-CEO FedEx] Wednesday, April 1, 2009
  4. 4.

    JTeam Innovating J2EE Development Business Demands JTeam Innovating J2EE Development

    High throughput Low latency High Availability Complexity Insight Wednesday, April 1, 2009
  5. 5.

    JTeam Innovating J2EE Development Conventional Models JTeam Innovating J2EE Development

    • RDBMS • Adds delays into data storage • Uses Polling Model • Wasteful Use of Resources Wednesday, April 1, 2009
  6. 6.

    JTeam Innovating J2EE Development Conventional Models JTeam Innovating J2EE Development

    • Messaging Systems • Process Unitary Events • No Correlation support Wednesday, April 1, 2009
  7. 7.

    JTeam Innovating J2EE Development Agenda • Predictive Business • Complex

    Event Processing • Esper • Demo • Questions JTeam Innovating J2EE Development Wednesday, April 1, 2009
  8. 9.

    JTeam Innovating J2EE Development Concepts - Event JTeam Innovating J2EE

    Development An event is a piece of data that represents that something happened in the real world, or in software system. e.g. Stock Tick, Weather, UserClick Wednesday, April 1, 2009
  9. 10.

    JTeam Innovating J2EE Development Concepts - Complex Event JTeam Innovating

    J2EE Development An event that could only happen when lots of other events happen. e.g. Housing Price Drop Wednesday, April 1, 2009
  10. 11.

    JTeam Innovating J2EE Development Concepts - Event Stream JTeam Innovating

    J2EE Development A linearly ordered (often by time) sequence of events forms Event Stream. e.g. Click Stream Wednesday, April 1, 2009
  11. 12.

    JTeam Innovating J2EE Development Concepts - Event Cloud JTeam Innovating

    J2EE Development A partially ordered set of events form Event Cloud e.g. Set of all stock trades for GOOG within a 5 minute time window is an Event Stream. While all Stocks sold in a business day is an Event Cloud. Wednesday, April 1, 2009
  12. 14.

    JTeam Innovating J2EE Development ESP and CEP JTeam Innovating J2EE

    Development Event Stream Processing is focused more on high-speed querying of data in streams of events and applying mathematical algorithms to the event data. Complex Event Processing includes event data analysis, but places emphasis on patterns of events, and abstracting and simplifying information in the patterns. Wednesday, April 1, 2009
  13. 15.

    JTeam Innovating J2EE Development CEP Engine JTeam Innovating J2EE Development

    An event processor is an application that performs operations on event objects, including creating, reading, transforming, aggregating, correlating or removing them. Wednesday, April 1, 2009
  14. 17.

    JTeam Innovating J2EE Development CEP Engine Characteristics JTeam Innovating J2EE

    Development 1. Keep the data moving 2. Query on streams 3. Handle Stream Imperfections 4. Integrate Stored and Streaming Data 5. Guarantee Data Safety and Availability Wednesday, April 1, 2009
  15. 18.

    JTeam Innovating J2EE Development CEP Engine Characteristics JTeam Innovating J2EE

    Development 6. Partition and scale applications automatically 7. Process and Respond instantaneously 8. Interoperability Wednesday, April 1, 2009
  16. 20.

    JTeam Innovating J2EE Development Commercial CEP Products JTeam Innovating J2EE

    Development • Weblogic Event Server • Coral8 • TIBCO • IBM • StreamBase • Progress Wednesday, April 1, 2009
  17. 21.

    JTeam Innovating J2EE Development CEP/EDA and SOA [1/3] JTeam Innovating

    J2EE Development EDA is SOA 2.0 EDA is Proactive SOA EDA and SOA Complementary Wednesday, April 1, 2009
  18. 22.
  19. 23.
  20. 24.

    JTeam Innovating J2EE Development Real World Applications JTeam Innovating J2EE

    Development Capital Markets BAM - Business Activity Monitoring Supply Chain Management Flight Operations Monitoring Fraud Detection Wednesday, April 1, 2009
  21. 25.

    JTeam Innovating J2EE Development Agenda • Predictive Business • Complex

    Event Processing • Esper • Demo • Questions JTeam Innovating J2EE Development Wednesday, April 1, 2009
  22. 26.

    JTeam Innovating J2EE Development Esper JTeam Innovating J2EE Development •

    Dual Licensing model • Open Source GPL • Esper Tech • Q2/2007 BEA Partner Wednesday, April 1, 2009
  23. 27.

    JTeam Innovating J2EE Development Good Documentation JTeam Innovating J2EE Development

    • Nice reference document • Patterns catalogue available online • Lots of examples Wednesday, April 1, 2009
  24. 28.
  25. 30.

    JTeam Innovating J2EE Development Pluggability JTeam Innovating J2EE Development •

    Works with any Java Process • OSGI Enabled Wednesday, April 1, 2009
  26. 31.

    JTeam Innovating J2EE Development Architecture JTeam Innovating J2EE Development ESPER

    Engine EPServiceProvider Event Objects Listeners Confi gurat ion EPL Statements JDB C Adap ter Subscribers Wednesday, April 1, 2009
  27. 32.

    JTeam Innovating J2EE Development API Overview JTeam Innovating J2EE Development

    • EPServiceProvider • Acts as Engine • EPStatement • Queries written in EQL • UpdateListener Wednesday, April 1, 2009
  28. 33.

    JTeam Innovating J2EE Development Event JTeam Innovating J2EE Development •

    POJOs • Key value pairs (java.util.Map) • XML Documents Wednesday, April 1, 2009
  29. 35.

    JTeam Innovating J2EE Development Event Properties JTeam Innovating J2EE Development

    Type Syntax Example Simple name sensor Indexed name[index] sensor[0] Mapped name(key) sensor(‘light’) Nested name.nested Name sensor.value Wednesday, April 1, 2009
  30. 36.

    JTeam Innovating J2EE Development UpdateListener JTeam Innovating J2EE Development Receives

    updated data as soon as it is processed for the statement. Wednesday, April 1, 2009
  31. 37.

    JTeam Innovating J2EE Development Subscriber JTeam Innovating J2EE Development •

    Must provide a method by name update to receive insert stream events row-by- row • The number and types of parameters declared by the update method must match the number and types of columns as specified in the select clause, in the same order as in the select clause • Wednesday, April 1, 2009
  32. 38.

    JTeam Innovating J2EE Development Subscriber JTeam Innovating J2EE Development select

    orderId, price, count(*) from OrderEvent public class MySubscriber { ... public void update(String orderId, double price, long count) {...} } Wednesday, April 1, 2009
  33. 39.

    JTeam Innovating J2EE Development Esper Engine Integration JTeam Innovating J2EE

    Development • Obtain an Esper engine instance • Create a statement (using the Esper query language) • Register the statement with the engine • Create a listener (by implementing a Java interface that will be triggered when the statement evaluates to true) and attach it to the statement Wednesday, April 1, 2009
  34. 40.

    JTeam Innovating J2EE Development Esper Engine Integration JTeam Innovating J2EE

    Development //Register events Configuration configuration = new Configuration(); configuration.addEventType("TempEvent", BodyTemperatureEvent.class.getName()); // Get Esper CEP Engine EPServiceProvider cepEngine = EPServiceProviderManager.getProvider("esper-sports- poc", configuration); // Create EPStatement PlayerBMIStatement playerBMIStatement = new PlayerBMIStatement(cepEngine.getEPAdministrator()); playerBMIStatement.addListener(new PlayerBMIListener()); // Dispatch Event cepEngine.getEPRuntime().sendEvent(eventInstance); Wednesday, April 1, 2009
  35. 41.

    JTeam Innovating J2EE Development EPL JTeam Innovating J2EE Development Similar

    to SQL Name BP Ross 110 Rachel 120 Joe 100 Stream Event Wednesday, April 1, 2009
  36. 43.

    JTeam Innovating J2EE Development Streams JTeam Innovating J2EE Development Input

    stream denotes new events arriving, the term remove stream denotes events leaving a data window. Wednesday, April 1, 2009
  37. 44.

    JTeam Innovating J2EE Development Windows JTeam Innovating J2EE Development •

    win:length(4) • win:time(4 sec) • win:time_batch(4 sec) • win:length_batch(4) Wednesday, April 1, 2009
  38. 46.

    JTeam Innovating J2EE Development Named Windows JTeam Innovating J2EE Development

    • Analogous to database views • Created using SELECT queries • Define window (view) first and insert data create window OrdersTimeWindow.win:time(30 sec) as select symbol, volume, price from OrderEvent Wednesday, April 1, 2009
  39. 47.

    JTeam Innovating J2EE Development Filters JTeam Innovating J2EE Development select

    * from Withdrawal(amount>=200).win:le ngth(5) Wednesday, April 1, 2009
  40. 48.

    JTeam Innovating J2EE Development Aggregations JTeam Innovating J2EE Development •

    sum • avg • count • min/max • stddev Wednesday, April 1, 2009
  41. 49.

    JTeam Innovating J2EE Development Output Rate Limiting JTeam Innovating J2EE

    Development Engine dispatches to Listener when output condition occurs. e.g. select irstream symbol, volume, price from MarketData.win:time(5.5 sec) output every 1 seconds Wednesday, April 1, 2009
  42. 50.

    JTeam Innovating J2EE Development Event Patterns JTeam Innovating J2EE Development

    Pattern Expression = Pattern atoms + Pattern Operators every (spike=ServiceMeasurement(latency>20000) or error=ServiceMeasurement(success=false)) select s from pattern [every s=SubmitOrderEvent -> (timer:interval(30 sec) and not OrderAcceptedEvent(theOrder.id=s.theOrder.id))] Wednesday, April 1, 2009
  43. 52.

    JTeam Innovating J2EE Development RDBMS Integration JTeam Innovating J2EE Development

    select name, healthy_temp from TempEvent.win:time(60 sec) temp, sql:mydb3 [' select name,healthy_temp from Player where name = ${temp.playerName} and $ {temp.temperature} > healthy_temp '] Wednesday, April 1, 2009
  44. 53.

    JTeam Innovating J2EE Development Non Event Based Data Integration JTeam

    Innovating J2EE Development public class InstrumentRepository { public static Exchange[] getExchangesForSymbol(String symbol) { ... } select ord, eligibleExchanges from TheOrder as ord, method:com.ociweb.jnb.esper.InstrumentRepository.ge tExchangesForSymbol(ord.symbol) as eligibleExchanges } Wednesday, April 1, 2009
  45. 54.

    JTeam Innovating J2EE Development CEP Design Patterns (1/9) JTeam Innovating

    J2EE Development Filtering: e.g. Click-stream analysis: a filter may be used to capture the trades that originate from a certain set of IP addresses. Wednesday, April 1, 2009
  46. 55.

    JTeam Innovating J2EE Development CEP Design Patterns (2/9) JTeam Innovating

    J2EE Development In Memory Caching: e.g. Click-stream analysis: a typical application may hold the recent clicks and searches performed by the users, coupled with the relevant historical and reference information. Wednesday, April 1, 2009
  47. 56.

    JTeam Innovating J2EE Development CEP Design Patterns (3/9) JTeam Innovating

    J2EE Development Aggregation over Windows: e.g. Click-stream analysis: it is often useful to compute the number of visitors who click on a particular link within a specified time interval. Wednesday, April 1, 2009
  48. 57.

    JTeam Innovating J2EE Development CEP Design Patterns (4/9) JTeam Innovating

    J2EE Development Database Lookups: e.g. Trading: a trading application may look up historical price for a stock, or certain information about an order, or certain rules and regulations stored in a database. Wednesday, April 1, 2009
  49. 58.

    JTeam Innovating J2EE Development CEP Design Patterns (5/9) JTeam Innovating

    J2EE Development Database Writes: e.g. Click-stream analysis: storing the raw click-stream history, together with derived data, in the database Wednesday, April 1, 2009
  50. 59.

    JTeam Innovating J2EE Development CEP Design Patterns (6/9) JTeam Innovating

    J2EE Development Correlation (Joins): e.g. Trading: correlating information from multiple exchanges to find arbitrage opportunities. Wednesday, April 1, 2009
  51. 60.

    JTeam Innovating J2EE Development CEP Design Patterns (7/9) JTeam Innovating

    J2EE Development Event Pattern Matching: e.g. Fraud detection: fraud patterns are often described as a sequence of events, in one or more streams. Wednesday, April 1, 2009
  52. 61.

    JTeam Innovating J2EE Development CEP Design Patterns (8/9) JTeam Innovating

    J2EE Development Hierarchical Events: e.g. Order Processing: Purchase Order can have multiple items which needs to be processed differently. Wednesday, April 1, 2009
  53. 62.

    JTeam Innovating J2EE Development CEP Design Patterns (9/9) JTeam Innovating

    J2EE Development Dynamic Queries: e.g. Trading environments: every trader can enter their subscriptions like X=MSFT, Y=.1%, Z=10 am. Wednesday, April 1, 2009
  54. 63.

    JTeam Innovating J2EE Development EsperIO JTeam Innovating J2EE Development Provides

    adapters support: • CSVAdapter • JMSAdapter • OpenTick Adapter Wednesday, April 1, 2009
  55. 65.

    JTeam Innovating J2EE Development Performance Tips JTeam Innovating J2EE Development

    // Better performance select * from RFIDEvent // Less good performance select assetId, zone, xlocation, ylocation from RFIDEvent Wednesday, April 1, 2009
  56. 66.

    JTeam Innovating J2EE Development Conclusion JTeam Innovating J2EE Development Do

    I really need it? Do I have the right infrastructure? Wednesday, April 1, 2009
  57. 67.

    JTeam Innovating J2EE Development Conclusion JTeam Innovating J2EE Development •

    Learning Curve of EPL • No Standardization of EPL • EPL is still evolving Wednesday, April 1, 2009
  58. 69.

    JTeam Innovating J2EE Development CEP in Dutch Market JTeam Innovating

    J2EE Development • KLM - TIBCO • Boekhandels Groep Nederlands (BGN) Wednesday, April 1, 2009
  59. 70.

    JTeam Innovating J2EE Development Resources JTeam Innovating J2EE Development Esper

    http://esper.codehaus.org/ CEP http://complexevents.com/ CEP http://www.cepbusinesscast.com/ CEP Open Source SOA Wednesday, April 1, 2009