comparison src/org/dancres/blitz/notify/SeqNumInterval.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.notify;
2
3 import java.io.IOException;
4 import java.io.Serializable;
5
6 import java.util.logging.Level;
7
8 import org.dancres.blitz.txn.TxnState;
9 import org.dancres.blitz.txn.TxnOp;
10
11 import org.dancres.blitz.disk.DiskTxn;
12
13 import org.dancres.blitz.oid.OID;
14
15 import org.dancres.blitz.meta.RegistryFactory;
16 import org.dancres.blitz.meta.Registry;
17
18 /**
19 Log action which restores a snapshotted sequence number to an event
20 generator. Rather than save an update to disk for each event we generate,
21 we log a single change record after a fixed number of events have been
22 dispatched. In this way, we reduce I/O's and can still keep the
23 EventGenerator sequence number up-to-date. Note that in the case of
24 restore from log, a <code>RemoteEventListener</code> will likely see a
25 slightly bigger jump than it might expect - that's okay. Note also that
26 such restarts will "eat up" a few sequence numbers (i.e. they will never
27 be used on a RemoteEvent) - that's okay too.
28 */
29 class SeqNumInterval implements TxnOp {
30 private OID theOID;
31 private long theSeqNum;
32
33 SeqNumInterval(OID aOID, long aSeqNum) {
34 theOID = aOID;
35 theSeqNum = aSeqNum;
36 }
37
38 public void commit(TxnState aState) throws IOException {
39 // Nothing to do, we're just recording state
40 }
41
42 public void abort(TxnState aState) throws IOException {
43 // Nothing to do, we're just recording state
44 }
45
46 public void restore(TxnState aState) throws IOException {
47 EventQueue.theLogger.log(Level.FINE, "Patching notify reg" +
48 theOID + ", " + theSeqNum);
49
50 EventGeneratorFactory.get().recover(theOID, theSeqNum);
51 }
52
53 public String toString() {
54 return " SN : " + theOID + " : " + theSeqNum;
55 }
56 }