flat committed join in join

59
Hernán Melgratti joint work with Roberto Bruni and Ugo Montanari Dipartimento di Informatica - Università di Pi Flat Committed Join in Join

Upload: kaori

Post on 25-Feb-2016

97 views

Category:

Documents


3 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Flat Committed Join in Join

Hernán Melgratti joint work with Roberto Bruni and Ugo MontanariDipartimento di Informatica - Università di Pisa

Flat Committed Join in Join

Page 2: 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

Page 3: Flat Committed Join in Join

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

Page 4: Flat Committed Join in Join

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

Page 5: Flat Committed Join in Join

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 | JPJ,K ::= xŷ | J|K

Processes

Definitions

Patterns

Programmable abort

Negotiation

CompensationMerge

definition

Messages

Page 6: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Committed Join (cJoin) Operational Semantics (CHAM Style):

0 P|Q P,QDE D,E

def D in P Ddn(D) , Pdn(D) range() fresh

J P, J J P, P

heating and cooling

reaction

Page 7: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Committed Join (cJoin) Operational Semantics (CHAM Style):

0 P|Q P,QDE 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

Page 8: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Committed Join (cJoin) Operational Semantics (CHAM Style):

0 P|Q P,QDE 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

Page 9: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Committed Join (cJoin) Operational Semantics (CHAM Style):

0 P|Q P,QDE 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

Page 10: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Committed Join (cJoin) Operational Semantics (CHAM Style):

0 P|Q P,QDE 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 ]} QJ1|…|JnP, i{[ Ji, Si, Qi ]} J1|…|JnP, {[iSi, P, iQi ]}

Merge n ongoing contracts

Page 11: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Example: Mailing ListML MailingListk MLDef

Page 12: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Example: Mailing ListML MailingListk MLDef

MLDef def …

in kadd, tell, close | lstnil

Page 13: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Example: Mailing ListML MailingListk MLDef

MLDef def … lsty | addx … lsty | tellv … lsty | close …

in kadd, tell, close | lstnil

Page 14: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Example: Mailing ListML MailingListk MLDef

MLDef def … lsty | addx def zv,w xv | yv,w in

lstz lsty | tellv … lsty | close …

in kadd, tell, close | lstnil

Page 15: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Example: Mailing ListML 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

Page 16: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Example: Mailing ListML 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

Page 17: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Example: Mailing ListML 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

Page 18: Flat Committed Join in Join

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

Page 19: Flat Committed Join in Join

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

Page 20: Flat Committed Join in Join

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) 2Merge-Mov xŷ P & P: �0 & count(P) 2Ord-Join xŷ1 | xŷ2 P & P: �1 & count(P) = 1Merge-Join xŷ1 |…|xŷn P & P: �0 & count(P) = 1

Page 21: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Has type �2

Has count = 2

Canonical Form: Exampledef 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]

Page 22: Flat Committed Join in Join

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

Page 23: Flat Committed Join in Join

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

Page 24: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Encoding a negotiation

[def z 0 in z : 0]

Page 25: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Encoding a negotiation

[def z 0 in z : 0]

A negotiation with one thread

Page 26: Flat Committed Join in Join

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

Page 27: Flat Committed Join in Join

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

Page 28: Flat Committed Join in Join

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

Page 29: Flat Committed Join in Join

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

Page 30: Flat Committed Join in Join

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

Page 31: Flat Committed Join in Join

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

Page 32: Flat Committed Join in Join

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

Page 33: Flat Committed Join in Join

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

Page 34: Flat Committed Join in Join

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

Page 35: Flat Committed Join in Join

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

Page 36: Flat Committed Join in Join

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

Page 37: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Encoding: Fork and Joinx y|z

Page 38: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Encoding: Fork and Join xp,a,l def D1 D2 x y|z

Page 39: Flat Committed Join in Join

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

Page 40: Flat Committed Join in Join

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

Page 41: Flat Committed Join in Join

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

Page 42: Flat Committed Join in Join

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

Page 43: Flat Committed Join in Join

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|

Page 44: Flat Committed Join in Join

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|

Page 45: Flat Committed Join in Join

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|

Page 46: Flat Committed Join in Join

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|

Page 47: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Encoding: Names[def zx xx in zy: 0]

Page 48: Flat Committed Join in Join

Workshop Finale Cometa – Dec,

2003

Encoding: Names[def zx xx in zy: 0] [def zx xx in yy:

0]

Page 49: Flat Committed Join in Join

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]

Page 50: Flat Committed Join in Join

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

Page 51: Flat Committed Join in Join

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]

Page 52: Flat Committed Join in Join

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]

Page 53: Flat Committed Join in Join

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]

Page 54: Flat Committed Join in Join

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]

Page 55: Flat Committed Join in Join

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

Page 56: Flat Committed Join in Join

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

Page 57: Flat Committed Join in Join

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

Page 58: Flat Committed Join in Join

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’),

Page 59: Flat Committed Join in Join

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)