comparison test/org/dancres/blitz/txn/TestCkpt.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.txn;
2
3 import net.jini.core.entry.Entry;
4 import net.jini.core.lease.Lease;
5
6 import net.jini.core.transaction.*;
7 import net.jini.core.transaction.server.*;
8
9 import org.dancres.blitz.remote.LocalSpace;
10
11 import org.dancres.blitz.test.DummyEntry;
12 import org.dancres.blitz.test.TxnMgr;
13
14 /**
15 Delete all state and ensure that the config is setup for persistent logging.
16 Then run the test once with no arguments. On exit, Blitz should report
17 that one transaction was active and that there were no entry's. Rerun
18 the test with an argument of "true" or whatever and a single transaction
19 should be restored from log which will then be commited in the second
20 run resulting in a DummyEntry appearing - i.e. instance count should be
21 one.
22 */
23 public class TestCkpt {
24 public static void main(String args[]) {
25 try {
26 if (args.length == 0)
27 new TestCkpt().test(false);
28 else
29 new TestCkpt().test(true);
30
31 } catch (Exception anE) {
32 anE.printStackTrace(System.err);
33 }
34 }
35
36 public void test(boolean isRestart) throws Exception {
37
38 LocalSpace mySpace = new LocalSpace(new TxnGatewayImpl());
39
40 TxnMgr myMgr = new TxnMgr(1, mySpace);
41
42 ServerTransaction myTxn = myMgr.newTxn();
43
44 if (isRestart) {
45 myTxn.commit();
46 } else {
47 Entry myTemplate = new DummyEntry("rhubarb");
48
49 mySpace.getProxy().write(myTemplate, myTxn, Lease.FOREVER);
50
51 myTxn.commit();
52
53 TxnManager.get().requestAsyncCheckpoint();
54 }
55
56 mySpace.stop();
57 }
58
59 private static class TxnGatewayImpl implements TxnGateway {
60 public int getState(TxnId anId) {
61 return TransactionConstants.COMMITTED;
62 }
63
64 public void join(TxnId anId) {
65 }
66 }
67 }