710 likes | 889 Views
Choreography-driven design. Ivan Lanese. Department of Computer Science University of Bologna INRIA research team FOCUS. Joint work with: Mario Bravetti, Gianluigi Zavattaro. Plan of the. Plan of the Talk. From Choreography to Contracts Contract-based Service Discovery Conclusion.
E N D
Choreography-driven design Ivan Lanese Department of Computer ScienceUniversity of Bologna INRIA research team FOCUS Joint work with: Mario Bravetti, Gianluigi Zavattaro
Plan of the Plan of the Talk • From Choreography to Contracts • Contract-based Service Discovery • Conclusion
Different models for interacting systems • Choreography (e.g. WS-CDL): Top abstract view of the system, composed by communications involving two of its participants • Orchestration (e.g. WS-BPEL)Set of contracts describing the components of the system, composed by sendings & receivings of messages
WS-CDL • Global view of service interactions Seller Buyer Bank
WS-CDL • Global view of service interactions Seller Request Buyer Bank
WS-CDL • Global view of service interactions Seller Request Offer Buyer PayDescr Bank
WS-CDL • Global view of service interactions Seller Request Offer Buyer PayDescr Payment Bank
WS-CDL • Global view of service interactions Seller Request Offer Buyer PayDescr Confirm Payment Receipt Bank
WS-CDL RequestBuyerSeller ; ( OfferSellerBuyer | PayDescrSellerBank ) ; PaymentBuyerBank ; ( ConfirmBankSeller | ReceiptBankBuyer ) Explicit representation of concurrency
Projection of the Choreography on the Single Participants Buyer: Send(Request)@Seller;Receive(Offer); Send(Payment)@Bank;Receive(Receipt) Seller: Receive(Request); (Send(Offer)@Buyer | Send(PayDescr)@Bank); Receive(Confirm) Bank: Receive(PayDescr);Receive(Payment); (Send(Receipt)@Buyer | Send(Confirm)@Seller)
Well Formed WS-CDL Choreographies • Can we always project (in a simple way)a WS-CDL choreography by preserving its behavior? • Which kind of behavior is preserved?
A Formal Model for WS-CDL • A global choreography language: H ::= ars | 1 | 0 | H;H | H+H | H|H
A Formal Model for WS-CDL • A global choreography language: H ::= ars | 1 | 0 | H;H | H+H | H|H r invokes the operation a of s Unsuccessful termination Successful termination
A Formal Model for WS-CDL • A global choreography language: H ::= ars | 1 | 0 | H;H | H+H | H|H Sequence Choice Parallel
A Formal Model for orchestrations • A language for orchestrations: P ::= a | ar| 1 | 0 | P;P | P+P | P|P S ::= [P]r | S|S
A Formal Model for orchestrations • A language for orchestrations: P ::= a | ar| 1 | 0 | P;P | P+P | P|P S ::= [P]r | S|S receive on a Unsuccessful termination invoke a at r Successful termination
A Formal Model for orchestrations • A language for orchestrations: P ::= a | ar| 1 | 0 | P;P | P+P | P|P S ::= [P]r | S|S Sequence Choice Parallel
A Formal Model for orchestrations • A language for orchestrations: P ::= a | ar| 1 | 0 | P;P | P+P | P|P S ::= [P]r | S|S Parallel compositionof participants Behaviour of participant r
The “canonical” projection • Projection [[ H ]]t of choreography Hto participant t as if t=r [[ ars ]]t = a if t=s 1 otherwise [[H;H’]]t=[[H]]t ; [[H’]]t [[H|H’]]t=[[H]]t | [[H’]]t [[H+H’]]t=[[H]]t + [[H’]]t • Essentially an homomorphism
Example • Consider the global choreography:ars ; btu • Projection: [ as ;1]r | [ a;1 ]s | [ 1;bu ]t | [ 1;b ]u • Are the two models equivalent? • NO • But, if r=t…. YES (synchronous)[ as; bu ]r | [ a;1 ]s | [ 1;b ]u
Asynchronous communication • Reconsider the example assuming asynchronous communication [ as; bu ]r | [ 1;a ]s | [ 1;b ]u • Communication on a starts before communication on b but could finish after • What we should observe? • Send, receive, both, …?
A lattice of possible observation criteria Synchronous Sender Receiver Sender-receiver Disjoint
A lattice of possible observation criteria Assuming synchronous communication: observe either send or receive Synchronous Sender Receiver Sender-receiver Disjoint
A lattice of possible observation criteria Synchronous Assuming asynchronous communication: observe send Sender Receiver Sender-receiver Disjoint
A lattice of possible observation criteria Assuming asynchronous communication: observe receive Synchronous Sender Receiver Sender-receiver Disjoint
A lattice of possible observation criteria Synchronous Sender Receiver Assuming asynchronous communication: observe send and observe receive Sender-receiver Disjoint
A lattice of possible observation criteria Synchronous Sender Receiver Assuming asynchronous communication: observe send and receive together Sender-receiver Disjoint
What about the previous example? • Reconsider the example ars ; bru [ as; bu ]r | [ 1;a ]s | [ 1;b ]u • OK: for synchronous and sender • NO: for receiver, sender-receiver, disjoint
Main result • For each observation criterion: • Sufficient syntactic conditions(connectedness, unique point of choice, and causality safety) that guarantee that a choreography is equivalent to its projection
Unique point of choice • In a choice H+H’ • The sender of the initial transitions in H and in H’ is always the same • The roles in H and in H’ are the same • Example: if we drop the second condition (ars + brt ); cst [ ( as+bt );1]r | [ (a+1);ct ]s | [ (1+b);c ]t
Which equivalence between choreography and orchestration? • Synchronous equivalence: global transitions are matched by synchronous local transitions • Sender equivalence: global transitions are matched by local sends, local receives are abstracted away • weak w.r.t. local receive transitions • Receiver equivalence: global transitions are matched by local receives, local sends are abstracted away • weak w.r.t. local send transitions • Sender-Receiver equivalence: both conditions above • Disjoint equivalence: global transitions are matched by a pair of a local send and a local receive
Example: Receiver equivalence • Global choreography:ars ; bts • Local choreography: [ 1;as ]r | [ a;b ]s | [ 1;bs ]t • The two systems are receiver equivalent
Amending choreographies What can we do if a choreography does not satisfy the conditions? • We can automatically transform it into one that satisfies the conditions for disjoint equivalence • Preserving the “weak” traces • We add actions which are used only for synchronization and are not observed
Example: Amending choreographies Original choreography: (ars | cru) ; bts Amended choreography: (ars ; h*sz|cru ; i*uz) ;j*zt; bts The two systems are now weak disjoint equivalent Similar patterns for all the criteria
Which equivalence to choose? Synchronous equivalence: if I have a synchronous system (easy ) Sender equivalence: ensures that data are available when needed Receiver equivalence: ensures that invariants in the choreography hold in the projected system Sender-Receiver equivalence: both the properties above Disjoint equivalence: robust also in case of message loss
Example Consider the global choreography:withdrawcustbank ; paycustshop Projection: [ wbank ;pshop]cust | [ 1;w ]bank | [ 1;p ]shop In the choregraphy money is never created In the system I can pay before the bank has updated my account amount
Example In a receiver connected choreography this will not happenwithdrawcustbank ; notifybankshop ; paycustshop Also in the projection the bank has updated the account before money can be spent
Plan of the From Choreography to Contracts Contract-based service discovery Conclusion Plan of the Talk
Contract:abstract service description Service Contracts • Contract: service “behavioural interface” • correct sequence of invoke and receive • just finite-state labeledtransition system with successful termination public registry
Contract Compliance • Verification of correctness of service composition based on their contracts: successful interaction i.e. no deadlock / termination reached public registry public registry Contract:abstract service description Contract:abstract service description … Reciprocal invocations Service Service …
Service Compliance: Formally • Services are compliant if the following holds for their composition S: S --->* S’implies that there exist S’’ and S’’’ s.t. S’ --->* S’’ ---> S’’’ • i.e. every computation can be extended to reach successful completion of all services • termination under fairness assumption τ τ √
Example: compliant services • The following pairs of services are compliant: • C1 = a+b+c C2 = a + b • C1 = a;b C2 = a | b • C1 = (a; b )* C2 = a;( b;a )*;b
Compliance-Preserving Contract Refinement ! Choreography projection projection compliant by construction Contract Part. 1 Contract Part. n … refines refines compliance preserved by refinement public registry public registry Contract Contract … Reciprocal invocations Service Service …
Contract Refinement Relation Choreography compliant by construction Contract Part. 1 Contract Part. n … refines refines compliance preserved by refinement public registry public registry Contract Contract … Reciprocal invocations Service Service …
Formally: Subcontract Preorder • Preorder ≤ between contracts C: • C’ ≤ C means C’ is a subcontract of C C subcontractpreorder sub-contracts of C
subcontractpreorder sub-contracts of Cn sub-contracts of C1 sub-contracts of C2 … … C’1 C’2 C’n Definition of Preorder Induced from Independent Refinement Given a set of compliant contracts … C1 C2 Cn is a set of compliant contracts
No maximal subcontract preorder … in general • Consider the system: [ a ] | [ a ] we could have one preorder ≤1 for which a + c.0 ≤1 a a + c.0 ≤1 a and one preorder ≤2 for which a + c.0 ≤2 a a + c.0 ≤2 a but no subcontract preorder could have a + c.0 ≤ a a + c.0 ≤ a • Consequence: no independent refinement!
Maximal pre-order • It exists under some assumptions: • Limiting the considered services (output persistence) • Strengthening the notion of compliance (strong compliance) • Moving to asynchronous communication(e.g. via message queues)
Output persistence • Output persistence means that given a process state P: • If P has an output action on a and P-->P’ with a different from output on a, then also P’ has an output on a • This holds, for instance, in WS-BPEL (without faults) • Pick operator is input guarded • Difficult to force if mixed choice is used a
Example • Given the choreography: RequestAliceBob; (AcceptBobAlice +RejectBobAlice) The following services can be retrieved: [τ;RequestBob;(Accept+Reject)]Alice | [Request;(τ;AcceptAlice+τ;RejectAlice)]Bob