Models and Languages for Coordination and Orchestration IMT

  • Slides: 46
Download presentation
Models and Languages for Coordination and Orchestration IMT- Institutions Markets Technologies - Alti Studi

Models and Languages for Coordination and Orchestration IMT- Institutions Markets Technologies - Alti Studi Lucca Formal Languages for Flow Composition and Compensation: Sagas Roberto Bruni Dipartimento di Informatica Università di Pisa 1

Roberto Bruni @ IMT Lucca 12 April 2005 c. CSP and Sagas n Independently

Roberto Bruni @ IMT Lucca 12 April 2005 c. CSP and Sagas n Independently from c. CSP a similar calculus has been devised in Pisa n n n inspired by sagas (rather than BPEL 4 WS) different compensation policies for parallel processes any action can succeed or fail n n THROW and YIELD are not explicit in the language big-step SOS semantics Institutions Markets Technologies IMT 2

Roberto Bruni @ IMT Lucca 12 April 2005 Outline n Sequential Sagas n n

Roberto Bruni @ IMT Lucca 12 April 2005 Outline n Sequential Sagas n n n n n Graphical representation Syntax Big Step Semantics Adequacy results Parallel Sagas Nested Sagas Additional features Comparison with c. CSP Implementation issues Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 3

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Syntax Accept Order Update

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Syntax Accept Order Update Credit Prepare Order Refuse Order Refund Money Update Stock S = { AO%RO ; UC%RM ; PO%US } (Step) X (Process) P (Saga) S Institutions Markets Technologies IMT : : = 0 | A%B : : = X | P; P : : = { P } Models and Languages for Coordination and Orchestration 4

Roberto Bruni @ IMT Lucca 12 April 2005 n Sequential Sagas: Semantics Preliminaries I

Roberto Bruni @ IMT Lucca 12 April 2005 n Sequential Sagas: Semantics Preliminaries I Syntactic sugar n inert compensations are immaterial n n sequential composition is associative n n IMT ( P; Q ) ; R P ; ( Q; R ) 0 is the identity for sequential composition n Institutions Markets Technologies A A%0 0; P P; 0 P Models and Languages for Coordination and Orchestration 5

Roberto Bruni @ IMT Lucca 12 April 2005 n An activity A either n

Roberto Bruni @ IMT Lucca 12 April 2005 n An activity A either n n n Sequential Sagas: Semantics Preliminaries II commits (A ) aborts (A ) = {A 1 , …, An } Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 6

Roberto Bruni @ IMT Lucca 12 April 2005 n A saga S = {

Roberto Bruni @ IMT Lucca 12 April 2005 n A saga S = { P } under either n n S ) commits ( S aborts ( ) fails ( S * ) n n Sequential Sagas: Semantics Preliminaries III is the observable flow Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 7

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Semantics n A process

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Semantics n A process P under either n n < , ß’> ) <P, ß> commits ( < , 0> ) <P, ß> aborts ( <P, ß> < * , 0> ) fails ( n aborts = successfully compensated n ß, ß’ are the installed compensations n Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 8

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Semantics , ß> (zero)

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Semantics , ß> (zero) <P, 0> < {P} (saga) A , A < , B; ß> <A%B, ß> (s-act) 0 < , ß> <0, ß> (f-cmp) <ß, 0> < , 0> A , <A%B, ß> * (s-cmp) <ß, 0> < , 0> A , <A%B, ß> IMT Institutions Markets Technologies Models and Languages for Coordination and Orchestration 9

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Semantics ’ <P, ß>

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Semantics ’ <P, ß> < , ß’’> <Q, ß’’> < ; ’ <P; Q, ß> < , ß’> (s-step) , ß’> Institutions Markets Technologies IMT <P, ß> < * , 0> <P; Q, ß> < * , 0> (a-step’’) <P, ß> < , 0> <P; Q, ß> < , 0> (a-step’) Models and Languages for Coordination and Orchestration 10

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Adequacy S A 1

Roberto Bruni @ IMT Lucca 12 April 2005 Sequential Sagas: Adequacy S A 1 Institutions Markets Technologies IMT Aj Ak An and = A 1; …; Ak-1; Bk-1; …; B 1 Aj B 1 Bj Ak An S * and = A 1; …; Ak-1; Bk-1; …; Bj+1 S and = A 1; …; An A 1 Aj B 1 Bj Ak Models and Languages for Coordination and Orchestration An 11

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Syntax Update Credit Accept

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Syntax Update Credit Accept Order Refuse Order Refund Money Prepare Order Update Stock S = { AO%RO ; UC%RM | PO%US } Institutions Markets Technologies IMT (Step) X (Process) P (Saga) S : : = 0 | A%B : : = X | P; P | P|P : : = { P } Models and Languages for Coordination and Orchestration 12

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Naïvely A 1 A’

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Naïvely A 1 A’ 1 Institutions Markets Technologies IMT B 1 Bj B’ 1 B’j Bn A 2 C 1 Ck Cm C’ 1 C’k C’m A 1; (B 1; …; Bj-1; B’j-1; …; B’ 1 | C 1; …; Cm; C’m; …; C’ 1); A’ 1 Models and Languages for Coordination and Orchestration 13

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Revised A 1 A’

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Revised A 1 A’ 1 Bj B’ 1 B’j Bn A 2 C 1 Ck Cm C’ 1 C’k C’m A 1; (B 1; …; Bj-1; B’j-1; …; B’ 1 | 0); A’ 1 A 1; (B 1; …; Bj-1; B’j-1; …; B’ 1 | C 1; C’ 1); A’ 1 … Institutions Markets Technologies IMT A 1; (B 1; …; Bj-1; B’j-1; …; B’ 1 | C 1; …; Cm; C’m; …; C’ 1); A’ 1 Models and Languages for Coordination and Orchestration 14

Roberto Bruni @ IMT Lucca 12 April 2005 Digression: Parallel Sagas in c. CSP

Roberto Bruni @ IMT Lucca 12 April 2005 Digression: Parallel Sagas in c. CSP A 1 A’ 1 Bj B’ 1 B’j Bn A 2 C 1 Ck Cm C’ 1 C’k C’m A 1; B 1; …; Bj-1; B’j-1; …; B’ 1 ; A’ 1 A 1; ((B 1; …; Bj-1)|C 1) ; ((B’j-1; …; B’ 1)|C’ 1) ; A’ 1 … Institutions Markets Technologies IMT A 1; ((B 1; …; Bj-1)|(C 1; …; Cm)) ; ((B’j-1; …; B’ 1)|(C’m; …; C’ 1)) ; A’ 1 Models and Languages for Coordination and Orchestration 15

Roberto Bruni @ IMT Lucca 12 April 2005 n Sequential Sagas: Semantics Preliminaries I

Roberto Bruni @ IMT Lucca 12 April 2005 n Sequential Sagas: Semantics Preliminaries I Syntactic sugar n parallel composition is AC 1 n A A%0 ( P; Q ) ; R P ; ( Q; R ) n 0; P P; 0 P n ( P|Q ) | R P | ( Q|R ) n P | 0 P n P | Q Q | P n Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 16

Roberto Bruni @ IMT Lucca 12 April 2005 n A process P under either

Roberto Bruni @ IMT Lucca 12 April 2005 n A process P under either n n <P, ß> < , ß’> ) commits ( < , 0> ) aborts ( <P, ß> < , 0> ) fails ( <P, ß> * < , 0> ) <P, ß> is forced to abort ( < , 0> ) is forced to fail ( <P, ß> * n n Parallel Sagas: Semantics Preliminaries II is the observable concurrent flow Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 17

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics I <P, 0>

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics I <P, 0> < , ß> {P} (saga) { , , * } IMT Institutions Markets Technologies <ß, 0> <P, ß> < * , 0> (forced-abt’’) <ß, 0> <P, ß> < , 0> (forced-abt’) Models and Languages for Coordination and Orchestration 18

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics II Institutions Markets

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics II Institutions Markets Technologies IMT ’ <Q, 0> < , ß’’> | ’ <P|Q, ß> < , ß’|ß’’; ß> <P, 0> < , ß’> (s-par) Models and Languages for Coordination and Orchestration 19

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics III (c-par’) 1,

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics III (c-par’) 1, 2 { } <ß, 0> < , 0> ’ <P, 0> < 1, 0> <Q, 0> < 2, 0> , | ’; <P|Q, ß> < 1 2 , 0> * * Institutions Markets Technologies IMT * * * Models and Languages for Coordination and Orchestration * 20

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics IV (c-par’’) 1,

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics IV (c-par’’) 1, 2 { } <ß, 0> < , 0> ’ <P, 0> < 1, 0> <Q, 0> < 2, 0> , | ’; <P|Q, ß> < 1 2 * , 0> * * Institutions Markets Technologies IMT * * * Models and Languages for Coordination and Orchestration * 21

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics V (f-par) ’

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Semantics V (f-par) ’ <P, 0> < 1, 0> <Q, 0> < 2 , 0> 2 { , , * } | ’ <P|Q, ß> < 1 2 , 0> 1 { * , * } * * Institutions Markets Technologies IMT * * * Models and Languages for Coordination and Orchestration * 22

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Adequacy I Completion Institutions

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Adequacy I Completion Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 23

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Adequacy II Successful Compensation

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Adequacy II Successful Compensation Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 24

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Adequacy III Failed Compensation

Roberto Bruni @ IMT Lucca 12 April 2005 Parallel Sagas: Adequacy III Failed Compensation Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 25

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Graphically Update Credit Accept

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Graphically Update Credit Accept Order Refuse Order Refund Money Prepare Order Update Stock Add Points Subtract Points Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 26

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Syntax (Step) X (Process)

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Syntax (Step) X (Process) P (Saga) S Institutions Markets Technologies IMT : : = 0 | A%B | S : : = X | P; P | P|P : : = { P } Models and Languages for Coordination and Orchestration 27

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Syntax Update Credit Accept

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Syntax Update Credit Accept Order Refuse Order Refund Money Prepare Order Update Stock Add Points Subtract Points S { AO%RO ; UC%RM | PO%US | {AP%SP} } Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 28

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Semantics I <P, 0>

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Semantics I <P, 0> < , ß’> <{P}, ß> < , ß’; ß> (sub-cmt) ß’ acts as default compensation Institutions Markets Technologies IMT <P, 0> < * , 0> <{P}, ß> < * , 0> (sub-fail) <P, 0> <{P}, ß> < , ß> (sub-abt) Models and Languages for Coordination and Orchestration 29

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Semantics II (sub-forced-1) <P,

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Semantics II (sub-forced-1) <P, 0> < * , 0> <{P}, ß> < * , 0> (sub-forced-2’) <ß, 0> < , 0> ; <{P}, ß> < , 0> <P, 0> < , 0> (sub-forced-2’’) IMT , *} Institutions Markets Technologies <P, 0> <ß, 0> < , 0> { ; <{P}, ß> < * , 0> Models and Languages for Coordination and Orchestration 30

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Adequacy I Completion Institutions

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Adequacy I Completion Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 31

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Adequacy II Successful Compensation

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Adequacy II Successful Compensation Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 32

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Adequacy III Failed Compensation

Roberto Bruni @ IMT Lucca 12 April 2005 Nested Sagas: Adequacy III Failed Compensation Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 33

Roberto Bruni @ IMT Lucca 12 April 2005 Additional Features n Exception handling try

Roberto Bruni @ IMT Lucca 12 April 2005 Additional Features n Exception handling try S with P n Used to catch crashes during backward computation Forward recovery strategies try S or P n Can be used to retry or to improve activities n n n Fully programmable compensations S%P n n Institutions Markets Technologies P is tried when S aborts and is successfully compensated More expressive than default compensation (sub-cmt) Choices: Discriminator P Q Choices: Internal P Q Data dependencies A B IMT n Valid executions must satisfy dependency constraints Models and Languages for Coordination and Orchestration 34

Roberto Bruni @ IMT Lucca 12 April 2005 Sagas vs c. CSP I n

Roberto Bruni @ IMT Lucca 12 April 2005 Sagas vs c. CSP I n Executions of activities n n n Failures n n n IMT raised by primitive THROW in c. CSP raised by activities that fail in Sagas Yielding to interrupt n Institutions Markets Technologies always successful in c. CSP dependent on the context in Sagas n both explicit and implicit in c. CSP only implicit in Sagas Models and Languages for Coordination and Orchestration 35

Roberto Bruni @ IMT Lucca 12 April 2005 Sagas vs c. CSP II n

Roberto Bruni @ IMT Lucca 12 April 2005 Sagas vs c. CSP II n Abnormal termination n n successful compensation and abnormal termination of a transaction block are silent to parent processes in c. CSP but not in Sagas n n Adequacy results n via self-cancelling in c. CSP n n IMT simple and intuitive but imprecise via complex adequacy theorems in Sagas n Institutions Markets Technologies where e. g. try S or P can be introduced more precise but less intuitive, can give more insights Models and Languages for Coordination and Orchestration 36

Roberto Bruni @ IMT Lucca 12 April 2005 Sagas vs c. CSP III n

Roberto Bruni @ IMT Lucca 12 April 2005 Sagas vs c. CSP III n Trace models n n n Compensation policy of parallel processes n n n Institutions Markets Technologies IMT interleaving in c. CSP (centralized) concurrent in Sagas (more distributed) coordinated interruption in c. CSP no interruption but distributed compensation in Sagas naive distributed interruption in Sagas revised Models and Languages for Coordination and Orchestration 37

Roberto Bruni @ IMT Lucca 12 April 2005 n More on Compensation Policies for

Roberto Bruni @ IMT Lucca 12 April 2005 n More on Compensation Policies for Parallel Processes The difference can be nicely illustrated in terms of semantic equivalence n [ A % A° | B % B° | THROWW ] =traces 1. naive Sagas c. CSP revised Sagas Institutions Markets Technologies IMT 2. 3. 4. (A|B) ; (A°|B°) (A; A°) | (B; B°) SKIP + (A; A°) + (B; B°) + (A|B); (A°|B°) SKIP + (A; A°) + (B; B°) + (A; A°)|(B; B°) 1 2 3 4 Models and Languages for Coordination and Orchestration 38

Roberto Bruni @ IMT Lucca 12 April 2005 Implementation Methodology n GOAL: Automatic generation

Roberto Bruni @ IMT Lucca 12 April 2005 Implementation Methodology n GOAL: Automatic generation of the “coordination code” from a description of a composed WS n design as n n n automatic generation of coordination wrappers n Institutions Markets Technologies IMT well-formed flow diagrams or as processes in a suitable language n for invoking involved services in a sound way for managing commitments and compensations Models and Languages for Coordination and Orchestration 39

Roberto Bruni @ IMT Lucca 12 April 2005 JTWS Approach n Java Transactional Web

Roberto Bruni @ IMT Lucca 12 April 2005 JTWS Approach n Java Transactional Web Services (JTWS) n n Institutions Markets Technologies IMT Java Signal Core Layer (JSCL) Java Transactional Layer (JTL) Models and Languages for Coordination and Orchestration 40

Roberto Bruni @ IMT Lucca 12 April 2005 JTWS and JSCL n JTWS tailored

Roberto Bruni @ IMT Lucca 12 April 2005 JTWS and JSCL n JTWS tailored to long running transactions n JTWS is based on n n signal exchanges, publish/subscribe, event notification JSCL gives a minimal set of functionalities for n creation/dismissal of new signal types n n signal emitters / handlers as services describing connections between components n n asynchronous / synchronous typed, peer-to-peer, unidirectional n n Institutions Markets Technologies IMT broadcast and bidirectional just requires additional links management of flow sessions Models and Languages for Coordination and Orchestration 41

Roberto Bruni @ IMT Lucca 12 April 2005 JTL n Specialized kind of JTWS

Roberto Bruni @ IMT Lucca 12 April 2005 JTL n Specialized kind of JTWS component n n n API for (paradigms of) connectors only a minimal subset of signals is considered three signals can encode compensable transactions n n n Institutions Markets Technologies IMT on. Invoke on. Roll. Back on. Commit Models and Languages for Coordination and Orchestration 42

Roberto Bruni @ IMT Lucca 12 April 2005 JTL Transactional Component In Out WS

Roberto Bruni @ IMT Lucca 12 April 2005 JTL Transactional Component In Out WS 1 links are dynamically established depending on the internal state WS 2 o. Rb i. Rb o. Ct i. Ct WS 1 % WS 2 Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 43

Roberto Bruni @ IMT Lucca 12 April 2005 JTL Sequence In Out o. Rb

Roberto Bruni @ IMT Lucca 12 April 2005 JTL Sequence In Out o. Rb i. Rb o. Ct i. Ct JTL 1 ; JTL 2 Institutions Markets Technologies IMT Models and Languages for Coordination and Orchestration 44

Roberto Bruni @ IMT Lucca 12 April 2005 Some Concluding Remarks n c. CSP

Roberto Bruni @ IMT Lucca 12 April 2005 Some Concluding Remarks n c. CSP and Sagas n n Allow to reason about program properties n n n Institutions Markets Technologies IMT abstract away from low-level computations can be easily extended independent from the coordination mechanisms that implement the primitives adequacy process equivalence correctness of implementation Models and Languages for Coordination and Orchestration 45

Roberto Bruni @ IMT Lucca 12 April 2005 References n A trace semantics for

Roberto Bruni @ IMT Lucca 12 April 2005 References n A trace semantics for long-running transactions (Proc. 25 Years of CSP) n n Theoretical foundations for compensations in flow composition languages (Proc. POPL'05) n n R. Bruni, H. Melgratti, U. Montanari Models and languages for global computing transactions (Ph. D Thesis, Univ. of Pisa, 2005) n n M. Butler, C. Ferreira, T. Hoare H. Melgratti Composizionalità di transazioni e Web Services nell'ambito della telefonia mobile (MSc Thesis 2005) n Institutions Markets Technologies IMT D. Strollo Models and Languages for Coordination and Orchestration 46