view src/org/dancres/blitz/notify/SequenceJumpRecord.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
line wrap: on
line source

package org.dancres.blitz.notify;

import java.io.IOException;

import org.dancres.blitz.txn.TxnOp;
import org.dancres.blitz.txn.TxnState;

import org.dancres.blitz.oid.OID;

/**
   An instance of this class is saved to the log whenever we apply a
   restart jump to an EventGenerator.  When we restart, a jump must be applied
   to each persisted Generator which yields one SequenceJumpRecord per
   jump applied.  The presence of this record ensures that:

   <ol>
   <li>If we have to restore state entirely from log files, the EventGenerator
   will still have an appropriate sequence number.</li>
   <li>If we crash again before the EventGenerator is sync'd to disk, via a
   checkpoint, the sequence number will still be accurate.</li>
   </ol>
 */
class SequenceJumpRecord implements TxnOp {
    private OID theOID;
    private long theSeqNum;

    SequenceJumpRecord(OID aOID, long aSeqNum) {
        theOID = aOID;
        theSeqNum = aSeqNum;
    }

    public void commit(TxnState aState) throws IOException {
        // Nothing to do
    }

    public void abort(TxnState aState) throws IOException {
        // Nothing to do
    }

    public void restore(TxnState aState) throws IOException {
        EventGeneratorFactory.get().jumpSequenceNumber(theOID, theSeqNum);
    }

    public String toString() {
        return " RJ : " + theOID + " : " + theSeqNum;
    }
}