Title: Formal Models for Distributed Negotiations Committed Join Calculus
1Formal Models forDistributed NegotiationsCommitt
ed Join Calculus
XVII Escuela de Ciencias Informaticas (ECI 2003),
Buenos Aires, July 21-26 2003
Roberto Bruni Dipartimento di Informatica
Università di Pisa
2Our Focus
- In commercial applications, separately designed
and implemented components must interact - commit (intermediate) results of long-running
activities upon (partial) agreements - e.g. e-commerce, on-line auction systems
- Formal models should
- avoid ad-hoc proprietary solutions
- offer alternatives to centralized transaction
managers - hide the coordination layer (separation of
concerns)
3Distributed Agreements
- Negotiations / Contracts
- commit, abort, compensation
- hierarchical decisions
- dynamic membership
- fully distributed control
- Process cooperation
- coordination / orchestration / choreography
- different platforms and policies
- Data integration
- unstructured documents in different formats
4Prerequisites forModeling Contracts
- Local and global resources
- Local sub-contracts and decisions
- Global results posted upon commit
- Abort of ongoing contracts
- All participants must be informed
- Compensations can be activated
- Either abort or commit (no divergence)
- Dynamic joining of participants
- Contracts can be merged
- Nested structure of contracts
5Commitment
- We have seen different concepts in different
areas - DataBase transactions
- Transactional Workflows
- Transition synchronization
- PDLs with commit primitives
- Committed choice languages
6PDLs with commit
- Transactions in JavaSpaces and Linda
- create(x) and commit(x) prefixes
- event notification
- TraLinda
- typed messages (L / H) and atomic prefixing
- Long running transactions
- MINI-XLANG
- asynchronous ?-calculus with transactional
context context(P,Pf,Pc)
7Committed Choice Languages
- Logic programming
- Non determinism means exhaustive search of
successful computations - dont know non-determinism
- results are produced at the end
- Concurrent logic / constraint languages
- limit backtracking to improve efficiency
- dont care non-determinism (indeterminism)
- partial outputs during computation
8Guarded Horn Clauses
- Head ? Guard Body
- Reduce Head to Body if Guard succeeds
- dont know when evaluating guards
- dont care when selecting clauses whose guards
are true - Flat guards
- conjunction of primitive predicates
- Deep guards (e.g. AKL)
- both primitive and programmed predicates
9Our Proposal
- committed JOIN
- PDL presentation
- Non ACID
- Multiway
- Open Nesting
- Flexible
- Split / Join
- Programmable commit / abort / compensation
- Concurrency and distribution
- Distributed 2PC
- Different levels of abstraction
10Why an extension of JOIN
- Well-known asynchronous calculus
- Distributed implementations
- Jocaml
- Polyphonic C
- Analogous to dynamic coloured Petri nets
- Running D2PC implementation
- CHAM semantics
- molecules form solutions enclosed in membranes
- nesting is free (via membranes)
- Typed serializability
Ongoing Work!
11Committed JOIN Syntax
messages
- M,N 0 x?y? MN
- P,Q M def D in P PQ abort PQ
- D,E J?P D?E J?P
- J,K x?y? JK
programmable abort
merge definitions (boards) defined boards must
be disjoint from ordinary defined names
12Committed JOIN Semantics
13Committed JOIN Semantics
compensation is kept frozen
contract P can evolve in isolation
14Committed JOIN Semantics
commit
global resources
15Committed JOIN Semantics
compensation on abort
16Committed JOIN Semantics
merge n ongoing contracts
17JOIN vs cJOIN
- PROPOSITION
- cJOIN is a conservative extension of JOIN
P ?J Q iff P ?cJ Q (for P and Q JOIN processes)
18A Multi-Way Contract
19Multi-Level Nesting
20Nested Abort
21Nested Abort II
22Hotel Booking
H ? def WaitBooking ? def
request?o? ? o?? price?? ? price??
confirm?v? ? BookedRoom?v? ?
price?? ? abort in offeringRoom
?request,confirm? Q ? BookedRoom?v?
? in WaitBooking
23Hotel Booking
H ? def WaitBooking ? def
request?o? ? o?? price?? ? price??
confirm?v? ? BookedRoom?v? ?
price?? ? abort in offeringRoom
?request,confirm? Q ? BookedRoom?v?
? in WaitBooking C ? def
BookingHotel ? def hotelMsg ?r,c? ? def offer??
? c?visa? HotelFound ? offer?? ?
abort in r?offer? in searchRoom
?hotelMsg? Q in BookingHotel
24Hotel Booking
H ? def WaitBooking ? def
request?o? ? o?? price?? ? price??
confirm?v? ? BookedRoom?v? ?
price?? ? abort in offeringRoom
?request,confirm? Q ? BookedRoom?v?
? in WaitBooking C ? def
BookingHotel ? def hotelMsg ?r,c? ? def offer??
? c?visa? HotelFound ? offer?? ?
abort in r?offer? in searchRoom
?hotelMsg? Q in BookingHotel
HB ? def searchRoom?hm? offeringRoom ?r,c? ?
hm?r,c? in H C
25Hotel Booking
, WaitBooking , BookingHotel ? ? , ,
offeringRoom?request,confirm? Q , ,
searchRoom?hotelMsg? Q ? , ,
hotelMsg?request,confirm? Q Q ? , ,
request?offer? Q Q ? , , offer??,
price?? Q Q ? , , confirm?visa?,
HotelFound , price?? Q Q ? , ,
BookedRoom?visa?, HotelFound Q Q ? ,
BookedRoom?visa?, HotelFound
26Trip Booking I
H as before F ? def WaitBooking ? def
request?o? ? o?? price?? ?
price?? confirm?v? ? BookedFlight?v? ?
price?? ? abort in
offeringFlight ?request,confirm? Q ?
BookedFlight?v? ? in WaitBooking
local name, different from homonym name in H
27Trip Booking II
both needed to commit
C ? def hotelOK?fc? flightOK?hc? ? fc hc
? BookingHotel ? def hotelMsg?r,c? ? def
offer?? ? c?visa? hotelOK?flightConf?
? offer?? ? abort ? flightConf ?
HotelFound in r?offer? in searchRoom
?hotelMsg? Q ? BookingFlight ? def
flightlMsg?r,c? ? def offer?? ? c?visa?
flightOK?hotelConf? ? offer?? ? abort
? hotelConf ? FlightFound in
r?offer? in searchFlight ?flightMsg? Q
in BookingHotel BookingFlight TB ?
def searchRoom?hm? offeringRoom ?r,c? ?
hm?r,c? ? searchFlight?fm?
offeringFlight ?r,c? ? fm?r,c? in H
F C
28Matching the Prerequisites
- Local and global resources
- Local sub-contracts and decisions
- Global results posted upon commit
- Abort of ongoing contracts
- All participants must be informed
- Compensations can be activated
- Either abort or commit (no divergence)
- Dynamic joining of participants
- Contracts can be merged
- Nested structure of contracts
29ZS nets, JOIN and cJOIN
- ZS nets can be encoded in JOIN by attaching the
dynamic creation of a local DTC to transitions - Implementation of D2PC (transparent to users)
- Tokens must carry several channel names
- Each firing must undergo local DTCs approval
- cJOIN primitives allow a straightforward encoding
- No further protocol is needed
- Tokens carry just one contract identifier
- Firings directly correspond to reactions
30ZS nets in JOIN
We encode basic nets, which are expressive enough
given a net (T,S) we define an agent def T
in S , where
E open e E ? def D in e(put,
lock ) state( E ) e calc e
e(p, L) ? e(p, L) e fork e, e
e(p, L) ? def D in e(p, L ? lock )
e(put, L ? lock ) state( ? ) e, e
join e e(p, L) e(p, L) ? e(p,
L ? L) p(L ? L, ? ) e close E
e(p, L) ? p(L, E )
default compensation
31DTC in JOIN
the definition D is the following
state(H) put(L, F) ? commit(L \ lock , L ,
lock , F, H ) state(H) ? failed()
release(H) commit( l ? L, L, L, F, H) ?
commit(L, L, L , F, H) l(L, lock,
fail ) commit(L, L, L, F, H) lock(L, l, f
) ? commit(L ? (L \ L), L ? L, L ?
l , F, H ) commit(?, L, L, F, H) ?
release(F) commit(L, L, L, F, H) fail() ?
failed() release(H) failed() put(L, F) ?
failed() failed() lock(L, l, f) ? failed()
f() failed() fail() ? failed()
32ZS nets in cJOIN
We encode basic nets, which are expressive enough
given a net (T,S) we define an agent def T
in S , where
E open e E ? def z?0 in e?z?
E e calc e e?z? ? e?z? e
fork e, e e?z? ? e?z? e?z?
e, e join e e?z? e?z? ? e?z?
e close E e ?z? ? E
dummy definition (JOIN way of declaring a local
id)
z and z have now identical scope and meaning
33Committed Join Features
- Negotiations can be defined in terms of
concurrent sub-negotiations - Cooperation between contracts are given by
merging definitions - Global resources produced inside a negotiation
are made available at commit time - Commit means termination
- Explicit abort and compensation
34Some results on cJoin
- cJoin is a conservative extension of Join
- P ?J Q iff P ?cJ Q. (P and Q Join processes)
- Zero-safe nets can be encoded as cJoin processes
- N(T,S) a ZS net. (S,?) ? (S,?) iff def T in
S ? def T in S
35cJOIN and Logic Languages
- Commit primitives of cJoin can be used to
implement committed choices of AKL - explicit encoding of search strategies and
unification via continuation passing and
compensation
36Serializability
- A simple type system that guarantees
serializability - Shallow processes
- the start of a sub-negotiation can be postponed
until all the cooperating sub-negotiations needed
to commit can be generated inside its parent
negotiation - Proof via correspondence w.r.t. big step semantics
37Encoding of cJOIN in JOIN
- Aim
- Define an implementation of cJOIN in JOIN
- Associate to every cJOIN process a JOIN process
that simulate its behavior - Ideas
- Identification of basic forms for definitions
- Definition of a type system to single out
canonical processes - Reuse controllers of the D2PC protocol
38Abstract Semantics
- Expected Result
- Define the abstract representative of a cJOIN
process - a JOIN process describing all the stable
behaviors of the original process
def a?x?b?y? ? def c?z? ? b?z? in a?y?
c?x? a?x?b?y? in a?1?b?2?
def a?x? b?y? ? a?y? b?x? in a?1?b?2?
39Comparatives studies
- Comparison with other approaches for modeling
long-running activities - Transactional context of MINI-XLANG
- distinguish two kinds of compensations
- Goals
- Find limitations / restrictions
- Show the encoding of other common constructors
(such as those in WMS)
40References
- Committed actions for mobile calculi (PhD Thesis
Proposal, Manuscript, 2003) - H. Melgratti
- Nested commits for mobile calculi extending Join
(Manuscript) - R. Bruni, H. Melgratti, U. Montanari