Progress Apama 4 0 Training Developing Apama Scenarios

  • Slides: 42
Download presentation
Progress® Apama® 4. 0 Training Developing Apama Scenarios in Event Modeler

Progress® Apama® 4. 0 Training Developing Apama Scenarios in Event Modeler

Overview of Apama Development Tools Event Modeler provides the ability for Other software less

Overview of Apama Development Tools Event Modeler provides the ability for Other software less technical youusers want to quickly create Apama applications in a graphical to integrate modelling environment - rather than using Apama Studio to write event processing logic directly in Monitor. Script or Java. Includes a library of standard blocks, Integration Adapter Framework allowing users to make use of pre-tested code for common event-processing tasks. Research Studio Management and Monitoring Apama Studio Event Modeler Dashboard Builder GUIs and Container Processes using Client APIs Event Correlator Dashboard Server 1 Progress Software Confidential Version 4. 0. 0 Dashboard GUI Copyright © 2008 Progress Software Corporation. All rights reserved.

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler § Defining States § Defining Variables § Manipulating Blocks § Composing Rules § Where to Get More Information § Summary 2 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

What is an Apama Scenario? § An Apama scenario is a description of a

What is an Apama Scenario? § An Apama scenario is a description of a real-time business strategy • • § An Apama application consists of a single scenario or several cooperating scenarios § Examples: • • 3 Event trigger and value analysis Action response A financial markets application that watches for changes in the value of named stocks and emits an event should a stock of interest fall below a parameterized value. A manufacturing plant monitoring application that ensures if an error occurs on the plant floor (a machine breaks down, missed production step) that the production plan is adjusted and someone is notified to take action. Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

What is an Apama Scenario? A scenario is made of: § States – A

What is an Apama Scenario? A scenario is made of: § States – A scenario is in one active state at a time • The state determines: • • § Variables • • • Used to contain working data and parameters Can be marked as inputs and outputs Blocks • • § Integrate scenarios with the rest of Apama Encapsulate reusable functionality Rules – Each rule is comprised of: • • A condition which is event-triggered An action which: • • • 4 The events that are listened for The active rules Sets variables Performs operations Causes state transitions Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Creating Scenarios in Event Modeler Edit rules Specify sequence of states – Intuitive visual

Creating Scenarios in Event Modeler Edit rules Specify sequence of states – Intuitive visual user interface design Define variables – Values can be adjusted at run time to specify conditions to monitor, analyze, and act upon Event Modeler Color Key • Blue refers to blocks (inputs, parameters and outputs) Add Block Instances – Encapsulated, pre-packaged code • Green refers to variables • Purple refers to literal expressions • All other items are black 5 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Demo: Event Modeler 6 Progress Software Confidential Version 4. 0. 0 Copyright © 2008

Demo: Event Modeler 6 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler § Defining States § Defining Variables § Manipulating Blocks § Composing Rules § Where to Get More Information § Summary 7 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Defining States State transition programming paradigm § § A scenario instance moves through a

Defining States State transition programming paradigm § § A scenario instance moves through a set of states A state includes one or more “if…then” rules • § Only one state is active at a time • § no branching or sub-states Special start and end states • • 8 Determine the scenario instance’s behavior when in that state Start state is entered upon creation of a scenario instance When the scenario instance reaches the end state, it has finished processing Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Defining States Guidelines § Think of states as belonging to two categories: • •

Defining States Guidelines § Think of states as belonging to two categories: • • § Try to minimise the number of states in a scenario • • § For example: Waiting for opportunity, submit order, wait for order to finish Give states meaningful names • 9 Scenarios with more rules in fewer states often perform better If you have more than 20 states you probably need to refactor (using a block, possibly exported from a scenario) Only add a state when the behavior of the strategy changes • § Wait state: – Strategy is waiting for an event (block update) to trigger its next action Processing State: – A state which should always cause a transition to some other state (for example, determine buy or sell) For debugging purposes Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Defining States 10 § To add a state, click the add button: § To

Defining States 10 § To add a state, click the add button: § To rename it, double-click the state: § To remove it, select it and click the delete button: § To move it, drag and drop § To resize it, drag a resize handle Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Exercise: Defining States § Objective • § 11 Learn how to create a new

Exercise: Defining States § Objective • § 11 Learn how to create a new scenario in the Event Modeler and add states to the scenario Follow instructions in the “Create a Scenario” document Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler § Defining States § Defining Variables § Manipulating Blocks § Composing Rules § Where to Get More Information § Summary 12 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Defining Variables § Variables can be input, output, or neither • • § Variables

Defining Variables § Variables can be input, output, or neither • • § Variables have default values • § Specified at scenario creation time (using Event Modeler) Variables are typed • • 13 Inputs are specified when a scenario instance is created Inputs can be edited from dashboards Inputs and outputs can be rendered in dashboards Variables marked neither input or output are private (internal to the scenario) string, number, choice (enum) and condition (boolean) Variables are autotyped, but can be overridden by double-clicking the green square next to the variable name Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Defining Variables 14 § To add a variable type its name in the empty

Defining Variables 14 § To add a variable type its name in the empty row at the bottom of the variable table: § To delete a variable select it and hit the delete key or delete button: § To re-order variables use the re-order buttons Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Exercise: Defining Variables § Objective • § 15 Learn how to define variables for

Exercise: Defining Variables § Objective • § 15 Learn how to define variables for your new scenario in the Event Modeler Follow instructions in the “Create a Scenario” document Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler § Defining States § Defining Variables § Manipulating Blocks § Composing Rules § Where to Get More Information § Summary 16 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Blocks What is a block? § A block is an encapsulated block of reusable

Blocks What is a block? § A block is an encapsulated block of reusable code § Blocks provide integration between scenarios and the rest of Apama • § Blocks can also provide reusable utility code • 17 They can send and receive events For example: averaging a signal over a time window Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Blocks What is a block? § Blocks are saved as BDF files § Blocks

Blocks What is a block? § Blocks are saved as BDF files § Blocks are kept in catalogs • • 18 Catalogs are directories Catalogs can contain subdirectories Blocks are stored in directories named <blockname>. BDF – For example: ABlock. bdf The block files themselves use the same name, appended with a version number – For example: ABlock v 1. 0. bdf – Allowing for multiple versions Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Blocks Why use blocks? § Strategies need to interact with the outside world •

Blocks Why use blocks? § Strategies need to interact with the outside world • • • § Source input data Send output data Perform operations Blocks provide access to common pre-tested utility code • Instead of writing it afresh in each scenario Scenario Logic 19 Progress Software Confidential Block Version 4. 0. 0 Events Apama Application Copyright © 2008 Progress Software Corporation. All rights reserved.

Manipulating Blocks Components of a blocks § Parameters • • • § Output feeds

Manipulating Blocks Components of a blocks § Parameters • • • § Output feeds • • § • Can be used to chain calculations in a scenario without using rules Are structured like outputs, with multiple typed fields Operations • • 20 Often represent an event received by the block, often an update Contain multiple fields each of which is typed Input feeds • § Act like scenario variables and are typed in the same fashion Affect the block’s operation Often provide the parameters for operations Cause things to happen, usually by causing an event to be sent to the rest of Apama Do not have parameters, but often use the block’s parameters Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Manipulating Blocks 21 § To add an instance of a block to the scenario,

Manipulating Blocks 21 § To add an instance of a block to the scenario, select the block in the catalog and click the Add button: § To remove it from the scenario, select it from the block list or block wiring view and click the Delete button § Blocks can have their parameters set in the same way as variables, literal or by linking to other variables Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Manipulating Blocks Wiring block input and output feeds together 22 § To wire blocks

Manipulating Blocks Wiring block input and output feeds together 22 § To wire blocks together, use the Block Wiring view and drag a line from an output node to an input node: • Use the Configure Block Wiring dialogue to map the individual fields Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Linking Blocks and Variables § Linking variables to blocks • • § Linking blocks

Linking Blocks and Variables § Linking variables to blocks • • § Linking blocks to variables • • 23 Scenario variables can be linked to a field of a block output feed, via the right-click menu Whenever the block outputs an event on the given feed, the variable is automatically updated Block parameters can be linked to scenario variables, via the right-click menu Whenever the variable’s value is modified, the block’s parameter is automatically updated Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Exercise: Adding Blocks and Linking Variables § Objectives • § 24 Learn how to:

Exercise: Adding Blocks and Linking Variables § Objectives • § 24 Learn how to: – Add block instances to your new scenario in the Event Modeler – Link block parameters and variable scenarios Follow instructions in the “Create a Scenario” document Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler § Defining States § Defining Variables § Manipulating Blocks § Composing Rules § Where to Get More Information § Summary 25 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Composing Rules § Rules define scenario behaviour • § Each rule contains three sections:

Composing Rules § Rules define scenario behaviour • § Each rule contains three sections: • • • § Name and Description – Optional but recommended for debugging Condition - An event-triggered boolean expression Action - An action that takes place should the condition hold – Sets variables and block parameters – Performs operations on blocks – Last action is always a state transition rule Rules are contained within each state • 26 A rule is an if-then statement Global rules are copied and pasted into every state Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

How Rules are Evaluated § Rules are evaluated sequentially (top to bottom) • •

How Rules are Evaluated § Rules are evaluated sequentially (top to bottom) • • § When no rule evaluates to true • • 27 Global rules before state-specific rules When one rule’s condition holds, its action is executed When the transition action is “continue”, evaluation continues downwards After the state changes, the new state’s rules are immediately evaluated The scenario waits in the current state Whenever a relevant input variable or block output changes rules are reevaluated Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Rule Conditions When X != X • A rule condition can refer to a

Rule Conditions When X != X • A rule condition can refer to a field of an output feed of a block – For example: A rule can trigger when a statistics block outputs an average value of 100 or higher • Be aware that the semantics of this are subtle: – Scenario instances are constantly saving a copy of the most recent event from each output feed of each block instance – When referring to an output feed, the test is on this copy (which could have been taken before the current state was entered) – Any condition referring to an output feed that has not yet fired an event always evaluates to false § Even “X = X”! 28 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Rules and State Transitions Different ways to move within the same state State 1

Rules and State Transitions Different ways to move within the same state State 1 ? Condition A !. . . ? Condition B ! Continue ! Move to State 1 ? Condition C !. . . “Continue” Continues to the next rule in the state (i. e. Condition C is checked) “Move To <same state>” Restarts with first rule in the state (i. e. Condition A is checked) Beware of creating infinite loops ! 29 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Composing Rules 30 § To add a rule, use the add button: § To

Composing Rules 30 § To add a rule, use the add button: § To re-order rules, use the re-order buttons: § To delete a rule, use the delete key or the delete button: Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Composing Rules Right-click rule construction § § § Both the rule’s conditions and actions

Composing Rules Right-click rule construction § § § Both the rule’s conditions and actions are built using right-click menus Rule construction can be quicker using copy and paste Rule expressions are trees • • 31 By clicking more times on a leaf element, you can select more of the tree. The selection can be: – Copied or pasted over – Changed or reverted using the right-click menu Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Expressions in Rules § § Expressions are used in conditions and actions Expression are

Expressions in Rules § § Expressions are used in conditions and actions Expression are assembled by choosing: • Operators – – Numeric operators (<, ≤, >, ≥, =, ≠) Text operators (=, ≠, contains) Choice operators (=, ≠) Logical operators (and, or, not) – Arithmetic operators (+, -, *, /) • Values – – – 32 Constants Scenario variables Block parameters Function calls Block output feed event fields Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Composing Rules Expressions - functions 33 • Event Modeler provides some commonly-required functions •

Composing Rules Expressions - functions 33 • Event Modeler provides some commonly-required functions • For example: – abs(n), ceil(n), floor(n), round(n, dp) – concat(t 1, t 2), replace(original, old, new) – to_boolean(t), to_number(t), to_text(n) • You can also add your own functions Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Composing Conditions § 34 Example of condition construction: Progress Software Confidential Version 4. 0.

Composing Conditions § 34 Example of condition construction: Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Composing Rules Adding/Removing Actions § To add an action statement to a rule’s body,

Composing Rules Adding/Removing Actions § To add an action statement to a rule’s body, left-click on the circle § 35 To delete an action statement from the rule’s body, rightclick on the circle Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Exercise: Composing Rules § Objective • § 36 Learn how to compose rules in

Exercise: Composing Rules § Objective • § 36 Learn how to compose rules in a scenario using the Apama Event Modeler tool Follow instructions in the Exercise booklet Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler

Topics § What is an Apama Scenario? § Creating a Scenario in Event Modeler § Defining States § Defining Variables § Manipulating Blocks § Composing Rules § Where to Get More Information § Summary 37 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Where to Get More Information § Apama 4. 0 Documentation: Developing Scenarios book •

Where to Get More Information § Apama 4. 0 Documentation: Developing Scenarios book • • § Tutorial 7: Scenario Modeling • 38 From PC Desktop: Start Programs Apama 4. 0 Documentation In Apama Studio: Help Contents Apama Studio Documentation In Apama Studio: Welcome Tutorials Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Summary § In this module, you learned how to use the Event Modeler to

Summary § In this module, you learned how to use the Event Modeler to create an Apama scenario and: • • 39 Define states Define variables Interact with code blocks Compose rules Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

Questions? 40 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software

Questions? 40 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.

41 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation.

41 Progress Software Confidential Version 4. 0. 0 Copyright © 2008 Progress Software Corporation. All rights reserved.