Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, 119333 Phone: +7 (495) 981-0531 Fax: +7 (495) 232-2683

Slides:



Advertisements
Similar presentations
ASP.NET Best Practices Dawit Wubshet Park University.
Advertisements

Apache Struts Technology
Drools – Diabetes Phenotype Identification
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
COMP171 Data Structure & Algorithm Tutorial 1 TA: M.Y.Chan.
Programming Languages Structure
VB in Context Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh Pittsburgh, Pa 15260
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Outline Chapter 1 Hardware, Software, Programming, Web surfing, … Chapter Goals –Describe the layers of a computer system –Describe the concept.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 10 Classes Continued
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Classes in C++ Bryce Boe 2012/08/15 CS32, Summer 2012 B.
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
Software Reengineering 2003 년 12 월 2 일 최창익, 고광 원.
1 Developing Rules Driven Workflows in Windows Workflow Foundation Jurgen Willis COM318 Program Manager Microsoft Corporation.
Programming Languages and Paradigms Object-Oriented Programming.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
Advanced Java New York University School of Continuing and Professional Studies.
Katanosh Morovat.   This concept is a formal approach for identifying the rules that encapsulate the structure, constraint, and control of the operation.
Database Technical Session By: Prof. Adarsh Patel.
Forms - An Overview of Oracle Form Builder v.6.0 Abhishek Parag Prashant Arun.
Chapter 11 Inheritance and Composition. Chapter Objectives Learn about inheritance Learn about subclasses and superclasses Explore how to override the.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Hans-Peter Plag November 6, 2014 Session 4 (Programming Languages) (Data Types and Variables) Expressions and Operators Flow Control.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Data Mining By Dave Maung.
Middleware for FIs Apeego House 4B, Tardeo Rd. Mumbai Tel: Fax:
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
CS333 Intro to Operating Systems Jonathan Walpole.
Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495)
INNOV-10 Progress® Event Engine™ Technical Overview Prashant Thumma Principal Software Engineer.
Database Management Systems (DBMS)
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Workforce Scheduling Release 5.0 for Windows Implementation Overview OWS Development Team.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Charm++ overview L. V. Kale. Parallel Programming Decomposition – what to do in parallel –Tasks (loop iterations, functions,.. ) that can be done in parallel.
Pattern Bridge. Definition Bridge is the structural pattern that separates abstraction from the implementation so that both of them can be changed independently.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
Introduction to Active Directory
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Slide 1 Chapter 8 Architectural Design. Slide 2 Topics covered l System structuring l Control models l Modular decomposition l Domain-specific architectures.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
© 2014 IBM Corporation The BE 2 model: When Business Events meet Business Entities Fabiana Fournier and Lior Limonad 8 September 2014.
V7 Foundation Series Vignette Education Services.
20 Copyright © 2006, Oracle. All rights reserved. Best Practices and Operational Considerations.
Managing Data Resources File Organization and databases for business information systems.
Building Enterprise Applications Using Visual Studio®
SQL Server Statistics and its relationship with Query Optimizer
The need for Programming Languages
Forms Concepts Triggers Fired when Internal/External events occur
CSC 222: Computer Programming II
Processes and threads.
JAVA MULTIPLE CHOICE QUESTION.
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
CS399 New Beginnings Jonathan Walpole.
About the Presentations
CS490 Windows Internals Quiz 2 09/27/2013.
CMPE419 Mobile Application Development
Data Model.
CMPE419 Mobile Application Development
Rule Engine Concepts and Drools Expert
Presentation transcript:

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) The art of technology Drools and Drools 5 Fusion

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Drools is an open source rules engine, which lets you express business logic rules in a declarative way using non-XML native language

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Agenda Drools Basics -Advantages of Drools -DRL file -Executing rules -Conflicts resolution -Updating knowledge in rules engine Drools Fusion (CEP) -What is Complex Event Processing -Drools Fusion vision -Features and examples

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Advantages of Drools Separates application from conditions controlling the flow -Rules can be modified by different groups -No need to recompile or redeploy -All rules are in one place Readable native non-XML language -Easy to learn -Eclipse plug-in helps to visualize rules Native BRMS implementation Complex event processing engine Rete algorithm

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) DRL file rule "User has no picture“ dialect=“java” when follower : Follower(hasPicture == false) then follower.setRanking(follower.getRanking() ); end rule "Extract and classify followers“ dialect=“java” when twitter : Twitter() then for (User user : twitter.getFollowers()) { Follower follower = new Follower(); follower.setUser(user); follower.setFollows(twitter); follower.setClassification(TwitterUserType.getType(TwitterUtils.getTwitterI nfluenceRatio(user))); follower.setHasPicture(TwitterUtils.hasSetProfileImage(user)); insert(follower); } end

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Executing rules KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); knowledgeBuilder.add(drlFileAsResource, ResourceType.DRL); Collection pkgs = knowledgeBuilder.getKnowledgePackages(); knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(); knowledgeBase.addKnowledgePackages(pkgs); First, we need to create rules knowledge base It parses and compiles DRL files It extracts named packages of rules for KnowledgeBaseFactory

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Executing rules KnowledgeSession provides the way of exposing objects to be ruled StatefulKnowledgeSession knowledgeSession = knowledgeBase.newStatefulKnowledgeSession(); Twitter twitter = new Twitter(twitterUser, twitterPassword); knowledgeSession.insert(twitter); Fire rules knowledgeSession.fireAllRules();

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) The art of technology Questions… (to be continued)

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Conflicts resolution Often we need non-trivial flow of rules -Validate data in knowledge base -Prepare base for future rules flow -Cover rules from execution It is solved by using salience parameter…

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Conflicts resolution (example) package demo; import demo.Machine; import demo.Test; import demo.TestDAO; import java.util.Calendar; import java.sql.Timestamp; global TestDAO testDAO; DRL file first block function void setTestsDueTime(Machine machine, int numberOfDays) { setDueTime(machine, Calendar.DATE, numberOfDays); } function void setDueTime(Machine machine, int field, int amount) { Calendar calendar = Calendar.getInstance(); … machine.setTestsDueTime(new Timestamp(calendar.getTimeInMillis())); } Defining functions in DRL file

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Conflicts resolution (example) rule "Tests for type2, DNS server machine" salience 100 when machine : Machine( type == "Type2", functions contains "DNS Server") then Test test5 = testDAO.findByKey(Test.TEST5); machine.getTests().add(test5); insert( test5 ); end rule "Due date for Test 5" salience 50 when machine : Machine() Test( id == Test.TEST5 ) then setTestsDueTime(machine, 14); end

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Conflicts resolution Rules with higher salience will be fired first -preparing objects for future rules execution -filtering some instances from ruling Dynamic salience rule "high value fires first“ salience (person.bonus * item.price) when person : Person() item : Item() then... end

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Updating knowledge in rules engine Knowledge base can be updated inside rule’s body -insert() – Inserted object will be used by rules engines inside current session -update() – Updates existing in working memory object for the rest of rules -delete() – Removed object will not be ruled on current execution

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) rule "Tests for type2, DNS server machine" salience 100 when machine : Machine( type == "Type2", functions contains "DNS Server") then Test test5 = testDAO.findByKey(Test.TEST5); machine.getTests().add(test5); update( machine ); end rule "Due date for Test 5" salience 50 when machine : Machine( tests contains (testDAO.findByKey(Test.TEST5)) ) then setTestsDueTime(machine, 14); end Updating knowledge in rules engine

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Separates application from conditions controlling the flow Significantly reduce the complexity of components that implement the business-rules logic Rules engine expresses rules using a declarative approach that is maintainable and extensible Easy to learn by Java developers Once again…

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) The art of technology Questions… (to be continued)

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) The art of technology Drools 5 Fusion

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Agenda What is Complex Event Processing Drools Fusion scenario Features -Events -Session Clock -Streams support -Temporal reasoning -Event processing modes -Sliding windows -KnowledgeBase partitioning -Memory management

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) What is Complex Event Processing Complex Event Processing is an event processing concept for identifying the meaningful events within an event cloud

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) CEP employs techniques like … -detection of complex patterns of many events -event correlation and abstraction -event hierarchies -relationships between events (causality, membership, timing) -event-driven processes What is Complex Event Processing

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Understand and handle events as first class citizens of the platform Select a set of interesting events in a cloud or stream of events Detect the relevant relationships (patterns) among these events Take appropriate actions based on the patterns detected Drools Fusion scenario

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Features Events Session Clock Streams support Temporal reasoning Event processing modes Sliding windows KnowledgeBase partinioning Memory management

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Features: Events Events, from a Drools perspective, are just a special type of fact -usually immutable -strong temporal constraints -managed lifecycle -use of sliding windows

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Event declaration Features: Events public class VoiceCall { private String originNumber; private String destinationNumber; private Date callDateTime; private long callDuration; // constructors, getters and setters } declare event callDateTime callDuration 1h35m ) end DRL file

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Session clock provide availability of concept “now” Implements strategy pattern -Rules testing -Regular execution -Special environments – clock synchronization – appServer provided clocks -Rules replay or simulation Two default implementations are provided Features: Session Clock

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Real time clock Features: Session Clock KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); config.setOption( ClockTypeOption.get("realtime") ); Pseudo clock KnowledgeSessionConfiguration conf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); conf.setOption( ClockTypeOption.get( "pseudo" ) ); StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession( conf, null ); SessionPseudoClock clock = session.getSessionClock(); FactHandle handle1 = session.insert( tick1 ); clock.advanceTime( 10, TimeUnit.SECONDS ); FactHandle handle2 = session.insert( tick2 ); clock.advanceTime( 30, TimeUnit.SECONDS ); FactHandle handle3 = session.insert( tick3 );

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Different forms of streams -JMS queues -database tables -raw sockets -Web Service calls -flat text files -etc. Events are orders by timestamp Meanings are usually extracted from correlation of events and even streams Homogeneous and heterogeneous streams Features: Streams support

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Features: Streams support StatefulKnowledgeSession session =... WorkingMemoryEntryPoint atmStream = session.getWorkingMemoryEntryPoint( "ATM Stream" ); atmStream.insert( aWithdrawRequest ); rule "apply fee on withdraws on branches" when WithdrawRequest( $ai : accountId, processed == true ) from entry-point "Branch Stream" CheckingAccount( accountId == $ai ) then // apply a $2 fee on the account end

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Features: Temporal reasoning $eventA : EventA( this after[ 3m30s, 4m ] $eventB ) 3m30s <= $eventA.startTimestamp - $eventB.endTimeStamp <= 4m $eventA : EventA( this before[ 3m30s, 4m ] $eventB ) abs( $eventA.startTimestamp - $eventB.startTimestamp ) <= 15s && abs( $eventA.endTimestamp - $eventB.endTimestamp ) <= 10s $eventA : EventA( this coincides[15s, 10s] $eventB ) 2s <= $eventA.startTimestamp - $eventB.startTimestamp <= 6s && 4s <= $eventB.endTimestamp - $eventA.endTimestamp <= 10s $eventA : EventA( this during[ 2s, 6s, 4s, 10s ] $eventB ) $eventB.startTimestamp < $eventA.startTimestamp && abs( $eventA.endTimestamp - $eventB.endTimestamp ) <= 5s $eventA : EventA( this finishes[ 5s ] $eventB ) abs( $eventB.startTimestamp - $eventA.endTimestamp) <= 5s $eventA : EventA( this meets[ 5s ] $eventB )

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Cloud mode -no notion of time -no clock synchronization -no events ordering Stream mode -time-ordered events -synchronization between stream by session clocks -automatic event lifecycle management -rules delaying -sliding window support Features: Event Processing modes

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Enabling Stream mode Features: Event Processing modes KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); config.setOption( EventProcessingOption.STREAM ); drools.eventProcessingMode = stream or Rules delaying using negative pattern rule "Sound the alarm" when $f : FireDetected( ) not( SprinklerActivated( this after[0s,10s] $f ) ) then // sound the alarm end

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Sliding time windows Sliding length windows Features: Sliding windows rule "Sound the alarm in case temperature rises above threshold" when TemperatureThreshold( $max : max ) Number( doubleValue > $max ) from accumulate( SensorReading( $temp : temperature ) over window:length( 100 ), average( $temp ) ) then // sound the alarm end

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Features: KnowledgeBase partitioning Does your hardware contain multiple processors? Does your knowledge session process a high volume of facts? Are the LHS of your rules expensive to evaluate? (ex: use expensive "from" expressions) Does your knowledge base contain hundreds or more rules? KnowledgeBaseConfiguration config = knowledgeBaseFactory.newKnowledgeBaseConfiguration(); config.setOption( MultithreadEvaluationOption.YES ); config.setOption( MaxThreadsOption.get(5) ); drools.multithreadEvaluation = drools.maxThreads = or

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Features: Memory management explicitly, using the expiration policy implicitly, analyzing the temporal constraints on events declare 30m ) end rule "correlate orders" when $bo : BuyOrderEvent( $id : id ) $ae : AckEvent( id == $id, this after[0,10s] $bo ) then // do something end

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) Finally… Session clocks provide an important concept of “now” Events are usually immutable and have strong relationships A list of operators allows to detect correlation of events -after -before -includes Sliding windows allow to accumulate data during period of time

Artezio LLC Address: 3G Gubkina Str., suite 504, Moscow, Russia, Phone: +7 (495) Fax: +7 (495) The art of technology Questions…