49
24th Apr. 2014 Technical Lead Sriskandarajah Suhothayan WSO2 CEP 3.1.0 Product Release Webinar Software Engineer Lasantha Fernando

WSO2 Product Release Webinar - WSO2 Complex Event Processor

  • Upload
    wso2

  • View
    131

  • Download
    6

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: WSO2 Product Release Webinar - WSO2 Complex Event Processor

24th Apr. 2014

Technical LeadSriskandarajah Suhothayan

WSO2 CEP 3.1.0Product Release Webinar

Software EngineerLasantha Fernando

Page 2: WSO2 Product Release Webinar - WSO2 Complex Event Processor

**

About the Presenter(s)

๏ Sriskandarajah Suhothayan - [email protected]

Suho joined WSO2 in December 2011. He is a technical lead working in the Data technologies team where he leads development on the WSO2 Complex Event Processing Server. In addition to his product development efforts he has provided technology consulting on customer engagements, including customer QuickStart programs mainly focused on SAP integration.

๏ Lasantha Fernando - [email protected]

Lasantha joined WSO2 in February 2013. He is a software engineer working in the Data technologies team where he mainly focuses on the WSO2 Complex Event Processing Server. In addition to his product development efforts he has provided technology consulting on customer engagements.

Page 3: WSO2 Product Release Webinar - WSO2 Complex Event Processor

**

About WSO2๏ Global enterprise, founded in

2005 by acknowledged leaders in XML, web services technologies, standards and open source

๏ Provides only open source platform-as-a-service for private, public and hybrid cloud deployments

๏ All WSO2 products are 100% open source and released under the Apache License Version 2.0.

๏ Is an Active Member of OASIS, Cloud Security Alliance, OSGi Alliance, AMQP Working Group, OpenID Foundation and W3C.

๏ Driven by Innovation

๏ Launched first open source API Management solution in 2012

๏ Launched App Factory in 2Q 2013

๏ Launched Enterprise Store and first open source Mobile solution in 4Q 2013

Page 4: WSO2 Product Release Webinar - WSO2 Complex Event Processor

**

What WSO2 delivers

Page 5: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Outline

o Scenarios of Event Processingo What's new in CEP 3.1.0?

o WSO2 CEP Server & SOA integrationo Improvements in Siddhi Runtime CEP Engine.o High availability of WSO2 CEP

o How CEP can be combined with Business Activity Monitoring (BAM).

o Demo

Page 6: WSO2 Product Release Webinar - WSO2 Complex Event Processor

CEP Is & Is NOT!

o Is NOT!o Simple filters

■ Simple Event Processing■ E.g. Is this a gold or platinum customer?

o Joining multiple event streams■ Event Stream Processing

o Is !o Processing multiple event streams o Identify meaningful patterns among streamso Using temporal windows

■ E.g. Notify if there is a 10% increase in overall trading activity AND the average price of commodities has fallen 2% in the last 4 hours

Page 7: WSO2 Product Release Webinar - WSO2 Complex Event Processor

WSO2 CEP Server

o Enterprise grade server for CEP runtimeso Supports several transports (network access) o Supports several data formatso Governanceo Monitoringo Real-time Dashboard

Page 8: WSO2 Product Release Webinar - WSO2 Complex Event Processor

WSO2 CEP Server: Big Picture

Page 9: WSO2 Product Release Webinar - WSO2 Complex Event Processor

WSO2 CEP Detailed Architecture

Page 10: WSO2 Product Release Webinar - WSO2 Complex Event Processor

CEP Event Adaptors

● Is an adaptor for receiving and publishing events● Has the configurations to connect to external endpoints● Its many-to-many with CEP engine

Page 11: WSO2 Product Release Webinar - WSO2 Complex Event Processor

CEP Event Adaptors

Support for several transports (network access)● SOAP● HTTP● JMS● SMTP● SMS● Thrift● Kafka

Supporting data formats ● XML● JSON● Map● Text● WSO2Event - WSO2 data format over Thrift for High Performant

Event Capturing & Delivery Framework supports Java/C/C++/C# via Thrift language bindings

Page 12: WSO2 Product Release Webinar - WSO2 Complex Event Processor

● Supports database writes using Map messages○ Cassandra ○ MYSQL ○ H2

● Supports custom event adaptors via its pluggable architecture!

CEP Event Adaptors

Page 13: WSO2 Product Release Webinar - WSO2 Complex Event Processor

CEP Event Streams

o Event stream is a sequence of events o Events streams have in-flows and out-flowso Inflows can be from

o Event builders ■ Converts incoming XML, JSON, etc events to event stream

o Execution plans

o Outflows are to o Event formatters

■ Converts to event stream to XML, JSON, etc events

o Execution plans

Page 14: WSO2 Product Release Webinar - WSO2 Complex Event Processor

CEP Execution Plan

● Is an isolated logical execution unit● Each execution plan imports some of the event

streams available in CEP and defines the execution logic using queries and exports the results as output event streams.

● Its one-to-one with a CEP Backend Runtime Engine● It deals with Siddhi processing engine.

Page 15: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Default Event Types

o Default events do not need a mapping to be specified in event builder/formatter

o Sample default event for XML<events> <event> <metaData> <tenant_id>2</tenant_id> </metaData> <correlationData> <activity_id>ID5</activity_id> </correlationData> <payloadData> <clientPhoneNo>0771117673</clientPhoneNo> <clientName>Mohanadarshan</clientName> <clientResidenceAddress>15, Alexendra road, California</clientResidenceAddress> <clientAccountNo>ACT5673</clientAccountNo> </payloadData> </event><events>

o For Custom events, event mapping should be configured in Event builder and Formatter

Page 16: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Monitoring & Debugging (Event Statistics)Provides real-time statistical visual illustrations of request & response counts per time based on CEP server, execution plan, event adaptor, event builder and formatter.

Page 17: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Provides the actual message in a textual format before and after processing at each stage of the event flow

Monitoring & Debugging (Event Tracer)

Page 18: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Real time Dashboard

o Powered by WSO2 User Engagement Server (UES)o Gadget generation tool to configure gadgets

o Currently supports RDBMS only

Page 19: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Writing CEP Queries (using Siddhi

Runtime)

Page 20: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Siddhi Engine

Apache License, a java library, Tuple based event model Supports distributed processing

o Filters and Projectiono Windows

o Events are processed within temporal windows. (e.g. for aggregation and joins) ■ Time window vs. length window.

o Joins - Join two streamso Event ordering - Identify event sequences and patternso Event Partitions o Output Rate Limitingo Event Tables

Page 21: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Filters

o Filters the events by conditions, use to detect simple condition

o Conditionso >, <, = , <=, <=, !=o contains, instanceofo and, or, not

o Example

from <stream-name> [<conditions>]*select <attributes> insert into <stream-name>

from cseEventStream[price >= 20 and symbol==’IBM’]select symbol, volumeinsert into StockQuote

Page 22: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Window

from <stream-name> [<conditions>]#window.<window-name>(<parameters>) select <attributes>insert into <stream-name>

o Types of Windows o (Time | Length) (Sliding| Batch) windows

o Types of aggregate functionso sum, avg, max, min

o Example

from cseEventStream[price >= 20]#window.lengthBatch(50)select symbol, avg(price) as avgPricegroup by symbol having avgPrice>50insert into StockQuote

Page 23: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Join

o Used to join two streams based on a condition. There must be at least one window defined

o Unidirectional – event arriving only to the unidirectional stream triggers join

o Example

from <stream>#<window> [unidirectional] join <stream>#<window> on <condition> within <time>

insert into <stream>

from TickEvent[symbol==’IBM’]#window.length(2000) join NewsEvent#window.time(5 min)

on TickEvent.symbol==NewsEvent.companyselect * insert into JoinStream *

Page 24: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Pattern

o Use to Check condition A happen before/after condition B. o Can do iterative checks via “every” keyword.o Here with “within <time>”, SIddhi emits only events that

are within that time of each othero Example

from [every] <condition> → [every] <condition> … <condition> within <time>select <attributes> insert into StockQuote

from every (a1 = purchase[price < 10] ) -> a2 = purchase [price >10000 and a1.cardNo==a2.cardNo] within 1 day

select a1.cardNo as cardNo, a2.price as price, a2.place as placeinsert into potentialFraud

a1 x1 k5 a2 n7y1

Page 25: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Sequence

o Regular Expressions supportedo * - Zero or more matches (reluctant). o + - One or more matches (reluctant). o ? - Zero or one match (reluctant). o or - either event

o Here we have to refer events returned by * , + using square brackets to access a specific occurrence of that event

from <event-regular-expression> within <time> select <attributes> insert into <stream>

from a1 = requestOrder[action == "buy"], b1 = cseEventStream[price > a1.price and symbol==a1.symbol]+, b2 = cseEventStream[price <b1.price]select a1. symbol as symbol, b1[0].price as firstPrice, b2.price as orderPriceinsert into purchaseOrder

a1 b1 b1 b2 n7y1

Page 26: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Event Partitions

Partition types can be one of two typeso Variable Partitions - Partitions are created by the

discrete values that are encountered for a variable

define partition StockSymbol by StockStream.symbol

o Range partitions - Partitions are created according to predefined ranges of variables

define partition stockVolume by range volume < 10 as 'SMALL', range volume > 10 && volume < 100 as 'MEDIUM', range volume > 100 as 'LARGE'

define <partition-id> by <partition-type> (,<partition-type>)*

Page 27: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Event Tables

define table <table-name> (<attribute-name> <type> {, <attribute-name> <type>}*) ( from (<parameter-name>=’<value>’)+)?

Event tables can be used in the same manner as an event stream, with the difference being that events sent to an event table being persisted to a data source. CEP supports event tables for

o In Memoryo Relational

o MySQLo H2

define table cseEventTable(symbol string, price int, volume float) from ('datasource.name'='cepDataSource', 'table.name'='cepEventTable', 'caching.algorithm'='LRU')

Page 28: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Caching Support for Event Tables

o Event tables now support several caching algorithmso Basic: A size-based algorithm. Events are cached in a FIFO

manner. The oldest event is dropped when the cache is full.

o LRU (Least Recently Used): The least recently used event is dropped when the cache is full.

o LFU (Least Frequently Used): The least frequently used event is dropped when the cache is full.

Page 29: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Working with Event Tables

from <stream> (select <attribute-name> (,<attribute-name>)* )? insert into <table-name>

Inserts the selected attributes from the input stream into the event table.

from cseEventCheckStream[symbol==cseEventTable.symbol in cseEventTable] insert into outStream;

For update and delete

from <stream> update <table-name> (on <condition>)?

from <stream> delete <table-name> (on <condition>)?

Page 30: WSO2 Product Release Webinar - WSO2 Complex Event Processor

High Availability

o Execution plan specifies the distributed processing mode

<executionPlan name="RedundantNodeExecutionPlan" statistics="enable" trace="enable" xmlns="http://wso2.org/carbon/eventprocessor"> ... <siddhiConfiguration> <property name="siddhi.enable.distributed.processing">RedundantNode</property> <property name="siddhi.persistence.snapshot.time.interval.minutes">0</property> </siddhiConfiguration> ...</executionPlan>

Page 31: WSO2 Product Release Webinar - WSO2 Complex Event Processor

HA/ Persistence

o Option 1: Side by side o Takes 2X hardware, but recommended and and have

zero down timeo Option 2: Snapshot and restore

o Uses less HW o Will lose events between snapshotso Downtime while recovery

o ** Some scenarios you can use event tables to keep intermediate state

Page 32: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Scalingo Vertically scaling

o Can be distributed as a pipeline

o Horizontally scalingo Queries like windows, patterns, and Join have shared

states, hence hard to distribute!

Page 33: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Scaling (Contd.)o Currently users have to setup the pipeline manually

(WSO2 team can help)o Work is underway to support above pipeline and

distributer operators out of the box.

Page 34: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Event Recording

o Ability to record all/some of the events for future processing

o Few options o Publish them to Cassandra cluster using WSO2 data

bridge API or BAM (can process data in Cassandra with Hadoop using WSO2 BAM).

o Write them to distributed cache o Custom thrift based event recorder

Page 35: WSO2 Product Release Webinar - WSO2 Complex Event Processor

o Same JVM Performance (Siddhi with Esper, M means a Million) - 4 core machineo Filters 8M Events/Sec vs Esper 2M o Window 2.5M Events/Sec vs. Esper 1Mo Patterns 1.4M Events/Sec about 10X faster than Esper

o Over the Network Performance (Using thrift based WSO2 event format) - 8 core machineo Filter 0.25M (or 250K) Event/Sec

Performance Results

Page 36: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Integration with WSO2 BAM

Data Receiving Data Analyzing Data Presentation

Data Publishing

Page 37: WSO2 Product Release Webinar - WSO2 Complex Event Processor

CEP Role within WSO2 Platform

Page 38: WSO2 Product Release Webinar - WSO2 Complex Event Processor

DEMO

Page 39: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Scenarioo Monitoring stock exchange for game changing

momentso Two input event streams.

o Event stream of Stock Quotes from a stock exchangeo Event stream of word count on various company names

from twitter pages

o Check whether the last traded price of the stock has changed significantly(by 2%) within last minute, and people are tweeting about that company (> 10) within last minute

Page 40: WSO2 Product Release Webinar - WSO2 Complex Event Processor
Page 41: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Input events

o Input events are JMS Mapso Stock Exchange Stream

● Map<String, Object> map1 = new HashMap<String, Object>();■ map1.put("symbol", "MSFT");■ map1.put("price", 26.36);

● publisher.publish("AllStockQuotes", map1);o Twitter Stream

● Map<String, Object> map1 = new HashMap<String, Object>();● map1.put("company", "MSFT");● map1.put("wordCount", 8);● publisher.publish("TwitterFeed", map1);

Page 42: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Queries

Page 43: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Queriesfrom allStockQuotes[win.time(60000)]select symbol,price, avg(price) as averagePrice

group by symbol having ((price > averagePrice*1.02) or (averagePrice*0.98 > price ))

insert into fastMovingStockQuotes

from twitterFeed[win.time(60000)]select company as company, sum(wordCount) as words

group by companyhaving (words > 10)

insert into highFrequentTweets

from fastMovingStockQuotes[win.time(60000)] as fastMovingStockQuotes join highFrequentTweets[win.time(60000)] as highFrequentTweetson fastMovingStockQuotes.symbol==highFrequentTweets.company

select fastMovingStockQuotes.symbol as company,fastMovingStockQuotes.averagePrice as amount, highFrequentTweets.words as words

insert into predictedStockQuotes

Page 44: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Visualize Results

o Create a gadget that reads from MySQL databaseo The query should be something like

SELECT company,words FROM predictedStocks

Page 45: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Alert

o As an Email (Optional)

HiWithin last minute, people being tweeting about {company} {words}

times, and the last traded price of {company} has changed by 2% and now being trading at ${amount}.

FromCEP

Page 46: WSO2 Product Release Webinar - WSO2 Complex Event Processor

**

More Information !๏ WSO2 CEP 3.1.0

http://wso2.com/products/complex-event-processor/๏ CEP Performance Info http://srinathsview.blogspot.

com/2013/08/cep-performance-processing-100k-to.html๏ Creating Custom Event Adaptors for CEP 3.1.0 http://wso2.

com/library/articles/2013/08/writing-custom-event-adaptors-for-cep-3.0.0/

๏ Creating Custom Data Publishers to BAM/CEP http://wso2.org/library/articles/2012/07/creating-custom-agents-publish-events-bamcep

๏ Siddhi Query Partitioning http://lasanthatechlog.blogspot.com/2013/08/siddhi-query-partitioning-overview.html

๏ WSO2 BAM 2.4.0http://wso2.com/products/business-activity-monitor/

Page 47: WSO2 Product Release Webinar - WSO2 Complex Event Processor

**

Business Model

Page 48: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Questions?

Page 49: WSO2 Product Release Webinar - WSO2 Complex Event Processor

Contact us !