The Zero-ETL Approach: Enhancing Data Agility and Insight
Summary and implementation of a process calculi for long running transactions
1. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Summary and implementation of a process
calculi for long running transactions
Alex Prut1
1Universit`a degli Studi di Udine
Dipartimento di Scienze Matematiche, Informatiche e Fisiche
Concurrency Theory, 15 July 2016
2. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Presentation based on the work I
R. Bruni. G. Ferrari. H. Melgratti. U. Montanari.
From Theory to Practice in Transactional Composition
of Web Services.
2005
R. Bruni. H. Melgratti. U. Montanari.
Theoretical Foundations for Compensations in Flow
Services Composition Languages.
2005
3. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Outline
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional Web Services
4. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Web Services (WS)
Choreography
Orchestration
5. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
ACID
Atomicity: requires that each transaction be ”all or
nothing”
Consistency: ensures that any transaction will bring the
database from one valid state to another
Isolation : ensures that the concurrent execution of
transactions results in a system state that would be
obtained if transactions were executed serially
Durability : ensures that once a transaction has been
committed, it will remain so, even in the event of power
loss
6. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Long-running transactions (LRTs)
Long-running transactions: (also known as Saga) are
computer database transactions that avoid locks on
non-local resources, use compensation to handle failures
a LRT is a saga if it can be written as a sequence of
transactions that can be interleaved with other
transactions
relax Isolation property, keep strong Atomicity,
Consistency, Durability properties
use compensations
Hector Garcia-Molina Kenneth Salem.
Sagas.
1987
7. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Transactions with compensation
A1 ÷ B1; A2 ÷ B2; A3 ÷ B3
success : A1; A2; A3
failure with success (undo activities) : A1; A2; B1
forward flow : A1; A2; A3
backward flow: B3; B2; B1
8. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Problem
varie linguaggi per l’orchestrazione di WS (XLANG,
BPML, ...): purtroppo forniscono una sintassi formale e
non una semantica formale
poca attenzione: Join calculus, πt-calculus, ...
Sagas Calculus: perch`e astrae dal basso livello di
computazione e communicazione e si focalizza sulla
struttura composizionale ad alto livello di processi
transazionali
9. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Goals
Provide a formal framework for isolating and studying
LRTs (Sagas Calculus, Naive Sagas)
Provide a framework for implementing a WS scenario
(JTWS)
R. Bruni. G. Ferrari. H. Melgratti. U. Montanari.
From Theory to Practice in Transactional Composition
of Web Services.
2005
10. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Goals and Introduction
fornire una semantica per un insieme di linguaggi
transazionali generici con espressivit`a aumentante
inizialmente una formalizzazione di un linguaggio per la
composizione di attivit`a atomiche in sequenza
successivamente estendere il linguaggio e fornire una
semantica per la composizione di attivit`a atomiche in
parallelo
discussione di varie alternative e future possibili
estensioni
R. Bruni. H. Melgratti. U. Montanari.
Theoretical Foundations for Compensations in Flow
Services Composition Languages.
2005
11. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Outline
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional Web Services
12. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Sequential Sagas
an infinite set A of names for atomic activities, ranged
over by A, B...
nil activity 0 ∈ A that always completes and has no
effect
13. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Sequential Sagas
Structural congruence
14. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Big Step Semantics
R = { , , } the set of possible results for the
execution of a saga, ∈ R
for commit
for abort (compensated)
for abnormal termination
15. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Big Step Semantics
Context / Scenario
we are not interested on the low level behaviour of
individual tasks, we rely on the abstract description of
their execution, stating wheter they complete
successfully or abort
This information is given by a context Γ
Γ : A → { , } is a partial function over A
we denote a particular function Γ as
A1 → 1, · · · , An → n where Ai = Aj for all i = j
16. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Big Step Semantics
Γ S →α denotes that the execution of S produces
when the atomic activities behave like Γ
the observation flow α describes the actual flow
Γ P, β →α , β describes the behavior of a
process P within a saga that already installed the
compensation β
Figure: Semantics of sequential sagas: inference rules
17. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Sequential Sagas
Adequacy Theorem
18. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Outline
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional Web Services
19. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Parallel Sagas
the language of sequential sagas is extended with the
operator |
20. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Parallel Sagas
Naive Semantics of parallel composition
21. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Parallel Sagas
Example
S ≡ {A1 ÷ B1; A2 ÷ B2|C1 ÷ D1}
Γ = A1 → , A2 → , C1 → , B1 → , B2 →
α = (A1; A2|0); B2; B1
22. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Outline
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional Web Services
23. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Naive Sagas: Syntax
build over a set of atomic activities Σ ∪ {0, THROW },
ranged over A, B...
0 is the nil activity
THROWS is the interrupting activity
24. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Naive Sagas: Semantics
Semantics is defined in terms of admissible execution
traces
a trace for a saga is a string s ω , where s ∈ Σ∗ is said
the observable flow and ω ∈ Ω is the final event
Ω = { , !, ?} ( stands for success, ! for failure, ? for
yielding to a concurrent interrupt)
hereafter, we let p, q, r range over Σ∗ and s, t range
over the set of traces Σ∗Ω
The set of traces is evaluated according to a scenario
Γ : Σ → { , !}
Γ S = S if S and S represent the same set of traces
under the scenario Γ
Γ s ∈ S ifthe set of traces associated to S under the
scenario Γ includes s
25. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Naive Sagas: Semantics
Composition of Standard Traces
26. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Naive Sagas: Semantics
Traces of Naive Sagas
(p ω , s) where p ω is the forward trace and s is the
corresponding compensation trace
27. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Naive Sagas: Semantics
Composition of Compensable Traces
28. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Naive Sagas: Semantics
Traces of Compensable Processes
29. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Example
Handling Purchase Orders
HPOsaga = [A.O. ÷ R.O.; (U.C. ÷ R.M.|P.O. ÷ U.S.)]
Γ HPOsaga =
{ A.O., U.C., P.O., , A.O., P.O., U.C., }
Γ HPOsaga = { A.O., P.O., U.S., R.O., }
Γ2 HPOsaga = { A.O., P.O., ! }
30. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Naive Sagas: Equivalences
31. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Outline
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional Web Services
32. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Java Transactional Web Services (JTWS)
A Java implementation on Naive Sagas
Java Transactional Web Services (JTWS) = Java Signal
Core Layer (JSCL) + Java Transactional Layer (JTS)
Java Signal Code Layer: fornisce delle primitive per la
gestione dei segnali
Java Transactional Layer: definisce le primitive per le
transazioni
WS becomes JTWS components by exchaning signals
Publish / Subscribe pattern
33. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Java Signal Core Layer (JSCL)
Provide primitive mechanisms for defining and
exchanging signals among gates
Signal: an event that occurs on a given gate
Handlers: must subscribe to a signal
Emitters: generate signals
Signal class: (defines signals, carry some internal
information) (getParam, setParamValue, id)
Communication by means of I/O ports
Ports connectec through links
e.createLink(t, h), h = handler, t = type of the link, e
= emitter
e.emitSignal
34. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Gates
JTWS components are called gates
comp(A, B)
API class: AtomicTask
35. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Java Transactional Layer (JTL)
specialisation of JSCL focused on describing the
transactional aspects related to the forward and
backward flow across gates
Signals: Forward, Commit, Rollback, Exception
API Classes: TransactionalSequence,
TransactionalParallel, TransactionalComponent
(onForward, onCommit, onException, onRollback
methods)
36. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Mapping Naive sagas in JTWS
1) Signals representing the states of the transaction
2) atomic tasks represent atomic activities of Naive
Sagas
3) transactional generic gates corresponding to sagas
Exception signal implement !
Rollaback, Commit implements
NB: we assume that signal emission do not fail
37. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Gates for sequential composition of sagas
seq(P, Q)
A, B atomic tasks
A starts execution when a Forward signal is received on
in port
38. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
GenericTransactionalGate class
39. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Gates for parallel composition of sagas
par(P, Q)
use Collector, Trigger as auxiliary gates
3 scenario: (Commit, Rollback, Exception)
closure(P)
40. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Naive Sagas to JTWS mapping
41. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Complete Example
[RecSMS ÷ SMSErr; LocUser; SearchTC; MakeCall]
42. Summary and
implementation of
a process calculi
for long running
transactions
Alex Prut
Introduction
Background
Sagas Calculus
Sequential Sagas
Parallel Sagas
Naive Sagas
Implementation
Java Transactional
Web Services
Summary
Summary
a visual/graphical representation of parallel sagas
a process calculus description in bijective
correspondence with sagas diagrams
an executable, distributed translation of symbolic
processes
Future work: implement nested transactions and other
features