Download presentation
Presentation is loading. Please wait.
1
Hernán Melgratti joint work with Roberto Bruni and Ugo Montanari Dipartimento di Informatica - Università di Pisa Flat Committed Join in Join
2
Workshop Finale Cometa – Dec, 2003 Committed Join (cJoin) Join + primitives for negotiations Syntax: P,Q ::= 0 | x ŷ | def D in P | P|Q D,E ::= J P | D E J,K ::= x ŷ | J|K Processes Definitions Patterns
3
Workshop Finale Cometa – Dec, 2003 Committed Join (cJoin) Join + primitives for negotiations Syntax: M,N ::= 0 | x ŷ | M|N P,Q ::= 0 | x ŷ | def D in P | P|Q D,E ::= J P | D E J,K ::= x ŷ | J|K Processes Definitions Patterns Messages
4
Workshop Finale Cometa – Dec, 2003 Committed Join (cJoin) Join + primitives for negotiations Syntax: M,N ::= 0 | x ŷ | M|N P,Q ::= M | def D in P | P|Q D,E ::= J P | D E J,K ::= x ŷ | J|K Processes Definitions Patterns Messages
5
Workshop Finale Cometa – Dec, 2003 Committed Join (cJoin) Join + primitives for negotiations Syntax: M,N ::= 0 | x ŷ | M|N P,Q ::= M | def D in P | P|Q | abort | [P:Q] D,E ::= J P | D E | J P J,K ::= x ŷ | J|K Processes Definitions Patterns Programmable abort Negotiation Compensation Merge definition Messages
6
Workshop Finale Cometa – Dec, 2003 Committed Join (cJoin) Operational Semantics (CHAM Style): 0 P|Q P,Q DEDE D,E def D in P D dn(D), P dn(D) range( ) fresh J P, J J P, P heating and cooling reaction
7
Workshop Finale Cometa – Dec, 2003 Committed Join (cJoin) Operational Semantics (CHAM Style): 0 P|Q P,Q DEDE D,E def D in P D dn(D), P dn(D) range( ) fresh J P, J J P, P [P:Q] {[ P, Q ]} Contract P evolves in isolation Compensation Q is kept frozen
8
Workshop Finale Cometa – Dec, 2003 Committed Join (cJoin) Operational Semantics (CHAM Style): 0 P|Q P,Q DEDE D,E def D in P D dn(D), P dn(D) range( ) fresh J P, J J P, P [P:Q] {[ P, Q ]} {[ M|def D in 0, Q ]} M Global Resources Commit
9
Workshop Finale Cometa – Dec, 2003 Committed Join (cJoin) Operational Semantics (CHAM Style): 0 P|Q P,Q DEDE D,E def D in P D dn(D), P dn(D) range( ) fresh J P, J J P, P [P:Q] {[ P, Q ]} {[ M|def D in 0, Q ]} M {[ abort |P, Q ]} Q Compensation on Abort
10
Workshop Finale Cometa – Dec, 2003 Committed Join (cJoin) Operational Semantics (CHAM Style): 0 P|Q P,Q DEDE D,E def D in P D dn(D), P dn(D) range( ) fresh J P, J J P, P [P:Q] {[ P, Q ]} {[ M|def D in 0, Q ]} M {[ abort |P, Q ]} Q J 1 |…|J n P, i {[ J i , S i, Q i ]} J 1 |…|J n P, {[ i S i, P , i Q i ]} Merge n ongoing contracts
11
Workshop Finale Cometa – Dec, 2003 Example: Mailing List ML MailingList k MLDef
12
Workshop Finale Cometa – Dec, 2003 Example: Mailing List ML MailingList k MLDef MLDef def … in k add, tell, close | lst nil
13
Workshop Finale Cometa – Dec, 2003 Example: Mailing List ML MailingList k MLDef MLDef def … lst y | add x … lst y | tell v … lst y | close … in k add, tell, close | lst nil
14
Workshop Finale Cometa – Dec, 2003 Example: Mailing List ML MailingList k MLDef MLDef def … lst y | add x def z v,w x v | y v,w in lst z lst y | tell v … lst y | close … in k add, tell, close | lst nil
15
Workshop Finale Cometa – Dec, 2003 Example: Mailing List ML MailingList k MLDef MLDef def … lst y | add x def z v,w x v | y v,w in lst z lst y | tell v [def w 0 in y v,w | lst y : lst y ] lst y | close … in k add, tell, close | lst nil
16
Workshop Finale Cometa – Dec, 2003 Example: Mailing List ML MailingList k MLDef MLDef def nil v, w 0 lst y | add x def z v,w x v | y v,w in lst z lst y | tell v [def w 0 in y v,w | lst y : lst y ] lst y | close … in k add, tell, close | lst nil
17
Workshop Finale Cometa – Dec, 2003 Example: Mailing List ML MailingList k MLDef MLDef def nil v, w 0 lst y | add x def z v,w x v | y v,w in lst z lst y | tell v [def w 0 in y v,w | lst y : lst y ] lst y | close 0 in k add, tell, close | lst nil
18
Workshop Finale Cometa – Dec, 2003 Implementing flat cJoin Goal To implement cJoin in Join Key Points Distributed commit of interacting negotiations as a global decision Participants can join dynamically (participants statically unknown) First step Consider flat negotiations Use canonical form of processes Encode canonical flat cJoin processes as Join processes
19
Workshop Finale Cometa – Dec, 2003 Flat cJoin Negotiations cannot be nested Type system for cJoin Processes: P: 0, P does not contain [_:_] at all P: 1, P may contain [_:_] in the definitions P: 2, P may have and generate flat negotiations Join Processes have type 0 Subject Reduction holds for 0 and 2 Flat cJoin: The sub-calculus of all P: 2
20
Workshop Finale Cometa – Dec, 2003 Canonical Flat cJoin Inspired by the basic shapes of ZS nets Few elementary definition patterns Any flat process can be written in canonical form Open xŷ Pxŷ P & P: 2 & count(P) = 1 Ord-Mov xŷ Pxŷ P & P: 1 & count(P) 2 Merge-Mov xŷ Pxŷ P & P: 0 & count(P) 2 Ord-Join x ŷ 1 | x ŷ 2 P & P: 1 & count(P) = 1 Merge-Join x ŷ 1 |…|x ŷ n P & P: 0 & count(P) = 1
21
Workshop Finale Cometa – Dec, 2003 Has type 2 Has count = 2 Canonical Form: Example def nil v, w 0 lst y | add x def z v,w x v | y v,w in lst z lst y | tell v [def w 0 in y v,w | lst y : lst y ] lst y | close 0 in k add, tell, close | lst nil lst y | tell x a y,x a y,x [def w 0 in y v,w | lst y : lst y ] a y,x [def w 0 in def b v,w,l,y y v,w | l y in b v,w,lst,y : lst y ]
22
Workshop Finale Cometa – Dec, 2003 Encoding: Main Idea Any message in a negotiation runs in a thread, which is managed by a coordinator Coordinators perform a D2PC protocol [BLM2002]. A variant of the decentralized 2PC with a finite but unknown number of participants 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
23
Workshop Finale Cometa – Dec, 2003 Encoding: D2PC Every participant P acts as coordinator During the transaction P builds its own synchronization set L P of cooperating agents When P is ready to commit, P asks readiness to processes in L P (if empty P was isolated and can commit) In doing so, P sends them the set L P 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 L P The protocol terminates when L P is transitively closed
24
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0]
25
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] A negotiation with one thread
26
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] def D A negotiation with one thread A coordinator D to manage z put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation
27
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] def D put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation Compensation
28
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] def D cmp 0 in state {cmp} put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation Compensation Set initial compensation
29
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] def D cmp 0 in state {cmp} put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation z runs in a managed thread
30
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] def D cmp 0 in state {cmp} | | def … p l, , in z put, abt, {lock} put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation z carries the ports of its coordinator z runs in a managed thread
31
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] def D cmp 0 in state {cmp} | | def … in z put, abt, {lock} put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation It consumes managed msgs
32
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] def D cmp 0 in state {cmp} | | def z p, a, l … in z put, abt, {lock} put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation It consumes managed msgs z carries the ports of its coordinator
33
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] def D cmp 0 in state {cmp} | | def z p, a, l … in z put, abt, {lock} put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation The thread ends
34
Workshop Finale Cometa – Dec, 2003 Encoding a negotiation [def z 0 in z : 0] def D cmp 0 in state {cmp} | | def z p, a, l p l, , in z put, abt, {lock} put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation The thread ends D can commit
35
Workshop Finale Cometa – Dec, 2003 Encoding an abort [def z abort in z : 0] def D cmp 0 in state {cmp} | | def z p, a, l … in z put, abt, {lock} put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation The thread aborts
36
Workshop Finale Cometa – Dec, 2003 Encoding an abort [def z abort in z : 0] def D cmp 0 in state {cmp} | | def z p, a, l a in z put, abt, {lock} put : to notify thread completion abt: to notify thread abortion lock: to receive partners’ confirmations state: to set the initial compensation The thread aborts D aborts
37
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x y |z
38
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x p,a,l def D 1 D 2 x y |z
39
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x p,a,l def D 1 D 2 in y put 1, abt 1, l {lock 1,lock 2 } | z put 2, abt 2, l {lock 1,lock 2 } x y |z
40
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x p,a,l def D 1 D 2 in y put 1, abt 1, l {lock 1,lock 2 } | z put 2, abt 2, l {lock 1,lock 2 } | p l {lock 1,lock 2 }, {abt 1,abt 2 }, x y |z
41
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x p,a,l def D 1 D 2 in y put 1, abt 1, l {lock 1,lock 2 } | z put 2, abt 2, l {lock 1,lock 2 } | p l {lock 1,lock 2 }, {abt 1,abt 2 }, | state 1 {a,abt 2 } | state 2 {a,abt 1 } x y |z
42
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x p,a,l def D 1 D 2 in y put 1, abt 1, l {lock 1,lock 2 } | z put 2, abt 2, l {lock 1,lock 2 } | p l {lock 1,lock 2 }, {abt 1,abt 2 }, | state 1 {a,abt 2 } | state 2 {a,abt 1 } x y |z x |y z
43
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x p,a,l def D 1 D 2 in y put 1, abt 1, l {lock 1,lock 2 } | z put 2, abt 2, l {lock 1,lock 2 } | p l {lock 1,lock 2 }, {abt 1,abt 2 }, | state 1 {a,abt 2 } | state 2 {a,abt 1 } x y |z y p 2,a 2,l 2 def D x |y z x p 1,a 1,l 1 |
44
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x p,a,l def D 1 D 2 in y put 1, abt 1, l {lock 1,lock 2 } | z put 2, abt 2, l {lock 1,lock 2 } | p l {lock 1,lock 2 }, {abt 1,abt 2 }, | state 1 {a,abt 2 } | state 2 {a,abt 1 } x y |z y p 2,a 2,l 2 def D in z put, abt 1, l 1 l 2 {lock} x |y z x p 1,a 1,l 1 |
45
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x p,a,l def D 1 D 2 in y put 1, abt 1, l {lock 1,lock 2 } | z put 2, abt 2, l {lock 1,lock 2 } | p l {lock 1,lock 2 }, {abt 1,abt 2 }, | state 1 {a,abt 2 } | state 2 {a,abt 1 } x y |z y p 2,a 2,l 2 def D in z put, abt 1, l 1 l 2 {lock} | p 1 l 1 l 2 {lock}, {abt,a 2 }, | p 2 l 1 l 2 {lock}, {abt,a 1 }, x |y z x p 1,a 1,l 1 |
46
Workshop Finale Cometa – Dec, 2003 Encoding: Fork and Join x p,a,l def D 1 D 2 in y put 1, abt 1, l {lock 1,lock 2 } | z put 2, abt 2, l {lock 1,lock 2 } | p l {lock 1,lock 2 }, {abt 1,abt 2 }, | state 1 {a,abt 2 } | state 2 {a,abt 1 } x y |z y p 2,a 2,l 2 def D in z put, abt 1, l 1 l 2 {lock} | p 1 l 1 l 2 {lock}, {abt,a 2 }, | p 2 l 1 l 2 {lock}, {abt,a 1 }, | state {a 1,a 2 } x |y z x p 1,a 1,l 1 |
47
Workshop Finale Cometa – Dec, 2003 Encoding: Names [def z x x x in z y : 0]
48
Workshop Finale Cometa – Dec, 2003 Encoding: Names [def z x x x in z y : 0][def z x x x in y y : 0]
49
Workshop Finale Cometa – Dec, 2003 Encoding: Names [def z x x x in z y : 0][def z x x x in y y : 0] ** [y y | def z x x x in 0: 0]
50
Workshop Finale Cometa – Dec, 2003 Encoding: Names [def z x x x in z y : 0][def z x x x in y y : 0] ** [y y | def z x x x in 0: 0] yyyy
51
Workshop Finale Cometa – Dec, 2003 Encoding: Names [def z x x x in z y : 0][def z x x x in y y : 0] ** [y y | def z x x x in 0: 0] yyyy [def z x x x in z z : 0]
52
Workshop Finale Cometa – Dec, 2003 Encoding: Names [def z x x x in z y : 0][def z x x x in y y : 0] ** [y y | def z x x x in 0: 0] yyyy [def z x x x in z z : 0]
53
Workshop Finale Cometa – Dec, 2003 Encoding: Names [def z x x x in z y : 0][def z x x x in y y : 0] ** [y y | def z x x x in 0: 0] yyyy [def z x x x in z z : 0] …
54
Workshop Finale Cometa – Dec, 2003 Encoding: Names [def z x x x in z y : 0][def z x x x in y y : 0] ** [y y | def z x x x in 0: 0] yyyy Definitions have different behaviours depending on received names [def z x x x in z z : 0] …
55
Workshop Finale Cometa – Dec, 2003 Encoding: Names A definition is encoded as several definitions: z x x x z s x, p, a,l p l, , {x x } z z x, p, a,l x x, p, a, l
56
Workshop Finale Cometa – Dec, 2003 Encoding: Names A definition is encoded as several definitions: The encoding function takes into account the scope of names: [[ _ ]] S,B z x x x z s x, p, a,l p l, , {x x } z z x, p, a,l x x, p, a, l
57
Workshop Finale Cometa – Dec, 2003 Encoding: Merge Names def b … in [b : 0] has two different behaviors: It can commit It can compute with the global reaction rule for b Merge definitions are encoded with two rules One encoding the commit of the thread The other, the application of the rule inside a negotiation Moreover, the commit behavior is allowed only when parameters are global names
58
Workshop Finale Cometa – Dec, 2003 Correctness and Completeness Correctness P: 1 and canonical. If P cJ * P’ with P: 1, then Q s.t. [[P]] fn(P), j * Q, and norm(Q) [[P’]] fn(P’), Completeness P: 1 and canonical. If [[P]] fn(P), j * Q and norm(Q) is well-defined, then P’ s.t. P cJ P’, and norm(Q) [[P’]] fn(P’),
59
Workshop Finale Cometa – Dec, 2003 Concluding remarks Flat cJoin can be implemented in Join Commit is fully distributed This suggest that full cJoin can be modeled back in Join At commit, a sub-negotiation can generate its parent: new threads, and messages to be delivered at commit On abort, sub-negotiations should finish but not compensate Extension of running implementations of join (Jocaml, Comega, Join-Java)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.