440 likes | 589 Views
Nested Commits for Mobile Calculi: Extending Join. Roberto Bruni, Hern án Melgratti and Ugo Montanari. Motivation. To develop a process description language with primitives for agreements or negotiations Multiway (several parties can start separately but commit on reached agreement)
E N D
Nested Commits for Mobile Calculi: Extending Join Roberto Bruni, Hernán Melgratti and Ugo Montanari
Motivation • To develop a process description language with primitives for agreements or negotiations • Multiway (several parties can start separately but commit on reached agreement) • Non-perfect compensations (certain actions cannot be undone) • Programmable abort / compensation • Different levels of abstraction IFIP-TCS 2004, Toulouse, August 21-27 2004
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 IFIP-TCS 2004, Toulouse, August 21-27 2004
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 IFIP-TCS 2004, Toulouse, August 21-27 2004
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 IFIP-TCS 2004, Toulouse, August 21-27 2004
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 IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join (cJoin) • Operational Semantics (CHAM Style): heating and cooling reaction IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join (cJoin) • Operational Semantics (CHAM Style): Contract P evolves in isolation Compensation Q is kept frozen IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join (cJoin) • Operational Semantics (CHAM Style): Global Resources Commit IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join (cJoin) • Operational Semantics (CHAM Style): Compensation on Abort IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join (cJoin) • Operational Semantics (CHAM Style): Merge n ongoing contracts IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination {[ M | def D in 0 , Q ]} M IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation {[ abort | P , Q ]} Q IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation • Cooperation between contracts are given by merging definitions (multiway contracts) …,J1|J2P, [J1t| P1:Q1], [J2t| P2: Q2] …,J1|J2 P, [Pt|P1| P2: Q1| Q2] IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation • Cooperation between contracts are given by merging definitions (multiway contracts) • Multi-level nesting [ [P1 :Q1] | [P2:Q2] : Q] IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation • Cooperation between contracts are given by merging definitions (multiway contracts) • Multi-level nesting [ [P1 :Q1] | [P2:Q2] : Q] * [ M1 | [P2:Q2] : Q] IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation • Cooperation between contracts are given by merging definitions (multiway contracts) • Multi-level nesting [ [P1 :Q1] | [P2:Q2] : Q] * [ M1 | [P2:Q2] : Q] * [ M1 | M2: Q] IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation • Cooperation between contracts are given by merging definitions (multiway contracts) • Multi-level nesting [ [P1 :Q1] | [P2:Q2] : Q] * [ M1 | [P2:Q2] : Q] * [ M1 | M2 : Q] M1 | M2 IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation • Cooperation between contracts are given by merging definitions (multiway contracts) • Multi-level nesting [ [P1 :Q1] | [P2:Q2] : Q] * [ [abort | P1’:Q1] | [P2:Q2] : Q] IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation • Cooperation between contracts are given by merging definitions (multiway contracts) • Multi-level nesting [ [P1 :Q1] | [P2:Q2] : Q] * [ [abort | P1’:Q1] | [P2:Q2] : Q] [ Q1 | [P2:Q2] : Q] IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation • Cooperation between contracts are given by merging definitions (multiway contracts) • Multi-level nesting [ [P1 :Q1] | [P2:Q2] : Q] * [ [abort | P1’:Q1] | [P2:Q2] : Q] [ Q1| [P2:Q2] : Q] * [ abort | Q1’ | [P2:Q2] : Q] IFIP-TCS 2004, Toulouse, August 21-27 2004
Committed Join Features • Commit means termination • Global resources produced inside a negotiation are availableat commit • Explicit abort and compensation • Cooperation between contracts are given by merging definitions (multiway contracts) • Multi-level nesting [ [P1 :Q1] | [P2:Q2] : Q] * [ [abort | P1’:Q1] | [P2:Q2] : Q] [ Q1 | [P2:Q2] : Q] * [ abort | Q1’ | [P2:Q2] : Q] Q IFIP-TCS 2004, Toulouse, August 21-27 2004
Example I: Hotel Booking H def WaitBooking [ def requesto o$ | price$ price$ | confirmv BookedRoomv price$ abort inofferingRoom request,confirm : Q ] BookedRoomv … inWaitBooking | … IFIP-TCS 2004, Toulouse, August 21-27 2004
Example I: Hotel Booking H def WaitBooking [ def requesto o$ | price$ price$ | confirmv BookedRoomv price$ abort inofferingRoom request,confirm : Q ] BookedRoomv … inWaitBooking | … C def BookingHotel [defhotelMsgr,cdef offer$ cvisa | HotelFound offer$ abort in roffer insearchRoom hotelMsg : Q’ ] inBookingHotel | … IFIP-TCS 2004, Toulouse, August 21-27 2004
Example I: Hotel Booking H def WaitBooking [ def requesto o$ | price$ price$ | confirmv BookedRoomv price$ abort inofferingRoom request,confirm : Q ] BookedRoomv … inWaitBooking | … C def BookingHotel [defhotelMsgr,cdef offer$ cvisa | HotelFound offer$ abort in roffer insearchRoom hotelMsg : Q’ ] inBookingHotel | … HB defsearchRoomhm |offeringRoom r,chmr,c inH | C IFIP-TCS 2004, Toulouse, August 21-27 2004
Example I: 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 IFIP-TCS 2004, Toulouse, August 21-27 2004
Example I: Trip Booking I H as before F def WaitBooking [ def requesto o$ | price$ price$ | confirmv BookedFlightv price$ abort inofferingFlight request,confirm : Q ] BookedFlightv … inWaitBooking | … local name, different from homonym name in H IFIP-TCS 2004, Toulouse, August 21-27 2004
Example I: Trip Booking II both needed to commit C defhotelOKfc | flightOKhc fc | hc BookingHotel [defhotelMsgr,cdef offer$ cvisa | hotelOKflightConf offer$ abort flightConf HotelFound in roffer insearchRoom hotelMsg : Q’ ] BookingFlight [defflightlMsgr,cdef offer$ cvisa | flightOKhotelConf offer$ abort hotelConf FlightFound in roffer insearchFlight flightMsg : Q’’ ] inBookingHotel | BookingFlight | … IFIP-TCS 2004, Toulouse, August 21-27 2004
Example I: Trip Booking II both needed to commit C defhotelOKfc | flightOKhc fc | hc BookingHotel [defhotelMsgr,cdef offer$ cvisa | hotelOKflightConf offer$ abort flightConf HotelFound in roffer insearchRoom hotelMsg : Q’ ] BookingFlight [defflightlMsgr,cdef offer$ cvisa | flightOKhotelConf offer$ abort hotelConf FlightFound in roffer insearchFlight flightMsg : Q’’ ] inBookingHotel | BookingFlight | … TB def searchRoomhm |offeringRoom r,chmr,c searchFlightfm |offeringFlight r,cfmr,c inH | F | C IFIP-TCS 2004, Toulouse, August 21-27 2004
Zero-safe nets • Synchronization mechanism for transitions • Places are divided in Stable: Ordinary places Zero-safe: Idealized resources, invisible to external observers IFIP-TCS 2004, Toulouse, August 21-27 2004
(Firing) (Step) (Concatenation) (Close) S+Z [ S’+Z’ T (S1,Z1) T (S1’,Z1’) (S2,Z2) T (S2’,Z2’) (S1,Z) T (S1’,Z’’) (S2,Z’’) T (S2’,Z’) (S,) T (S’,) (S+S’’,Z+Z’’) T (S’+S’’,Z’+Z’’) (S1+S2,Z1+Z2) T (S1’+S2’,Z1’ + Z2’) (S1+S2,Z) T (S1’+S2’,Z’) (S,) T (S’,) Zero-safe nets • Synchronization mechanism for transitions • Places are divided in Stable: Ordinary places Zero-safe: Idealized resources, invisible to external observers IFIP-TCS 2004, Toulouse, August 21-27 2004
(Close) (Concatenation) (Step) (Firing) (S,) T (S’,) (S1,Z) T (S1’,Z’’) (S2,Z’’) T (S2’,Z’) (S1,Z1) T (S1’,Z1’) (S2,Z2) T (S2’,Z2’) S+Z [ S’+Z’ T (S+S’’,Z+Z’’) T (S’+S’’,Z’+Z’’) (S1+S2,Z) T (S1’+S2’,Z’) (S,) T (S’,) (S1+S2,Z1+Z2) T (S1’+S2’,Z1’ + Z2’) Zero-safe nets • Synchronization mechanism for transitions • Places are divided in Stable: Ordinary places Zero-safe: Idealized resources, invisible to external observers send receive IFIP-TCS 2004, Toulouse, August 21-27 2004
(Close) (Concatenation) (Step) (Firing) (S,) T (S’,) (S1,Z) T (S1’,Z’’) (S2,Z’’) T (S2’,Z’) (S1,Z1) T (S1’,Z1’) (S2,Z2) T (S2’,Z2’) S+Z [ S’+Z’ T (S+S’’,Z+Z’’) T (S’+S’’,Z’+Z’’) (S1+S2,Z) T (S1’+S2’,Z’) (S,) T (S’,) (S1+S2,Z1+Z2) T (S1’+S2’,Z1’ + Z2’) Zero-safe nets • Synchronization mechanism for transitions • Places are divided in Stable: Ordinary places Zero-safe: Idealized resources, invisible to external observers send receive IFIP-TCS 2004, Toulouse, August 21-27 2004
(Close) (Concatenation) (Step) (Firing) (S,) T (S’,) (S1,Z) T (S1’,Z’’) (S2,Z’’) T (S2’,Z’) (S1,Z1) T (S1’,Z1’) (S2,Z2) T (S2’,Z2’) S+Z [ S’+Z’ T (S+S’’,Z+Z’’) T (S’+S’’,Z’+Z’’) (S1+S2,Z) T (S1’+S2’,Z’) (S,) T (S’,) (S1+S2,Z1+Z2) T (S1’+S2’,Z1’ + Z2’) Zero-safe nets • Synchronization mechanism for transitions • Places are divided in Stable: Ordinary places Zero-safe: Idealized resources, invisible to external observers send receive IFIP-TCS 2004, Toulouse, August 21-27 2004
(Close) (Concatenation) (Step) (Firing) (S,) T (S’,) (S1,Z) T (S1’,Z’’) (S2,Z’’) T (S2’,Z’) (S1,Z1) T (S1’,Z1’) (S2,Z2) T (S2’,Z2’) S+Z [ S’+Z’ T (S+S’’,Z+Z’’) T (S’+S’’,Z’+Z’’) (S1+S2,Z) T (S1’+S2’,Z’) (S,) T (S’,) (S1+S2,Z1+Z2) T (S1’+S2’,Z1’ + Z2’) Zero-safe nets • Synchronization mechanism for transitions • Places are divided in Stable: Ordinary places Zero-safe: Idealized resources, invisible to external observers send receive IFIP-TCS 2004, Toulouse, August 21-27 2004
Zero-safe nets: Encoding • Given a ZS net N=(T,S): • Places ports • Transitions firing rules • Tokens messages • Encoding of a marking S: [[E]] ::= E [[S1+S2]] ::= [[S1]] | [[S2]] IFIP-TCS 2004, Toulouse, August 21-27 2004
E e1 e e e e1 e2 open calc fork fork close drop e2 e1 e2 e e E Zero-safe nets: Encoding • Encoding of (basic) transitions IFIP-TCS 2004, Toulouse, August 21-27 2004
E e1 e e e e1 e2 open calc fork fork close drop e2 e1 e2 e e E Zero-safe nets: Encoding • Encoding of (basic) transitions E [ def z 0 in ez : E ] e1z e2z ez e1z | e2z e1z1 | e2z2 ez1 ez E ez 0 IFIP-TCS 2004, Toulouse, August 21-27 2004
Zero-safe nets: Encoding • cJoin process for a ZS net Let N=(T,S) be a ZS net, PN = def [[ T ]] in [[ S ]] • Theorem Let N=(T,S) be a ZS net. (S,) * (S’,) iff def [[T]] in [[S]] * def [[T]] in [[S’]] IFIP-TCS 2004, Toulouse, August 21-27 2004
Serializability • A serializable transaction admits an abstract representation as a single transition • cJoin negotiations may interact with other negotiations (not serializable in the previous sense) • But all cooperating negotiations can be viewed as a single transition • Moreover, we would like this property to hold at every level of nesting IFIP-TCS 2004, Toulouse, August 21-27 2004
nest( 0 ) = nest( abort ) = nest( xŷ ) = 0 nest( def DinP ) = nest(P ) nest( [ P : Q ]) = nest(P ) + 1 nest( P | Q ) = max{nest( P ), nest(Q )} Serializability: Shallowness • Shallow processes: any computation increases the height of nesting structure in at most 1 • P is shallow if every definition D in P satisfies D = JP, where nest(P ) = 0, or P = [ R : Q ] and nest( R | Q ) = 0 D = J P, and nest(P ) = 0 IFIP-TCS 2004, Toulouse, August 21-27 2004
(Global Firing) (Abort) (Local Commit) (Idle) D ├ [abort | P : S] D ├ S D J P├ J D J P├ P D ├ P D ├ P D ├ [M | D’ ├ 0 : S] D ├ M (Seq) (Local Firing) (Par) D ├ P D ├ P’’ D ├ P’’ D ├ P’ |B|├ S |B|├ S’ D ├ P D ├ P’ D ├ Q D ├ Q’ (Merge) D ├ P | Q D ├ P’ | Q’ D B ├ [S : Q] D B ├ [S’ : Q] D ├ P D ├ P’ D iJiS├ I [ Di├ Ji| Si : Qi] D I JiS├ [iDi├ I Si | S: I Qi] Serializability • Serializability as big step reduction relation () between shallow processes • Theorem: S *cJ S’ iff S S’ IFIP-TCS 2004, Toulouse, August 21-27 2004
Final Remarks • cJoin models multi-way transactions by describing interacting agents but not their global structure • Compensations do not undo precommitted activities. • Can such compensations be encoded in cJoin? • Are cJoin primitives implementable? • We plan to use the D2PC protocol • The subcalculus of flat processes can be implemented IFIP-TCS 2004, Toulouse, August 21-27 2004