Mercurial > hg > blitz_condensed
comparison src/org/dancres/blitz/txn/TimeBarrierPersonality.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 | 4580bb12db30 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.txn; | |
2 | |
3 import java.util.logging.Level; | |
4 | |
5 import org.prevayler.implementation.SnapshotPrevayler; | |
6 import org.prevayler.implementation.BufferingPrevaylerImpl; | |
7 import org.prevayler.implementation.SnapshotPrevaylerImpl; | |
8 | |
9 import org.prevayler.PrevalentSystem; | |
10 | |
11 import org.dancres.blitz.config.TimeBarrierPersistent; | |
12 | |
13 import org.dancres.blitz.disk.Disk; | |
14 | |
15 /** | |
16 Understands how to translate TimeBarrierPersistent into core component | |
17 configuration. | |
18 | |
19 @see org.dancres.blitz.config.TimeBarrierPersistent | |
20 */ | |
21 class TimeBarrierPersonality implements StoragePersonality { | |
22 private TimeBarrierPersistent theModel; | |
23 private String theLogDir; | |
24 | |
25 TimeBarrierPersonality(TimeBarrierPersistent aModel, String aLogDir) { | |
26 theModel = aModel; | |
27 theLogDir = aLogDir; | |
28 | |
29 TxnManager.theLogger.log(Level.INFO, "TimeBarrierPersonality"); | |
30 | |
31 TxnManager.theLogger.log(Level.INFO, "Max logs before sync: " + | |
32 theModel.getMaxLogsBeforeSync()); | |
33 TxnManager.theLogger.log(Level.INFO, "Reset log stream: " + | |
34 theModel.shouldResetLogStream()); | |
35 | |
36 if (theModel.shouldCleanLogs()) { | |
37 TxnManager.theLogger.log(Level.WARNING, | |
38 "*** Automatically cleaning logs *** [EXPERIMENTAL]"); | |
39 } | |
40 | |
41 Disk.init(); | |
42 } | |
43 | |
44 public CheckpointTrigger getCheckpointTrigger(Checkpointer aCheckpointer) { | |
45 /* | |
46 return | |
47 new OpCountingCheckpointTrigger(aCheckpointer, | |
48 theModel.getMaxLogsBeforeSync()); | |
49 */ | |
50 return | |
51 new TimeoutCheckpointTrigger(aCheckpointer, | |
52 theModel.getMaxLogsBeforeSync(), theModel.getFlushTime()); | |
53 } | |
54 | |
55 public SnapshotPrevayler getPrevayler(PrevalentSystem aSystem) | |
56 throws Exception { | |
57 | |
58 PersistentReboot myReboot = new PersistentReboot(theModel); | |
59 myReboot.execute(); | |
60 | |
61 SnapshotPrevayler myPrevayler = | |
62 new BufferingPrevaylerImpl(aSystem, theLogDir, | |
63 theModel.shouldResetLogStream(), | |
64 theModel.shouldCleanLogs(), | |
65 theModel.getLogBufferSize()); | |
66 | |
67 return myPrevayler; | |
68 } | |
69 | |
70 public void destroy() { | |
71 Disk.destroy(); | |
72 Disk.clean(theLogDir); | |
73 } | |
74 } |