1 / 32

Jini Transaction Part II

Jini Transaction Part II. Daniel Müller Marcel Ziswiler. Seminar Informations- & Kommunikationssysteme. Overview. ACID 2 Phase Commit Mahalo Jini Transaction & JavaSpaces References. Daniel M üller. Seminar Informations- & Kommunikationssysteme. ACID 2 Phase Commit Mahalo

xuxa
Download Presentation

Jini Transaction Part II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Overview • ACID • 2 Phase Commit • Mahalo • Jini Transaction & JavaSpaces • References Daniel Müller Seminar Informations- & Kommunikationssysteme

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

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

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

  6. ACID Atomicity Consistency Isolation Durability Isolation • Ongoing transactions should not affect each other • Not supported ! Daniel Müller Seminar Informations- & Kommunikationssysteme

  7. ACID Atomicity Consistency Isolation Durability 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 Daniel Müller Seminar Informations- & Kommunikationssysteme

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

  9. Two Phase Commit Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit 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 Daniel Müller Seminar Informations- & Kommunikationssysteme

  10. Two Phase Commit Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit TransactionStates • 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; } Daniel Müller Seminar Informations- & Kommunikationssysteme

  11. Two Phase Commit Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit Client’sView I ACTIVE create returns otherwise commit VOTING COMMITED participant ABORTED abort cleanup ABORTED Daniel Müller Seminar Informations- & Kommunikationssysteme

  12. Client’sView II • create()  ACTIVE • commit()  VOTING • abort()  ABORTED • Cancel the lease ABORTED • Expire the lease ABORTED Daniel Müller Seminar Informations- & Kommunikationssysteme

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

  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 Daniel Müller Seminar Informations- & Kommunikationssysteme

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

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

  17. TransactionManager’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 Daniel Müller Seminar Informations- & Kommunikationssysteme

  18. Two Phase Commit Problem Transaction States Client’ View Participant’ s View Transaction Manager’s View Exceptions PrepareAndCommit 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 Daniel Müller Seminar Informations- & Kommunikationssysteme

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

  20. prepareAndCommitII 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; } Daniel Müller Seminar Informations- & Kommunikationssysteme

  21. ACID 2 Phase Commit Mahalo Jini Transaction & JavaSpaces References 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) Daniel Müller Seminar Informations- & Kommunikationssysteme

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

  23. JavaSpaces Problem Example Solution Entries under a transaction ACID revisited 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 Daniel Müller Seminar Informations- & Kommunikationssysteme

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

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

  26. JavaSpaces Problem Example Solution Entries under a transaction ACID revisited 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 Daniel Müller Seminar Informations- & Kommunikationssysteme

  27. JavaSpaces Problem Example Solution Entries under a transaction ACID revisited ACIDRevisited • Atomicity • Consistency • Isolation • Durability Daniel Müller Seminar Informations- & Kommunikationssysteme

  28. ACID Atomicity Consistency Isolation Durability 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 Daniel Müller Seminar Informations- & Kommunikationssysteme

  29. ACID Atomicity Consistency Isolation Durability 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 Daniel Müller Seminar Informations- & Kommunikationssysteme

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

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

  32. ACID 2 Phase Commit Mahalo Jini Transaction & JavaSpaces References 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 Daniel Müller Seminar Informations- & Kommunikationssysteme

More Related