process composition

61
Process Composition

Upload: ronda

Post on 22-Jan-2016

39 views

Category:

Documents


0 download

DESCRIPTION

Process Composition. Process Composition Hierarchies. Control: Centralized control: e.g., RPC/WSDL Mediated or orchestrated control: e.g., BPEL Fully distributed control: autonomous processes, e.g., WS-CDL (WSCI) Messaging: Shared variables: tight coupling, service internal - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Process Composition

Process Composition

Page 2: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 2

Process Composition HierarchiesControl:Centralized control: e.g., RPC/WSDLMediated or orchestrated control: e.g., BPELFully distributed control: autonomous

processes, e.g., WS-CDL (WSCI)Messaging:Shared variables: tight coupling, service

internalSynchronous messaging: looser coupling; some

service-service interactionsAsynchronous messaging: loose coupling;

service-service interactions Synchronous and asynchronous both applicable to

BPEL:WSDL/SOAP, WSDL/JMS

Page 3: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 3

Communicating Sequential Processes

Mathematical framework for the description and analysis of systems consisting of processes interacting via exchange of messages

The evolution of processes is based on a sequence of events or actions

Visible actions

Interaction with other processes, communication

Invisible actionInternal computation steps

Page 4: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 4

The CSP Language: Syntax Termination: Stop Input: in ? x P(x)

Execute an input action on channel in, get message x, then continue as P(x)

Output: out ! x P(x)Execute an output action on channel out, send

message x, then continue as P(x) Recursion: P(y1,…,yn) = Body(y1,…,yn)

Process definition. P is a process name, y1,…,yn are the parameters, Body(y1,…,yn) is a process expression

Example: Copy = in ? x out ! m Copy

Page 5: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 5

CSP’s Syntax (Cont’ed)

External (aka guarded) choice: P QExecute a choice between P and Q. Do not

choose a process which cannot proceed Example: a ? x Px (b ? x Q(x))

Execute one and only one input action. If only one is available then choose that one. If both are available than choose arbitrarily. If none are available then block. The unchoosen branch is discarded

Internal choice: PQExecute an arbitrary choice between P and Q.

It is possible to choose a process which cannot proceed

Page 6: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 6

CSP’s Syntax (Cont’ed)

Parallel operator w/synchronization: P Q P and Q proceed in parallel and are obliged to

synchronize on all the common actions Example: c x Px c m Q

Synchronization: the two processes can proceed only if their actions correspond

Handshaking: sending and receiving is simultaneous (Buffered communication can anyway be modeled by implementing a buffer process)

Communication: m is transmitted to the first process, which continues as Pm

Page 7: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 7

Laws of CSP

Equivalence of expressions: useful in reasoning about CSP processes

Many laws concerning different aspects Examples:If Q does not involve e1:e1 P e2 Q

e1 P e2 QSynchronization:

c ? b Pb c ! a Q c ! a Pa Q

Page 8: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 8

Example

ADD2 in x iny outxyADD2ADD2 in x iny outxyADD2in y inx outxyADD2

SQ out z sqrsquarez SQADDSQ = ADD2 SQ = ? in x iny outxyADD2in y inx outxyADD2out z sqrsquarez SQ

in x iny outxyADD2out z sqrsquarez SQin y inx outxyADD2out z sqrsquarez SQ

Page 9: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 9

Example

ADDSQ in x iny outxyADD2out z sqrsquarez SQin y inx outxyADD2out z sqrsquarez SQ

in x iny outxyADD2out z sqrsquarez SQin y inx outxyADD2out z sqrsquarez SQ

inx inyoutxysqrsquarexy ADD2 SQ …

inx inyout xysqr squarexy ADDSQ …

Page 10: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 10

BPEL : CSP Semantics

BPEL interactions can be modeled in CSPThree main activities: invoke, receive, reply

<invoke partner=“...” portType=“...” operation=“...”

inputContainer= x outputContainer = y />

<receive partner=“...” portType=“...” operation=“...” container=x [createInstance=“...”] />

<reply partner=“...” portType=“...” operation=“...” container =y />

partner-port-in ! x partner-port-out ? y …

my-port-in ? x …

… my-port-out ? y …

Page 11: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 11

Synchronous communicationAdvantages:Easier to analyzeWell studied

Disadvantages:Not completely autonomous

BPEL : CSP Semantics

Page 12: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 12

The -Calculus

The -calculus is a process algebra Constructs for concurrency Communication on channels

channels are first-classchannel names can be sent on channels

access restrictions for channels In -calculus everything is a process

Page 13: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 13

Communications in -Calculus

Processes communicate on channels:

cM send message M on channel c cx receives x on channel c

Sequencing:

cMpsends message M on c, then does p

cxp receives x on c, then does p with x

Concurrency:

p q is the parallel composition of p and q Replication:

p creates an infinite number of replicas of p

Page 14: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 14

Examples

For example we might defineSpeakerairMPhone airxwirexATT wirexfiberxSystem Speaker Phone ATT

Communication between processes is modeled by reduction:Speaker Phone wireMwireM ATT fiberM

Composing these reductions we get:Speaker Phone ATT fiberM

Page 15: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 15

Channel Visibility

Anybody can monitor an unrestricted channel: Consider that we define

WireTap wirexwirexNSAxCopies the messages from the wire to NSAPossible since the name “wire” is globally

visible

NowWireTap wireMATT wireMNSAMATT NSAMfiberM

Page 16: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 16

Restriction

The restriction operator “c p” makes a fresh channel c within process p

is the Greek letter “nu”The name “c” is local (bound) in p

Restricted channels cannot be monitored wire x … wirewireM ATT

wire x … fiberM

The scope of the name “wire” is restricted There is no conflict with the global “wire”

Page 17: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 17

Restriction and Scope

Restrictionis a binding constructis lexically scopedallocates a new object (a channel)

c p is like “let c new Channel() in p”

In particular, c can be sent outside its scopeBut only if “p” decides so

Page 18: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 18

First-Class Channels

A channel c can leave its scope of declarationvia a message dc from within p

Allowing channels to be sent as messages means communication topology is dynamicIf channels are not sent as messages (or

stored in the heap) then the communication topology is static

This differentiates -calculus from CSP

Page 19: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 19

Example of First-Class Channels

Consider:MobilePhone airxcellxATT wirecell

ATT wireyyxfiberx

in cellMobilePhone ATTATT

ATT is trying to pass cell out of the static scope of the restriction cell

Page 20: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 20

Scope Extrusion

A channel is a nameFirst-class names must be usable even outside

their original scope

The -calculus allows restrictions to move: c p q cp q if c not free in q

Renaming is needed in general: c p q ddcp q

ddcp q where “d” is fresh (does not appear in p or q)

Page 21: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 21

Example, Continued

cellMobilePhone ATT ATT

cellMobilePhone ATT ATT)

cellMobilePhonecellxfiberx

Scope extrusion distinguishes the -calculus from other process calculi

Page 22: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 22

Syntax of the -Calculus

There are many versions of the -calculusA basic version:

p, q ::= nil nil process (sometimes written

0) xyp sending xyp receiving p q parallel composition p replication xp restriction

Note that only variables can be channels and messages

Page 23: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 23

Global modelEnsured conformance

Description languageNot executable

ToolsGenerators for end pointsAdvanced typing

StatusMoving for last call end of 2004

Choreography Definition Language (WS-CDL)

Page 24: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 24

Global Models

Page 25: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 25

A sequential processClient(open, close, request, reply) =

open.request1.reply1.request2.reply2.close.0

Clientopen

close

request

reply

WS-CDL Global Models

Page 26: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 26

A repetitive processClient (open, close, request, reply) =

open.request1.reply1.request2.reply2.close.Client(open, close, request, reply)

WS-CDL Global Models

Clientopen

close

request

reply

Page 27: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 27

A process with choices to makeIdleServer (o, req, rep, c) =

o.BusyServer(o, req, rep, close)BusyServer(o, req, rep, c) =

req.rep.BusyServer(o, req, rep, c) +c.IdleServer(o, req, rep, c)

IdleServeropen

BusyServerclose

request

reply

WS-CDL Global Models

Page 28: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 28

Communication, Concurrency and Replication

When Clienti hasstarted an exchangewith IdleServer

No other Clientj canthen communicatewith the server

Until Clienti has finishedand the server is onceagain IdleServer

WS-CDL Global Model

SYSTEM = (!Client | IdleServer)

Clienti | IdleServer

Clienti | BusyServer

Clientj | IdleServer

Clientj | BusyServer

…..

Page 29: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 29

Operation Notation Meaning

Prefix .p Sequence

Action a(y), ay Communication

Summation a(y).pb(x).qi.pi

Choice

Recursion p={…..}.p Repetition

Replication p Repetition

Composition

pq Concurrency

Restriction x p Encapsulation

Collapse send and receive into an

interact on channels

WS-CDL and the -Calculus

Page 30: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 30

Composition: Formal Semantics

WSDL is fundamentally message basedSo is everything based on it

Process algebra approach to formal semantics:BPEL : CSP WS-CDL : -calculus

Alternatives to process algebra:Automata theoreticPSL

Page 31: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 31

BPEL and Asynchronous Communication

Channels are assumed to be reliable Asynchronous, for example, the following channel:

ware-house1store order1

send Order1

o1

send Order1

receive Receipt1

Queues are FIFO, unbounded length Can simulate synchronous

and also bounded queues

Page 32: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 32

Messages

Messages are classified into classes Each class is associated with one channel

Each message class may have additional attributes which can carry the contents of messagesFor now, analysis involves no contentsResults immediately apply to “finite domain”

contents

ware-house1store

order1

Page 33: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 33

Individual Web Services

inputmessages

to othere-services

Do until halt nondeterministic choice: read an input; send an output to some other peer; halt; end choice

local storemessage log

Page 34: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 34

Individual Web Services

Again, ports and storages are ignored Internal logic of peers : finite state control

inputmessages

to othere-services

Do until halt nondeterministic choice: read an input; send an output to some other peer; halt; end choice

Page 35: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 35

Mealy Web Services

Mealy machines: Finite state machines with input (incoming messages) & output (outgoing messages)

warehouse2

?o2 !r2

!r2

!r2

!b2!b2

?p2?p2

Page 36: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 36

Technical Definition

A Mealy web service is an FSA M T, s, Fin, out,

T : a set of states s : the initial state F : a set of final states in : input message classes out : output message classes : transition relation that either

consume an input, sms, or

produce output, sms, or

make an empty (internal ) move, ss

Page 37: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 37

Executing a Mealy Composition

warehouse2

?o2 !r2

!r2

!r2

!b2!b2

?p2?p2

bank

?a

!k

store

!a

?k

!o2

w1

?o1

!o1

Execution halts ifAll mealy peers are in final statesAll queues are empty

Page 38: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 38

req

regack

?register

!reject

!accept!request

?ack?cancel

!bill

!terminate

!bill

!register

?reject

?accept

?report

!ack

!cancel?bill

?bill

Investor Stock Broker Firm

Research Dept.

accrep

Composite Web Service Execution

bil

ter?request

?terminate

!report

Page 39: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 39

Web Service Composition: What Now?authorize

ware-house1

ok

bill

2

paym

ent2

orde

r 1re

ceip

t 1

order2receipt

2

payment 1

bill 1

bank

ware-house2

store

Execution:Is there a deadlock?Always terminates in

finite steps?…

Functionality:Is it correct?Is there an unauthorized

payment?…

Page 40: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 40

Conversation Policies

A conversation: a sequence of messages between two parties

order

receiptStore Supplier

Start RequestPending

A’s ReplyPending

B’s ReplyPending

Terminate/Success

Terminate/Failure

AB: “Request bid”

AB: “CounterBid=x”

BA: “CounterBid=x”

AB: “Accept”

BA: “Reject”AB: “Reject”BA: “Accept”

BA: “Bid=x”BA: “Bye”

Page 41: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 41

order2

payment

1

bill 1

Multi-Party Conversations

Watcher: “records” the messages as they are sent

ok

authorize

receipt2

ord

er

1rece

ipt 1

bill2

paym

en

t 2

Watcher

ware-house2

ware-house1

store bank

a k o1 b1o2

A conversation is a sequence of messages the watcher sees in a successful run (or session)

composition language: the set of all possible conversations

What properties do composition languages have?

p1r1 r2 b2

p2

Page 42: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 42

Warehouse Example

The composition language recognized

a k shuff o1shuff r1b1p1 o2shuff r2b2p2

authorize

ware-house1

ok

bill

2

paym

ent2

ord

er1

rece

ipt 1

order2receipt

2

payment

1 bill 1

bank

ware-house2

store

Page 43: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 43

A composition schema is a triple (M, P, C ) whereM : finite set of message classesP : finite set of peers (web services)C : finite set of peer to peer channels

Specifies the infrastructure of composition

Web Service Composition Schema

authorize

ware-house1

ok

bill

2

paym

ent2

ord

er1

rece

ipt 1

order2receipt

2

payment

1 bill 1

bank

ware-house2

store

Page 44: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 44

Global Configurations

Given n Mealy implementationsfor composition schema MPC

Global configuration: Qt… Qntnwwhere

Qi : queue contents for peer i

ti : state for peer iw : watcher contents

Page 45: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 45

Derivation

QtQntnwQtQntnw if

peer pi takes an move, or

peer pi reads an input, or

peer pi sends a message m to pj

timtii

Qj Qj m (m appended to pj’s queue)

k itk tk

k j Qk Qk

w wm (watcher records the message m)

Page 46: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 46

Conversations

A halting run: ssnffn

wStarting from the initial configuration with

empty queues and Ending in final states with empty queues

A word w is a conversation if ssnffnw

is a halting run

Composition language (CL) :the set of all conversations

*

Page 47: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 47

Composition Languages Are Regular?

?b!a

p1 p2

?a

!b

a

b

CL a*b* anbn

Composition languages are not always regular Some may not even be context free Causes: asynchronous communication &

unbounded queue Bounded queues or synchronous: CL always

regular

Page 48: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 48

Bounded Queues

Synchronous messaging case: composition language can be recognized by the product machine

If queues are bounded, composition languages are also regularProduction machines can be constructed

Page 49: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 49

Conversations as Orchestration

ac

“Programming” interactions Two questions:

Given Mealy peers, what conversations can they have?

Given a conversation language, can we “implement” it?

p1

bd

p3

p4

e

p2

Page 50: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 50

Two Factors

ac

Local views: Conversations with the same local views are not distinguishable: abcde and acbde

Queuing effect: a peer can postpone sending a message

p1

bd

p3

p4

e

p2

Page 51: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 51

Local view of a conversation for a peer: part of the execution that is related to the peer

Defined as projection: pw for a conversation w

Two conversations cannot be distinguished if they have exactly the same set of local views

Local Views

Page 52: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 52

If abc is a part of a conversation, so are bac and bca

piabcpi

bacpi bcaa for i

piabcpi

bacpi bcabc for i

Example

a p2p1bc

p4p3

Page 53: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 53

Given languages Li over i, i n

Composition languages L are closed under“projection-join”:

Join

LL )(πpeerpeers

*)(π,1 iiiii LwniwLi

Page 54: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 54

If the global watcher sees:

What happens inside p?

Local Prepone

a peer

!a!b

ba ……

p

Page 55: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 55

Local Prepone

pw should also allow

a peer p

!a!b

… a b …

local view at p…

)(π wp

ab ……

ba ……the global watcher:

Page 56: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 56

A Synthesis Result

Given a regular language L, we can find a Mealy composition such that its CL is the closure:

))((πneLocalPrepo peer*

peers L

Intuitively: given a regular L (e.g., ako1…), we can find Mealy peers whose conversations are not arbitraryOpportunity for automatic composition

But some Mealy compositions do not relate to any regular languages in this way

Page 57: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 57

p1

The Converse (General Case)

There is an Mealy compositions whose CL is not

for every regular languages L

))((πneLocalPrepo peer*

peers L

a

b

?a

!cp2

!b

!a p3?c

?b

c

CL = { aibci | i 0 }

Page 58: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 58

When the schema graph is a tree, then the Mealy composition has a composition language equal to

for some regular languages L

Intuitively: the global behavior of bottom-up composition is still predictable if the composition infrastructure is a treeIn particular, adding an mediator (hub-

spoke) isn’t a bad idea!

The Tree Case

))((πneLocalPrepo peer*

peers L

Page 59: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 59

Hub-and-spoke

For every star-shaped composition schema, and every regular language L, we can construct an Mealy composition whose CL L

Good news for hub-and-spoke!

Page 60: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 60

Results of Mealy Web Services

1. CLs of some Mealy compositions are not regular,some not context free

2. The “prepone” and “join” closure of every regular language = CL of some composite Mealy web services

3. The converse of 2. is not true in general, true in special cases However: if bounded queue or synchronous:CL of every Mealy composition is regular

Design time decision! Need to be explicit in specifications (BPEL4WS, BPLM, …)

Page 61: Process Composition

Web Services: CSP/Pi-Calculus/Mealy 61

Communicating FSAs

Two communicating FSAs can simulate Turing machines

a0 a1 aq …

p1 p2

b0 b1 bq …