Calculi for Committed Choices and Compensations Roberto Bruni - Dipartimento di Informatica,...
-
date post
22-Dec-2015 -
Category
Documents
-
view
218 -
download
1
Transcript of Calculi for Committed Choices and Compensations Roberto Bruni - Dipartimento di Informatica,...
Calculi for Committed Choices and Compensations Roberto Bruni - Dipartimento di Informatica, Università di Pisa
joint work with
Gianluigi FerrariHernán MelgrattiUgo MontanariDaniele StrolloEmilio TuostoDip. Informatica, Univ. Pisa
Santa Cruz (CA) USA, 18 January 2005
Calculi for Committed Choices
and Compensations 2
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Motivations Design of business processes
rigorous mathematical foundations clean semantics “expressiveness” well-disciplined service composition modular implementation
Web Service Composition defining complex services as
aggregations of simpler services
Calculi for Committed Choices
and Compensations 3
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Motivations In long lasting negotiations partial
agreements can be reached and locally committed by parties To be compensated in case of failure To be published / confirmed on success
Formal models are needed To discover specification bugs To reason rigorously To run simulations To ease verification
Calculi for Committed Choices
and Compensations 4
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Compensations To Compensate (Merriam-Webster
OnLine) to neutralize the effect of to supply an equivalent to to provide with means of counteracting
variation to offset an error, defect, or undesired effect
The most important fact: Compensations have a cost
Calculi for Committed Choices
and Compensations 5
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Compensations: Examples Late cancelling of hotel reservations can
involve payment of fees Failures on credit checks can cause the abort
of parallel activities (which can be partially completed) e.g. to unpackage the goods to be sent to cancel the courier booking
Statements of politicians typically require an unbounded number of nested compensations
Calculi for Committed Choices
and Compensations 6
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Approaches Flow Composition or Hierarchical
Patterns Similar to workflow systems: a process
describes the flow of both control and data among WS
Interaction based Composition, Conversational Patterns or Global Model Services describe the ways they can be
engaged in a larger process
Calculi for Committed Choices
and Compensations 7
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Flow Composition
A1
A2 A3
A4
A5
Calculi for Committed Choices
and Compensations 8
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Transactional Flows
A1
A2 A3
A4
A5
Calculi for Committed Choices
and Compensations 9
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Compensation
A1
B1
A2
B2
A3
B3 A4
B4
A5
B5
Calculi for Committed Choices
and Compensations 10
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Compensation Flow
A1
B1
A2
B2
A3
B3 A4
B4
A5
B5
Calculi for Committed Choices
and Compensations 11
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Nested Flow Diagrams
A1
B1
A2
B2
A3
B3
PP
A4
B4
Calculi for Committed Choices
and Compensations 12
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Interaction and
Agreements In commercial applications, separately
designed and implemented components must interact avoiding ad-hoc proprietary solutions offering alternatives to centralized
transaction managers hiding the coordination layer (separation
of concerns)
Calculi for Committed Choices
and Compensations 13
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{}
{}
Interacting Transactions
{}
Calculi for Committed Choices
and Compensations 14
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{}
{}
Interacting Transactions
{}
Calculi for Committed Choices
and Compensations 15
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P3}
{P2}
Interacting Transactions
{}
Calculi for Committed Choices
and Compensations 16
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P3}
{P2}
Interacting Transactions
{}
Calculi for Committed Choices
and Compensations 17
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P1,P3}
{P2}
Interacting Transactions
{P2}
Calculi for Committed Choices
and Compensations 18
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Outline of the talk Part I
Transactional Flows with Compensations Part II
A Process Calculus for Distributed Transactions
Part III Prototype Implementations
Calculi for Committed Choices
and Compensations 19
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Outline of the talk Part I
Transactional Flows with Compensations Part II
A Process Calculus for Distributed Transactions
Part III Prototype Implementations
Calculi for Committed Choices
and Compensations 20
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Part I - Flows Sequential Sagas
Graphical representation Syntax Big Step Semantics Adequacy results
Parallel Sagas Nested Sagas Additional features
Calculi for Committed Choices
and Compensations 21
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Flow Diagrams and PDLs Many PDL proposals to describe business
processes unambiguously XML-based
WSFL, XLANG, BPEL4WS, … Extensions of known calculi
committed Join (cJOIN), t-calculus, web-calculus Flow-based
Structured Activity Compensation (StAC) now evolving to compensating CSP
core flow language (FL) for sagas [BMM:POPL2005]
Calculi for Committed Choices
and Compensations 22
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Graphically
Accept OrderRefuse Order
Update CreditRefund Money
Prepare OrderUpdate Stock
Calculi for Committed Choices
and Compensations 23
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Sequential Sagas: Syntax
Accept OrderRefuse Order
Update CreditRefund Money
Prepare OrderUpdate Stock
(Step) X ::= 0 | A | A%B(Process) P ::= X | P;P(Saga) S ::= { P }
Calculi for Committed Choices
and Compensations 24
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Sequential Sagas: Syntax
Accept OrderRefuse Order
Update CreditRefund Money
Prepare OrderUpdate Stock
S = { AO%RO ; UC%RM ; PO%US }
(Step) X ::= 0 | A | A%B(Process) P ::= X | P;P(Saga) S ::= { P }
Calculi for Committed Choices
and Compensations 25
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Semantics
An activity A either commits (A ) aborts (A )
= {A1 ,…, An }
Calculi for Committed Choices
and Compensations 26
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Semantics
A saga S = { P } under either commits ( ) aborts ( ) fails ( )
is the observable flow
S
S
S
*
Calculi for Committed Choices
and Compensations 27
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
A process P under either commits ( ) aborts ( ) fails ( )
aborts = successfully compensated ß, ß’ are the installed compensations
Sequential Sagas: Semantics
<P,ß> < ,ß’>
<P,ß> < , 0>
<P,ß> < , 0>
*
Calculi for Committed Choices
and Compensations 28
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Semantics(saga) <P,0> < , ß>
{P}
Calculi for Committed Choices
and Compensations 29
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Semantics
<0,ß> < , ß>
0(zero)
(saga) <P,0> < , ß>
{P}
Calculi for Committed Choices
and Compensations 30
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Semantics
<0,ß> < , ß>
0(zero)
(saga) <P,0> < , ß>
{P}
A , <A%B, ß> < , B;ß>
A(s-act)
Calculi for Committed Choices
and Compensations 31
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Semantics
A , <A%B, ß> < , B;ß>
A
<0,ß> < , ß>
0
(zero)
(s-act)
(s-cmp)
(saga)
A , <A%B,ß> < , 0>
<ß,0> < , 0>
(f-cmp)A , <A%B,ß> < , 0>
<ß,0> < , 0>
*
<P,0> < , ß>
{P}
Calculi for Committed Choices
and Compensations 32
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Semantics
(s-step) <Q,ß’’> < ,ß’>
’ <P,ß> < ,ß’’>
<P;Q, ß> < ,ß’>
;’
(a-step’) <P;Q,ß> < ,0>
<P,ß> < , 0>
(a-step’’) <P,ß> < , 0>
<P;Q,ß> < ,0>
*
*
Calculi for Committed Choices
and Compensations 33
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Adequacy S
and = A1;…;An
A1 Aj Ak An
Calculi for Committed Choices
and Compensations 34
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Adequacy S
and = A1;…;An
S
and = A1;…;Ak-1;Bk-1;…;B1
A1 Aj Ak An
A1 Aj Ak An
BjB1
Calculi for Committed Choices
and Compensations 35
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Sequential Sagas:
Adequacy S
and = A1;…;An
S
and = A1;…;Ak-1;Bk-1;…;B1
S
and = A1;…;Ak-1;Bk-1;…;Bj+1
A1 Aj Ak An
A1 Aj Ak An
BjB1
A1 Aj Ak An
BjB1
*
Calculi for Committed Choices
and Compensations 36
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: Syntax
Accept OrderRefuse Order
Update CreditRefund Money
Prepare OrderUpdate Stock
Calculi for Committed Choices
and Compensations 37
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: Syntax
(Step) X ::= 0 | A | A%B(Process) P ::= X | P;P | P|P(Saga) S ::= { P }
Accept OrderRefuse Order
Update CreditRefund Money
Prepare OrderUpdate Stock
Calculi for Committed Choices
and Compensations 38
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: Syntax
S = { AO%RO ; UC%RM | PO%US }
(Step) X ::= 0 | A | A%B(Process) P ::= X | P;P | P|P(Saga) S ::= { P }
Accept OrderRefuse Order
Update CreditRefund Money
Prepare OrderUpdate Stock
Calculi for Committed Choices
and Compensations 39
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: NaïvelyB1 Bj Bn
C1 Ck Cm
A1 A2
B’1 B’j
A’1
C’1 C’k C’m
A1;(B1;…;Bj-1;B’j-1;…;B’1 | C1;…Cm;C’m;…;C’1);A’1
Calculi for Committed Choices
and Compensations 40
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: Revised
A1;(B1;…;Bj-1;B’j-1;…;B’1 | 0);A’1
A1;(B1;…;Bj-1;B’j-1;…;B’1 | C1;C’1);A’1
…
A1;(B1;…;Bj-1;B’j-1;…;B’1 | C1;…Cm;C’m;…;C’1);A’1
B1 Bj Bn
C1 Ck Cm
A1 A2
B’1 B’j
A’1
C’1 C’k C’m
Calculi for Committed Choices
and Compensations 41
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
<P,ß> < , 0>
A process P under either commits ( ) aborts ( ) fails ( ) is forced to abort ( ) is forced to fail ( )
is the observable concurrent flow
<P,ß> < , 0>
<P,ß> < , 0>
<P,ß> < , 0>
Parallel Sagas: Semantics
<P,ß> < ,ß’>
*
*
Calculi for Committed Choices
and Compensations 42
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: Semantics
(saga)
(forced-abt’) <P,ß> < ,0>
<ß, 0> < , 0>
(forced-abt’’) <P,ß> < ,0>
<ß, 0> < , 0>
*
{ , , } * <P,0> <, ß>
{P}
Calculi for Committed Choices
and Compensations 43
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
<P,0> < ,ß’>
Parallel Sagas: Semantics
(s-par) <Q,0> < ,ß’’>
’
<P|Q, ß> < ,ß’|ß’’; ß>
|’
Calculi for Committed Choices
and Compensations 44
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: Semantics
<Q,0> <2,0>
’ <P,0> <1,0>
<P|Q, ß> < 1 2 , 0>
|’;
(c-par’)
<ß,0> < ,0>
1, 2 { , }
*
*
* *
***** * *
Calculi for Committed Choices
and Compensations 45
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: Semantics(c-par’’)
*
*
* *
***** * *
<Q,0> <2,0>
’ <P,0> <1,0>
<P|Q, ß> < 1 2 , 0>
|’;
<ß,0> < ,0>
1, 2 { , }
*
Calculi for Committed Choices
and Compensations 46
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: Semantics
<Q,0> <2 ,0>
’ <P,0> <1,0>
<P|Q, ß> < 1 2 , 0>
|’
(f-par)
1 { , }
2 { , , , }
**
**
*
*
* *
***** * *
Calculi for Committed Choices
and Compensations 47
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: AdequacyCompletion
Calculi for Committed Choices
and Compensations 48
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: AdequacySuccessful Compensation
Calculi for Committed Choices
and Compensations 49
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Parallel Sagas: AdequacyFailed Compensation
Calculi for Committed Choices
and Compensations 50
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Nested Sagas: Graphically
Accept OrderRefuse Order
Update CreditRefund Money
Prepare OrderUpdate Stock
Add Points
Subtract Points
Calculi for Committed Choices
and Compensations 51
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Nested Sagas: Syntax
(Step) X ::= 0 | A | A%B | S (Process) P ::= X | P;P | P|P(Saga) S ::= { P }
Calculi for Committed Choices
and Compensations 52
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Nested Sagas: Syntax
S { AO%RO ; UC%RM | PO%US | {AP%SP} }
Accept OrderRefuse Order
Update CreditRefund Money
Prepare OrderUpdate Stock
Add Points
Subtract Points
Calculi for Committed Choices
and Compensations 53
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Nested Sagas: Semantics
(sub-cmt) <P,0> < , ß’>
<{P},ß> < , ß’;ß>
(sub-abt) <P,0> < , 0>
<{P},ß> < , ß>
(sub-fail) <P,0> < , 0>
<{P},ß> < , 0>
ß’ acts as default compensation
*
*
Calculi for Committed Choices
and Compensations 54
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Nested Sagas: Semantics
(sub-forced-1)
(sub-forced-2’)
<P,0> < , 0>
*
<{P},ß> < , 0> *
(sub-forced-2’’)
{ , } *
<ß,0> <,0>
<P,0> < ,0>
<{P}, ß> < ,0>
;*
<ß,0> < ,0>
<P,0> < ,0>
<{P}, ß> < ,0>
;
Calculi for Committed Choices
and Compensations 55
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Nested Sagas: Adequacy
Completion
Calculi for Committed Choices
and Compensations 56
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Nested Sagas: Adequacy
Successful Compensation
Calculi for Committed Choices
and Compensations 57
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Failed Compensation
Nested Sagas: Adequacy
Calculi for Committed Choices
and Compensations 58
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
More on Sagas Exception handling try S with P
Used to catch crashes during backward computation Forward recovery strategies try S or P
Can be used to retry or to improve activities Fully programmable compensations S%P
More expressive than default compensation (sub-cmt) Allowed by languages like BPEL4WS
Choices: Discriminator PQ Choices: Internal PQ Data dependencies AB
Valid executions must satisfy dependency constraints
Calculi for Committed Choices
and Compensations 59
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Outline of the talk Part I
Transactional Flows with Compensations Part II
A Process Calculus for Distributed Transactions
Part III Prototype Implementations
Calculi for Committed Choices
and Compensations 60
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Part II - cJoin Distributed Negotiations CHAM and JOIN cJOIN
Calculi for Committed Choices
and Compensations 61
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Distributed Negotiations Negotiations / Contracts
commit, abort, compensation hierarchical decisions dynamic membership fully distributed control
Process cooperation coordination / orchestration / choreography different platforms and policies
Calculi for Committed Choices
and Compensations 62
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Our Proposal: cJOIN committed JOIN
Process Description Language presentation Non ACID (unrealistic in highly distributed
systems) Multiway (several parties can start separately
but commit on reached agreement) Programmable abort / non-perfect compensation Concurrency and distribution (Distributed 2PC) Different levels of abstraction (serializability)
Calculi for Committed Choices
and Compensations 63
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Why JOIN? Well-known asynchronous calculus process calculus presentation
few constructs, based on rendez-vous (atomic non-local interactions)
basis for distributed programming language
Calculi for Committed Choices
and Compensations 64
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Why JOIN? Extends a higher-order functional
language parallelism in expressions (fork calls) parallelism in function patterns (join patterns)
Distributed implementations JoCaml ( http://join.inria.fr ) Polyphonic C#
Calculi for Committed Choices
and Compensations 65
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Based on an elementary model of concurrency the reflexive chemical abstract machine = generic
CHAM + imposing locality + adding reflection locality: only linear reaction patterns allowed
each molecule or reaction rule is associated to a single reaction site
reflection: reactions can generate new kinds of molecules together with their defining reaction rules
Why JOIN?
Calculi for Committed Choices
and Compensations 66
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 Chemical Abstract
Machine States are called solutions s
Multisets of molecules m1,…,mn data and rules (reflexive CHAM)
Hierarchical structure via membranes Group solutions into molecules e.g. { s1 , { s2 } , { s3, { s4 } } }
multisetunion
Evolution (chemical rules) Heating / cooling (reversible)
Structural equivalence Reactions
Transitions Concurrency
Calculi for Committed Choices
and Compensations 67
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
JOIN Calculus in One Slide Syntax
P,Q ::= 0 | xŷ | def D in P | P|QD,E ::= J P | DEJ,K ::= xŷ | J|K
Operational semantics (CHAM Style)0 P|Q P,QDE D,E
def D in P Ddn(D) , Pdn(D) (range dn(D) “globally fresh”)
J P, J J P, P
heating and cooling
reaction
processesdefinition
s
patternsresembles funct. prog.
let f(x)=E in F (same scoping
discipline)
Calculi for Committed Choices
and Compensations 68
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Join calculus vs. calculus Join is essentially with restrictions on
communication patterns Join combines restriction, reception and
replication in a single receptor definition: they are not available separately
Asynchrony forces us to create and send continuations in join
Nevertheless, join and asynchronous have the same expressive power demonstrated by fully abstract encoding in
each direction up to weak barbed congruence
Calculi for Committed Choices
and Compensations 69
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Example: Cell Abstraction
getk | sv kv | sv
A cell s contains the value v To get the value:
send a message on port get the parameter k is the return address, where
the value v will be sent to
Calculi for Committed Choices
and Compensations 70
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Example: Cell Abstraction
getk | sv kv | sv
A cell s contains the value v To set the value:
send a message on port set the parameter m is the new value for s k is the return address (for confirmation)
setm,k | sv k | sm
Calculi for Committed Choices
and Compensations 71
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Example: Cell Abstraction
getk | sv kv | sv
The initial value in s is n But get, set and s are locally bound by def
get and set must be extruded, otherwise no one can use them
instead, s can be kept private
setm,k | sv k | sm
def in sn
Calculi for Committed Choices
and Compensations 72
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Example: Cell Abstraction
getk | sv kv | sv
get, set are extruded on public channel c
But c should be known only by the owner of the cell…
setm,k | sv k | sm
def in sn | cget,set
Calculi for Committed Choices
and Compensations 73
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Example: Cell Abstraction
getk | sv kv | sv
A message to create triggers the outermost def: Three fresh names for s, get and set are allocated
the initial value of s is the first parameter n get and set are sent back to the second argument c instead s will never be extruded
Invariant in every configuration there is exactly one message on s
setm,k | sv k | sm
def in sn | cget,set
def createn,c
in …
Calculi for Committed Choices
and Compensations 74
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Committed JOIN Syntax
M,N::= 0 | xŷ | M|NP,Q ::= M | def D in P | P|Q | abort |
[P:Q]D,E ::= JP | DE | JP J,K ::= xŷ | J|K
messages
programmable abort
compensation
contract
boundaries
merge definitions (boards):
defined boards must be disjoint from ordinary
defined names
Calculi for Committed Choices
and Compensations 75
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Committed JOIN Semantics0
P|Q P,Q
DE D,E
def D in P Ddn(D) , Pdn(D) range() fresh
J P, J J P, P
Calculi for Committed Choices
and Compensations 76
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Committed JOIN Semantics0
P|Q P,Q
DE D,E
def D in P Ddn(D) , Pdn(D) range() fresh
J P, J J P, P
[P:Q] { P , Q }
compensation is kept frozen
contract P can evolve in isolation
Calculi for Committed Choices
and Compensations 77
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Committed JOIN Semantics0
P|Q P,Q
DE D,E
def D in P Ddn(D) , Pdn(D) range() fresh
J P, J J P, P
[P:Q] { P , Q }
{ M|def D in 0 , Q } M
commitglobal resources
Calculi for Committed Choices
and Compensations 78
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Committed JOIN Semantics0
P|Q P,Q
DE D,E
def D in P Ddn(D) , Pdn(D) range() fresh
J P, J J P, P
[P:Q] { P , Q }
{ M|def D in 0 , Q } M
{ abort |P , Q } Qcompensation on abort
Calculi for Committed Choices
and Compensations 79
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Committed JOIN Semantics0
P|Q P,Q
DE D,E
def D in P Ddn(D) , Pdn(D) range() fresh
J P, J J P, P
[P:Q] { P , Q }
{ M|def D in 0 , Q } M
{ abort |P , Q } Q
J1|…|JnP, i{ Ji, Si, Qi } J1|…|JnP, {P, iSi, iQi }
merge n ongoing contracts
Calculi for Committed Choices
and Compensations 80
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
JOIN vs cJOIN
PROPOSITIONcJOIN is a conservative extension of
JOIN:P J Q iff P
cJ Q (for P and Q JOIN
processes)
Calculi for Committed Choices
and Compensations 81
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Hotel Booking
H def WaitBooking [ def requesto o$ | price$ price$ | confirmv BookedRoomv price$ abort in offeringRoom request,confirm : Q ]
BookedRoomv … in WaitBooking | …
Calculi for Committed Choices
and Compensations 82
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Hotel Booking
H def WaitBooking [ def requesto o$ | price$ price$ | confirmv BookedRoomv price$ abort in offeringRoom request,confirm : Q ]
BookedRoomv … in WaitBooking | …
C def BookingHotel [def hotelMsg r,c def offer$ cvisa | HotelFound
offer$ abort in rofferin searchRoom hotelMsg : Q’ ]
in BookingHotel | …
Calculi for Committed Choices
and Compensations 83
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Hotel Booking
H def WaitBooking [ def requesto o$ | price$ price$ | confirmv BookedRoomv price$ abort in offeringRoom request,confirm : Q ]
BookedRoomv … in WaitBooking | …
C def BookingHotel [def hotelMsg r,c def offer$ cvisa | HotelFound
offer$ abort in rofferin searchRoom hotelMsg : Q’ ]
in BookingHotel | …
HB def searchRoom hm | offeringRoom r,c hmr,c in H | C
Calculi for Committed Choices
and Compensations 84
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Hotel Booking…, WaitBooking , BookingHotel
…, […, offeringRoomrequest,confirm : Q ] , […, searchRoomhotelMsg : Q’]
…, […, hotelMsgrequest,confirm : Q | Q’]
…, […, requestoffer : Q | Q’]
…, […, offer$, price$ : Q | Q’]
…, […, confirmvisa, HotelFound , price$ : Q | Q’]
…, […, BookedRoomvisa, HotelFound : Q | Q’]
…, BookedRoomvisa, HotelFound
Calculi for Committed Choices
and Compensations 85
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Trip Booking IH as before
F def WaitBooking [ def requesto o$ | price$ price$ | confirmv BookedFlightv price$ abort in offeringFlight request,confirm : Q ]
BookedFlightv … in WaitBooking | …
local name, different from homonym name
in H
Calculi for Committed Choices
and Compensations 86
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Trip Booking IIC def hotelOKfc | flightOKhc fc | hc BookingHotel [def hotelMsgr,c def offer$ cvisa | hotelOKflightConf
offer$ abort flightConf HotelFound in rofferin searchRoom hotelMsg : Q’ ]
BookingFlight [def flightlMsgr,c def offer$ cvisa | flightOKhotelConf
offer$ abort hotelConf FlightFound in rofferin searchFlight flightMsg : Q’’ ]
in BookingHotel | BookingFlight | …
TB def searchRoomhm | offeringRoom r,c hmr,c searchFlightfm | offeringFlight r,c fmr,c in H | F | C
both needed to commit
Calculi for Committed Choices
and Compensations 87
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Something About cJOIN A simple type system guarantees
serializability for Shallow processes Proof via correspondence w.r.t. big step semantics
Commit primitives of cJOIN can be used to implement committed choices of AKL explicit encoding of search strategies and
unification via continuation passing and compensation
Zero-safe nets can also be straightforwardly encoded as cJOIN processes
Calculi for Committed Choices
and Compensations 88
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Outline of the talk Part I
Transactional Flows with Compensations Part II
A Process Calculus for Distributed Transactions
Part III Prototype Implementations
Calculi for Committed Choices
and Compensations 89
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Java Transactional Web Services (JTWS) Java Signal Core Layer (JSCL) Java Transactional Layer (JTL)
cJOIN compiler D2PC
Part III - Implementation
Calculi for Committed Choices
and Compensations 90
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
JTWS Methodology GOAL: Automatic generation of the
“coordination code” from a description of a composed WS design as
well-formed flow diagrams or as processes in a suitable language
automatic generation of coordination wrappers
for invoking involved services in a sound way for managing commitments and compensations
Calculi for Committed Choices
and Compensations 91
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
JTWS and JSCL JTWS tailored to long running transactions
JTWS is based on signal exchanges, publish/subscribe, event notification
JSCL gives a minimal set of functionalities for creation/dismissal of new signal types
signal emitters / handlers as services describing connections between components
asynchronous / synchronous typed, peer-to-peer, unidirectional
broadcast and bidirectional just requires additional links management of flow sessions
Calculi for Committed Choices
and Compensations 92
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
JTL Specialized kind of JTWS component
API for (paradigms of) connectors only a minimal subset of signals is
considered three signals can encode compensable
transactions onInvoke onRollBack onCommit
Calculi for Committed Choices
and Compensations 93
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
JTL Component Wrappers
WSiRb
In
iCt
Out
oRb
oCt
Calculi for Committed Choices
and Compensations 94
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 JTL Transactional
Component
WS1
iRb
In
iCt
Out
oRb
oCt
WS2
WS1 % WS2
links are dynamicallyestablished depending on the internal state
Calculi for Committed Choices
and Compensations 95
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
JTL Sequence
In Out
iRb
iCt
oRb
oCt
JTL1 ; JTL2
Calculi for Committed Choices
and Compensations 96
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 JTL Transactional
Sequence
In Out
offer the method addInternalComponent
{ JTL1 ; JTL2 }
Calculi for Committed Choices
and Compensations 97
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005 JTL Trans. Parallel
Component
In Out
offer the method addInternalComponent
{ JTL1 | JTL2 }
Calculi for Committed Choices
and Compensations 98
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Encoding of cJOIN in JOIN Aim:
Define an implementation of cJOIN in JOIN Associate to every cJOIN process a JOIN
process that simulate its behavior
Ideas: Identification of basic forms for definitions Definition of a type system to single out
canonical processes Reuse controllers of the D2PC protocol
Calculi for Committed Choices
and Compensations 99
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Distributed 2PC (D2PC) The Distributed 2PC is a variant of the
decentralized 2PC When a participant P is ready to commit it has
only a partial knowledge of the whole set of participants
Only those who directly cooperated with P To commit P must contact all its neighbors and
learn the identity of other participants from them The D2PC can be conveniently written in
Jocaml
Calculi for Committed Choices
and Compensations 100
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
D2PC Every participant P acts as coordinator
During the transaction P builds its own synchronization set LP of cooperating agents
When P is ready to commit, P asks readiness to processes in LP (if empty P was isolated and can commit)
In doing so, P sends them the set LP
Other participants will send to P either a successful reply with their own synchronization sets or a failure message
(in this case, failure is then propagated) Successful replies are added to LP
The protocol terminates when LP is transitively closed
Calculi for Committed Choices
and Compensations 101
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
Example: D2PC
Calculi for Committed Choices
and Compensations 102
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{}
Example: D2PC
Calculi for Committed Choices
and Compensations 103
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{}
{}
Example: D2PC
Calculi for Committed Choices
and Compensations 104
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{}
{}
Example: D2PC
{}
Calculi for Committed Choices
and Compensations 105
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{}
{}
Example: D2PC
{}
Calculi for Committed Choices
and Compensations 106
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P3}
{P2}
Example: D2PC
{}
Calculi for Committed Choices
and Compensations 107
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P3}
{P2}
Example: D2PC
{}
Calculi for Committed Choices
and Compensations 108
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P1,P3}
{P2}
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 109
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P1,P3}
{P2}
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 110
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P1,P3}
{P2} [P2] ()
<P3,{P2}>
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 111
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P1,P3}
<P3,{P2}>
{P2} [P2] ()
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 112
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P1,P3} [P1,P3] ()
<P3,{P2}>
{P2} [P2] ()
<P2,{P1,P3}><P2,{P1,P3}>
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 113
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
<P3,{P2}>
{P2} [P2] ()
<P2,{P1,P3}>
<P2,{P1,P3}>
{P1,P3} [P1,P3] ()
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 114
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P2} [P2] ()
<P2,{P1,P3}>
<P2,{P1,P3}>
{P1,P3} [P1,P3] (P3)
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 115
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P1,P2} [P2] (P2)
<P2,{P1,P3}>
{P1,P3} [P1,P3] (P3)
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 116
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P1,P2} [P1,P2] (P2)
<P2,{P1,P3}>
{P1,P3} [P1,P3] (P3)
<P3,{P1,P2}>
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 117
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P1,P2} [P1,P2] (P2)
<P2,{P1,P3}>
{P1,P3} [P1,P3] (P3)
<P3,{P1,P2}>
Example: D2PC
{P2}
Calculi for Committed Choices
and Compensations 118
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P2} [P2] ()
{P1,P2} [P1,P2] (P2)
<P2,{P1,P3}>
{P1,P3} [P1,P3] (P3)
<P3,{P1,P2}>
<P1,{P2}>
Example: D2PC
Calculi for Committed Choices
and Compensations 119
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P2} [P2] ()
{P1,P2} [P1,P2] (P2)
<P2,{P1,P3}>
{P1,P3} [P1,P3] (P3)
<P3,{P1,P2}>
<P1,{P2}>
Example: D2PC
Calculi for Committed Choices
and Compensations 120
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
P2
P3
{P2} [P2] ()
{P1,P2} [P1,P2] (P2)
<P2,{P1,P3}>
{P1,P3} [P1,P3] (P1,P3)
<P3,{P1,P2}>
Example: D2PC
Calculi for Committed Choices
and Compensations 121
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
Q2
P3
{P2} [P2] ()
{P1,P2} [P1,P2] (P2)
<P2,{P1,P3}>
{P1,P3} [P1,P3] (P1,P3)
<P3,{P1,P2}>
Example: D2PC
Calculi for Committed Choices
and Compensations 122
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
Q2
P3
{P2,P3} [P2] (P2)
{P1,P2} [P1,P2] (P2)
{P1,P3} [P1,P3] (P1,P3)
<P3,{P1,P2}>
Example: D2PC
Calculi for Committed Choices
and Compensations 123
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
Q2
P3
{P2,P3} [P2] (P2)
{P1,P2} [P1,P2] (P2)
{P1,P3} [P1,P3] (P1,P3)
<P3,{P1,P2}>
<P1,{P2,P3}>
Example: D2PC
Calculi for Committed Choices
and Compensations 124
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
Q2
P3
{P2,P3} [P2] (P2)
{P1,P2} [P1,P2] (P2)
{P1,P3} [P1,P3] (P1,P3)
<P3,{P1,P2}>
<P1,{P2,P3}>
Example: D2PC
Calculi for Committed Choices
and Compensations 125
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
Q2
P3
{P2,P3} [P2 ,P3] (P2 ,P3)
{P1,P2} [P1,P2] (P2)
{P1,P3} [P1,P3] (P1,P3)
<P1,{P2,P3}>
Example: D2PC
Calculi for Committed Choices
and Compensations 126
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
P1
Q2
P3
{P2,P3} [P2 ,P3] (P2 ,P3)
{P1,P2} [P1,P2] (P1,P2)
{P1,P3} [P1,P3] (P1,P3)
Example: D2PC
Calculi for Committed Choices
and Compensations 127
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Q1
Q2
Q3
{P2,P3} [P2 ,P3] (P2 ,P3)
{P1,P2} [P1,P2] (P1,P2)
{P1,P3} [P1,P3] (P1,P3)
Example: D2PC
Calculi for Committed Choices
and Compensations 128
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Final Remarks I Our definition for compensable flow
languages abstracts away from low-level computations can be easily extended independent from the coordination mechanisms
that implement the primitives Java Transactional Web Services (JTWS)
Distributed implementation of flows Allows to reason about program properties
Adequacy Correctness of implementation
Calculi for Committed Choices
and Compensations 129
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Final Remarks II cJOIN models multi-way transactions
by describing interacting agents but not their global structure
Shallow cJOIN is serializable cJOIN primitives are implementable in
a distributed way at least the subcalculus of flat processes D2PC protocol is used
Calculi for Committed Choices
and Compensations 130
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
Some Pointers R. Bruni, C. Laneve, U. Montanari
CONCUR 2002 (D2PC) R. Bruni, H. Melgratti, U. Montanari
POPL 2005 (Flows) IFIP TCS 2004 + COMETA 2003 (cJOIN)
Hernán Melgratti PhD Thesis submitted (Flows, cJOIN and more)
Daniele Strollo Master Thesis in preparation (JTWS)
Calculi for Committed Choices
and Compensations 131
Roberto Bruni @ Santa Cruz (CA) USA 18 Jan. 2005
JOIN: An Example A process P
P zx,z | def xy zy,x in xv
P as a solution { zx,z , wy zy,w , wv }
A reaction { zx,z , wy zy,w , wv }
{ zx,z , wy zy,w , zv,w }
bound name
extrusion
defined name
received name
free name
-conversion