590 likes | 788 Views
Flat Committed Join in Join. Hern á n Melgratti joint work with Roberto Bruni and Ugo Montanari Dipartimento di Informatica - Università di Pisa. Committed Join (cJoin). Join + primitives for negotiations Syntax:. P,Q ::= 0 | x ŷ | def D in P | P|Q D,E ::= J P | D E
E N D
Flat Committed Join in Join Hernán Melgratti joint work withRoberto BruniandUgo Montanari Dipartimento di Informatica - Università di Pisa
Committed Join (cJoin) • Join + primitives for negotiations • Syntax: P,Q ::= 0 | xŷ| def D in P | P|Q D,E ::= JP | DE J,K ::= xŷ | J|K Processes Definitions Patterns Workshop Finale Cometa – Dec, 2003
Committed Join (cJoin) • Join + primitives for negotiations • Syntax: Messages M,N::= 0 | xŷ | M|N P,Q ::= 0 | xŷ| def D in P | P|Q D,E ::= JP | DE J,K ::= xŷ | J|K Processes Definitions Patterns Workshop Finale Cometa – Dec, 2003
Committed Join (cJoin) • Join + primitives for negotiations • Syntax: Messages M,N::= 0 | xŷ | M|N P,Q ::= M| def D in P | P|Q D,E ::= JP | DE J,K ::= xŷ | J|K Processes Definitions Patterns Workshop Finale Cometa – Dec, 2003
Negotiation Compensation Committed Join (cJoin) • Join + primitives for negotiations • Syntax: Messages Programmable abort M,N::= 0 | xŷ | M|N P,Q ::= M| def D in P | P|Q | abort|[P:Q] D,E ::= JP | DE | JP J,K ::= xŷ | J|K Processes Definitions Patterns Merge definition Workshop Finale Cometa – Dec, 2003
Committed Join (cJoin) • Operational Semantics (CHAM Style): heating and cooling reaction Workshop Finale Cometa – Dec, 2003
Committed Join (cJoin) • Operational Semantics (CHAM Style): Contract P evolves in isolation Compensation Q is kept frozen Workshop Finale Cometa – Dec, 2003
Committed Join (cJoin) • Operational Semantics (CHAM Style): Global Resources Commit Workshop Finale Cometa – Dec, 2003
Committed Join (cJoin) • Operational Semantics (CHAM Style): Compensation on Abort Workshop Finale Cometa – Dec, 2003
Committed Join (cJoin) • Operational Semantics (CHAM Style): Merge n ongoing contracts Workshop Finale Cometa – Dec, 2003
Example: Mailing List ML MailingListk MLDef Workshop Finale Cometa – Dec, 2003
Example: Mailing List ML MailingListk MLDef MLDefdef … in kadd, tell, close | lstnil Workshop Finale Cometa – Dec, 2003
Example: Mailing List ML MailingListk MLDef MLDefdef … lsty | addx … lsty | tellv … lsty | close … in kadd, tell, close | lstnil Workshop Finale Cometa – Dec, 2003
Example: Mailing List ML MailingListk MLDef MLDefdef … lsty | addx def zv,w xv | yv,w in lstz lsty | tellv … lsty | close … in kadd, tell, close | lstnil Workshop Finale Cometa – Dec, 2003
Example: Mailing List ML MailingListk MLDef MLDefdef … lsty | addx def zv,w xv | yv,w in lstz lsty | tellv [def w 0 in yv,w| lsty : lsty] lsty | close … in kadd, tell, close | lstnil Workshop Finale Cometa – Dec, 2003
Example: Mailing List ML MailingListk MLDef MLDefdef nilv, w 0 lsty | addx def zv,w xv | yv,w in lstz lsty | tellv [def w 0 in yv,w| lsty : lsty] lsty | close … in kadd, tell, close | lstnil Workshop Finale Cometa – Dec, 2003
Example: Mailing List ML MailingListk MLDef MLDefdef nilv, w 0 lsty | addx def zv,w xv | yv,w in lstz lsty | tellv [def w 0 in yv,w| lsty : lsty] lsty | close 0 in kadd, tell, close | lstnil 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 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 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 Workshop Finale Cometa – Dec, 2003
Has type 2 • lsty | tellx ay,x • ay,x [def w 0 in yv,w| lsty : lsty] Has count = 2 ay,x [def w 0 in def bv,w,l,y yv,w| ly in bv,w,lst,y : lsty] Canonical Form: Example def nilv, w 0 lsty | addx def zv,w xv | yv,w in lstz lsty | tellv [def w 0 in yv,w| lsty : lsty] lsty |close 0 in kadd, tell, close | lstnil 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 Workshop Finale Cometa – Dec, 2003
Encoding: 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 Workshop Finale Cometa – Dec, 2003
Encoding a negotiation [def z 0 in z : 0] Workshop Finale Cometa – Dec, 2003
Encoding a negotiation [def z 0 in z:0] A negotiation with one thread Workshop Finale Cometa – Dec, 2003
Encoding a negotiation • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z 0 in z:0] A negotiation with one thread A coordinator Dto manage z def D Workshop Finale Cometa – Dec, 2003
Encoding a negotiation • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z 0 in z : 0] def D Compensation Workshop Finale Cometa – Dec, 2003
Encoding a negotiation • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z 0 in z : 0] Set initial compensation def D cmp 0 in state {cmp} Compensation Workshop Finale Cometa – Dec, 2003
Encoding a negotiation • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z 0 in z: 0] def D cmp0 in state {cmp} z runs in a managed thread Workshop Finale Cometa – Dec, 2003
Encoding a negotiation • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z 0 in z: 0] z carries the ports of its coordinator def D cmp0 in state {cmp} | | def … pl, , inzput, abt, {lock} z runs in a managed thread Workshop Finale Cometa – Dec, 2003
Encoding a negotiation • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z 0 in z : 0] def D cmp0 in state {cmp} | | def … inzput, abt, {lock} It consumes managed msgs Workshop Finale Cometa – Dec, 2003
Encoding a negotiation • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z 0 in z : 0] z carries the ports of its coordinator def D cmp0 in state {cmp} | | def zp, a, l … inzput, abt, {lock} It consumes managed msgs Workshop Finale Cometa – Dec, 2003
Encoding a negotiation • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z 0in z : 0] def D cmp0 in state {cmp} | | def zp, a, l … inzput, abt, {lock} The thread ends Workshop Finale Cometa – Dec, 2003
Encoding a negotiation • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z 0in z : 0] D can commit def D cmp0 in state {cmp} | | def zp, a, l pl, , inzput, abt, {lock} The thread ends Workshop Finale Cometa – Dec, 2003
Encoding an abort • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z abortin z : 0] def D cmp0 in state {cmp} | | def zp, a, l … inzput, abt, {lock} The thread aborts Workshop Finale Cometa – Dec, 2003
Encoding an abort • put: to notify thread completion • abt: to notify thread abortion • lock: to receive partners’ confirmations • state: to set the initial compensation [def z abortin z : 0] D aborts def D cmp0 in state {cmp} | | def zp, a, l a inzput, abt, {lock} The thread aborts Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z xp,a,l def D1 D2 Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z xp,a,l def D1 D2 in yput1, abt1,l{lock1,lock2} | zput2, abt2,l{lock1,lock2} Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z xp,a,l def D1 D2 in yput1, abt1,l{lock1,lock2} | zput2, abt2,l{lock1,lock2} | pl{lock1,lock2}, {abt1,abt2} , Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z xp,a,l def D1 D2 in yput1, abt1,l{lock1,lock2} | zput2, abt2,l{lock1,lock2} | pl{lock1,lock2}, {abt1,abt2} , | state1{a,abt2} | state2{a,abt1} Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z xp,a,l def D1 D2 in yput1, abt1,l{lock1,lock2} | zput2, abt2,l{lock1,lock2} | pl{lock1,lock2}, {abt1,abt2} , | state1{a,abt2} | state2{a,abt1} x|y z Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z xp,a,l def D1 D2 in yput1, abt1,l{lock1,lock2} | zput2, abt2,l{lock1,lock2} | pl{lock1,lock2}, {abt1,abt2} , | state1{a,abt2} | state2{a,abt1} yp2,a2,l2 def D x|y z xp1,a1,l1| Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z xp,a,l def D1 D2 in yput1, abt1,l{lock1,lock2} | zput2, abt2,l{lock1,lock2} | pl{lock1,lock2}, {abt1,abt2} , | state1{a,abt2} | state2{a,abt1} yp2,a2,l2 def D in zput, abt1,l1 l2{lock} x|y z xp1,a1,l1| Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z xp,a,l def D1 D2 in yput1, abt1,l{lock1,lock2} | zput2, abt2,l{lock1,lock2} | pl{lock1,lock2}, {abt1,abt2} , | state1{a,abt2} | state2{a,abt1} yp2,a2,l2 def D in zput, abt1,l1 l2{lock} | p1 l1 l2{lock}, {abt,a2} , | p2 l1 l2{lock}, {abt,a1} , x|y z xp1,a1,l1| Workshop Finale Cometa – Dec, 2003
Encoding: Fork and Join x y|z xp,a,l def D1 D2 in yput1, abt1,l{lock1,lock2} | zput2, abt2,l{lock1,lock2} | pl{lock1,lock2}, {abt1,abt2} , | state1{a,abt2} | state2{a,abt1} yp2,a2,l2 def D in zput, abt1,l1 l2{lock} | p1 l1 l2{lock}, {abt,a2} , | p2 l1 l2{lock}, {abt,a1} , | state{a1,a2} x|y z xp1,a1,l1| Workshop Finale Cometa – Dec, 2003
Encoding: Names [def zx xx in zy: 0] Workshop Finale Cometa – Dec, 2003
Encoding: Names [def zx xx in zy: 0] [def zx xx in yy: 0] Workshop Finale Cometa – Dec, 2003
Encoding: Names [def zx xx in zy: 0] [def zx xx in yy: 0] [yy | def zx xx in 0: 0] * Workshop Finale Cometa – Dec, 2003
Encoding: Names [def zx xx in zy: 0] [def zx xx in yy: 0] [yy | def zx xx in 0: 0] * yy Workshop Finale Cometa – Dec, 2003