Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Jini Transaction Part II Daniel Müller Marcel Ziswiler Seminar Informations- & Kommunikationssysteme.

Similar presentations


Presentation on theme: "1 Jini Transaction Part II Daniel Müller Marcel Ziswiler Seminar Informations- & Kommunikationssysteme."— Presentation transcript:

1 1 Jini Transaction Part II Daniel Müller Marcel Ziswiler Seminar Informations- & Kommunikationssysteme

2 2 Overview ACID 2 Phase Commit Mahalo Jini Transaction & JavaSpaces References Seminar Informations- & KommunikationssystemeDaniel Müller

3 3 ACID Atomicity Consistency Isolation Durability Seminar Informations- & KommunikationssystemeDaniel Müller ACID 2 Phase Commit Mahalo Jini Transaction & JavaSpaces References

4 4 All operations of a transaction occur or none of them! T = (a := a+5; b := b+3) Atomicity Seminar Informations- & KommunikationssystemeDaniel Müller Atomicity Consistency Isolation Durability ACID T = (a := a+5; => Two Phase Commit

5 5 Consistency Semantic Not supported ! –Outside of the realm of the transaction itself Transaction = Tool to allow consistency guarantees Transaction = A guarantor of consistency Seminar Informations- & KommunikationssystemeDaniel Müller Atomicity Consistency Isolation Durability ACID

6 6 Isolation Ongoing transactions should not affect each other –Not supported ! Seminar Informations- & KommunikationssystemeDaniel Müller Atomicity Consistency Isolation Durability ACID

7 7 Durability The result should be persistent –Not supported ! Durability is a commitment but Not a guarantee ! It depends on the application how durable data has to be Seminar Informations- & KommunikationssystemeDaniel Müller Atomicity Consistency Isolation Durability ACID

8 8 Two Phase Commit Problem Transaction States Client’s View Participant’s View Transaction Manager’s View Exceptions PrepareAndCommit Seminar Informations- & KommunikationssystemeDaniel Müller ACID 2 Phase Commit Mahalo Jini Transaction & JavaSpaces References

9 9 Problem Treat a transaction as a single atomic unit All operations of the transaction succeed or fail No partial failures Two Phase Commit Protocol Can be used in more than traditional transaction systems Seminar Informations- & KommunikationssystemeDaniel Müller Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit Two Phase Commit

10 10 Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit Transaction States Constants defined for the communication between managers & participants public interface TransactionConstants { int ACTIVE = 1; int VOTING = 2; int PREPARED = 3; int NOTCHANCHED = 4; int COMMITED = 5; int ABORTED = 6; } Seminar Informations- & KommunikationssystemeDaniel Müller Two Phase Commit

11 11 Client’s View I Seminar Informations- & KommunikationssystemeDaniel Müller ACTIVECOMMITEDVOTING ABORTED otherwise commit abort participant ABORTED create returns cleanup Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit Two Phase Commit

12 12 Client’s View II create()  ACTIVE commit()  VOTING abort()  ABORTED Cancel the lease  ABORTED Expire the lease  ABORTED Seminar Informations- & KommunikationssystemeDaniel Müller

13 13 Participant’s View I Seminar Informations- & KommunikationssystemeDaniel Müller ACTIVEVOTING abort cleanup NOTCHANGED COMMITED PREPARED ABORTED join returns commit abort prepare Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit Two Phase Commit

14 14 Participant’s View II join()  ACTIVE prepare()  VOTING –Decide to return one of the following states NOTCHANGED: read-only (no changes in the state) PREPARED: changes made & able to roll forward ABORTED: changes made but can’t guarantee to roll forward Seminar Informations- & KommunikationssystemeDaniel Müller

15 15 Participant’s View III PREPARED & commit()  COMMITED abort()  ABORTED request the state of the transaction manager int getState(long id);  Crash Recovery Seminar Informations- & KommunikationssystemeDaniel Müller

16 16 Transaction Manager’s View I Seminar Informations- & KommunikationssystemeDaniel Müller ACTIVEVOTING abort cleanup COMMITED ABORTED create returns participant ABORTED or timeout otherwise commit Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit Two Phase Commit

17 17 Transaction Manager’s View II create()  ACTIVE commit()  VOTING Invoke prepare() of all participants –One participant votes ABORTED  ABORTED –A participant votes NOTCHANGED  Dropped as participant –No one ABORTED & at least one PREPARED  COMMITED abort()  ABORTED Lease cancelled  ABORTED Lease expired  ABORTED Seminar Informations- & KommunikationssystemeDaniel Müller

18 18 Exceptions UnknownTransactionException –Incorrect transaction ID –Transaction already cleaned up CannotCommitException –Transaction already ABORTED or COMMITED CannotAbortException –Transaction already COMMITED TimeoutExpiredException –Wasn’t able to notify all participants in a given time Seminar Informations- & KommunikationssystemeDaniel Müller Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit Two Phase Commit

19 19 prepareAnd Commit I Optimisation / Elimination of the VOTING state Only one single participant Only one single participant to prepare() and all others already returned NOTCHANGED Seminar Informations- & KommunikationssystemeDaniel Müller Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit Two Phase Commit

20 20 prepareAndCommit II public int prepareAndCommit(TransactionManager mgr, long id) throws UnknownTransactionException, RemoteException { int result = prepare(mgr, id); if (result == PREPARED) { commit(mgr, id); result = COMMITED; } return result; } Seminar Informations- & KommunikationssystemeDaniel Müller

21 21 Mahalo Transaction engine in Sun’s distribution of Jini, as an implementation of a simple transaction manager An activatable service; it means that it runs under the control of rmid (RMI daemon) Seminar Informations- & KommunikationssystemeDaniel Müller ACID 2 Phase Commit Mahalo Jini Transaction & JavaSpaces References

22 22 Jini Transactions & JavaSpaces Problem Example Solution Entries under a transaction ACID revisited Seminar Informations- & KommunikationssystemeDaniel Müller ACID 2 Phase Commit Mahalo Jini Transaction & JavaSpaces References

23 23 Problem Tool for dealing with partial failure Transactions provide a means of enforcing consistency over a set of (one or more) space-based operations –Consistency: bundle operations together Either all complete or none of them Seminar Informations- & KommunikationssystemeDaniel Müller Problem Example Solution Entries under a transaction ACID revisited JavaSpaces

24 24 Example: Web Counter Problem: Counter lost Seminar Informations- & KommunikationssystemeDaniel Müller Problem Example Solution Entries under a transaction ACID revisited JavaSpaces Visit a web page Applet takes a page count entry Increments its value Writes it back into the page

25 25 Solution take & write under a Transaction –.. Transaction txn = trc.transaction; counter = space.take(tmp, txn, Long); counter.increment(); space.write(counter, txn, Lease);.. Seminar Informations- & KommunikationssystemeDaniel Müller Problem Example Solution Entries under a transaction ACID revisited JavaSpaces

26 26 Entries under a Transaction write  entry is only seen within the transaction until it commits read  a entry once read, cannot be taken afterwards, within the same transaction readIfExists  If an entry is taken by another transaction then wait for its return take  removes en entry temporarily from the space Seminar Informations- & KommunikationssystemeDaniel Müller Problem Example Solution Entries under a transaction ACID revisited JavaSpaces

27 27 ACID Revisited Atomicity Consistency Isolation Durability Seminar Informations- & KommunikationssystemeDaniel Müller Problem Example Solution Entries under a transaction ACID revisited JavaSpaces

28 28 Atomicity Two Phase Commit All operations occur ore non of them –Both: Counter was removed from and returned to the space –None:Counter was effectively never removed Operations are read, write, take, notify Seminar Informations- & KommunikationssystemeDaniel Müller Atomicity Consistency Isolation Durability ACID

29 29 Consistency Changes do not violate the correctness of the state within the space Program / Algorithm has to be correct –take and write the counter –increment the value by one Seminar Informations- & KommunikationssystemeDaniel Müller Atomicity Consistency Isolation Durability ACID

30 30 Isolation Two transactions should not affect each other –take removes the entry temporarily Deadlock ? Seminar Informations- & KommunikationssystemeDaniel Müller Atomicity Consistency Isolation Durability ACID

31 31 Durability After commit, changes to a space will survive failures Problem of the space, not the transaction Seminar Informations- & KommunikationssystemeDaniel Müller Atomicity Consistency Isolation Durability ACID

32 32 References Sun Inc., Jini Technology core platform specification, Version 1.1, Oct. 2000, http://www.sun.com/jini/specs/core1_1.pdf Scott Oaks & Henry Wong, Jini in a Nutshell, O’Reilly, 2000, http://www.oreilly.com/catalog/jininut Jan Newmarch, University of Canberra, http://pandonia.canberra.edu.au/java/jini/tutorial Eric Freeman, Susanne Hupfer, Ken Arnold, JavaSpaces principles, patterns, and practice, Addison Wesley, 1999, http://204.179.152.61/book/0,3828,0201309556,00.html Seminar Informations- & KommunikationssystemeDaniel Müller ACID 2 Phase Commit Mahalo Jini Transaction & JavaSpaces References


Download ppt "1 Jini Transaction Part II Daniel Müller Marcel Ziswiler Seminar Informations- & Kommunikationssysteme."

Similar presentations


Ads by Google