Hernán Melgratti joint work with Roberto Bruni and Ugo Montanari Dipartimento di Informatica -...
-
date post
20-Dec-2015 -
Category
Documents
-
view
215 -
download
0
Transcript of Hernán Melgratti joint work with Roberto Bruni and Ugo Montanari Dipartimento di Informatica -...
Hernán Melgratti
joint work with Roberto Bruni and Ugo MontanariDipartimento di Informatica - Università di Pisa
Flat Committed Join in Join
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 ::= JP | DE
J,K ::= xŷ | J|K
Processes
Definitions
Patterns
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 ::= JP | DE
J,K ::= xŷ | J|K
Processes
Definitions
Patterns
Messages
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 ::= JP | DE
J,K ::= xŷ | J|K
Processes
Definitions
Patterns
Messages
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 ::= JP | DE | JP
J,K ::= xŷ | J|K
Processes
Definitions
Patterns
Programmable abort
Negotiation
CompensationMerge
definition
Messages
Workshop Finale Cometa – Dec,
2003
Committed Join (cJoin) Operational Semantics (CHAM Style):
0
P|Q P,Q
DE D,E
def D in P Ddn(D) , Pdn(D) range() fresh
J P, J J P, P
heating and cooling
reaction
Workshop Finale Cometa – Dec,
2003
Committed Join (cJoin) Operational Semantics (CHAM Style):
0
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 ]}
Contract P evolves in isolation
Compensation Q is kept
frozen
Workshop Finale Cometa – Dec,
2003
Committed Join (cJoin) Operational Semantics (CHAM Style):
0
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
Global Resources
Commit
Workshop Finale Cometa – Dec,
2003
Committed Join (cJoin) Operational Semantics (CHAM Style):
0
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
Workshop Finale Cometa – Dec,
2003
Committed Join (cJoin) Operational Semantics (CHAM Style):
0
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, {[iSi, P, iQi ]}
Merge n ongoing
contracts
Workshop Finale Cometa – Dec,
2003
Example: Mailing List
ML MailingListk MLDef
MLDef def …
in kadd, tell, close | lstnil
Workshop Finale Cometa – Dec,
2003
Example: Mailing List
ML MailingListk MLDef
MLDef def …
lsty | addx … lsty | tellv … lsty | close …
in kadd, tell, close | lstnil
Workshop Finale Cometa – Dec,
2003
Example: Mailing List
ML MailingListk MLDef
MLDef def …
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
MLDef def …
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
MLDef 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 …
in kadd, tell, close | lstnil
Workshop Finale Cometa – Dec,
2003
Example: Mailing List
ML MailingListk MLDef
MLDef 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
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
Open xŷ P & P: �2 & count(P) = 1
Ord-Mov xŷ P & P: �1 & count(P) 2
Merge-Mov xŷ 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
Workshop Finale Cometa – Dec,
2003
Has type �2
Has count = 2
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 0in kadd, tell, close | lstnil
lsty | tellx ay,x ay,x [def w 0 in yv,w| lsty : lsty]
ay,x [def w 0 in def bv,w,l,y yv,w| ly in bv,w,lst,y : lsty]
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]
A negotiation with one thread
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
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
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
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
Workshop Finale Cometa – Dec,
2003
Encoding a negotiation
[def z 0 in z : 0] def D cmp 0 in state {cmp} | | def … pl, , in zput, 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
Workshop Finale Cometa – Dec,
2003
Encoding a negotiation
[def z 0 in z : 0] def D cmp 0 in state {cmp} | | def …
in zput, 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
Workshop Finale Cometa – Dec,
2003
Encoding a negotiation
[def z 0 in z : 0] def D cmp 0 in state {cmp} | | def zp, a, l …
in zput, 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
Workshop Finale Cometa – Dec,
2003
Encoding a negotiation
[def z 0 in z : 0] def D cmp 0 in state {cmp} | | def zp, a, l …
in zput, 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
Workshop Finale Cometa – Dec,
2003
Encoding a negotiation
[def z 0 in z : 0] def D cmp 0 in state {cmp} | | def zp, a, l pl, ,
in zput, 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
Workshop Finale Cometa – Dec,
2003
Encoding an abort
[def z abort in z : 0] def D cmp 0 in state {cmp} | | def zp, a, l … in zput, 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
Workshop Finale Cometa – Dec,
2003
Encoding an abort
[def z abort in z : 0] def D cmp 0 in state {cmp} | | def zp, a, l a in zput, 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
Workshop Finale Cometa – Dec,
2003
Encoding: Fork and Join
xp,a,l def D1 D2 in yput1, abt1, l{lock1,lock2} | zput2, abt2, l{lock1,lock2}
x y|z
Workshop Finale Cometa – Dec,
2003
Encoding: Fork and Join
xp,a,l def D1 D2 in yput1, abt1, l{lock1,lock2} | zput2, abt2, l{lock1,lock2} | pl{lock1,lock2}, {abt1,abt2} ,
x y|z
Workshop Finale Cometa – Dec,
2003
Encoding: Fork and Join
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
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
x|y z
Workshop Finale Cometa – Dec,
2003
Encoding: Fork and Join
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
yp2,a2,l2 def D x|y z xp1,a1,l1|
Workshop Finale Cometa – Dec,
2003
Encoding: Fork and Join
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
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
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
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
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
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] [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
Encoding: Names
[def zx xx in zy: 0] [def zx xx in yy: 0]*
[yy | def zx xx in 0: 0] yy
[def zx xx in zz: 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
[def zx xx in zz: 0]
[def zx xx in zz: 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
[def zx xx in zz: 0]
[def zx xx in zz: 0]
[def zx xx in zz: 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
Definitions have different behaviours depending on received names
[def zx xx in zz: 0]
[def zx xx in zz: 0]
[def zx xx in zz: 0]
…
Workshop Finale Cometa – Dec,
2003
Encoding: Names A definition is encoded as several definitions:
zx xxzsx, p , a ,l p l, , {xx}
zzx, p , a ,l x x, p, a, l
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
zx xxzsx, p , a ,l p l, , {xx}
zzx, p , a ,l x x, p, a, l
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
Workshop Finale Cometa – Dec,
2003
Correctness and Completeness
CorrectnessP: �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’),
CompletenessP: �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’),
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)