Mercurial > hg > blitz_condensed
comparison src/org/dancres/blitz/TxnControlImpl.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz; | |
2 | |
3 import java.io.IOException; | |
4 import java.io.Serializable; | |
5 | |
6 import java.rmi.RemoteException; | |
7 | |
8 import net.jini.core.transaction.server.TransactionManager; | |
9 import net.jini.core.transaction.UnknownTransactionException; | |
10 import net.jini.core.transaction.TransactionException; | |
11 | |
12 import org.dancres.blitz.txn.TxnState; | |
13 import org.dancres.blitz.txn.TxnManager; | |
14 | |
15 /** | |
16 All of this could be done in-line within SpaceImpl this just keeps | |
17 the method count down and separates the code a little. Responsible | |
18 for handling external requests against transactions and dispatching | |
19 to the appropriate internal objects. | |
20 | |
21 @todo Serializable here is naughty and strictly to facilitate unit tests | |
22 via TxnMgr class. | |
23 */ | |
24 class TxnControlImpl implements TxnControl, Serializable { | |
25 | |
26 public int prepare(TransactionManager aMgr, long anId) | |
27 throws UnknownTransactionException, RemoteException { | |
28 | |
29 TxnManager myManager = TxnManager.get(); | |
30 | |
31 TxnState myState = myManager.getTxnFor(aMgr, anId); | |
32 | |
33 return myManager.prepare(myState); | |
34 } | |
35 | |
36 public void commit(TransactionManager aMgr, long anId) | |
37 throws UnknownTransactionException, RemoteException { | |
38 | |
39 TxnManager myManager = TxnManager.get(); | |
40 | |
41 TxnState myState = myManager.getTxnFor(aMgr, anId); | |
42 | |
43 myManager.commit(myState); | |
44 } | |
45 | |
46 public void abort(TransactionManager aMgr, long anId) | |
47 throws UnknownTransactionException, RemoteException { | |
48 | |
49 TxnManager myManager = TxnManager.get(); | |
50 | |
51 TxnState myState = myManager.getTxnFor(aMgr, anId); | |
52 | |
53 myManager.abort(myState); | |
54 } | |
55 | |
56 public int prepareAndCommit(TransactionManager aMgr, long anId) | |
57 throws UnknownTransactionException, RemoteException { | |
58 | |
59 TxnManager myManager = TxnManager.get(); | |
60 | |
61 TxnState myState = myManager.getTxnFor(aMgr, anId); | |
62 | |
63 return myManager.prepareAndCommit(myState); | |
64 } | |
65 | |
66 public void requestSnapshot() throws TransactionException, IOException { | |
67 TxnManager.get().requestSnapshot(); | |
68 } | |
69 | |
70 public void backup(String aDir) throws IOException { | |
71 TxnManager.get().hotBackup(aDir); | |
72 } | |
73 } |