arlut.csd.ganymede
Class DBJournal

java.lang.Object
  |
  +--arlut.csd.ganymede.DBJournal
All Implemented Interfaces:
ObjectStatus

public class DBJournal
extends java.lang.Object
implements ObjectStatus

The DBJournal class is used to provide journalling of changes to the DBStore during operations. The Journal file will contain a complete list of all changes made since the last dump of the complete DBStore. The Journal file is composed of a header block followed by a number of transactions.

Each transaction consists of a number of object modification records, each record specifying the creation, deletion, or modification of a particular object. At the end of the transaction, a marker indicates the completion of the transaction. At DBStore startup time, the journal is read in and all complete transactions recorded are performed on the main DBStore.

Generally, if the DBStore was shut down correctly, the entire memory structure of the DBStore will be cleanly dumped out and the Journal will be removed. The Journal is intended to insure that the DBStore remains transaction consistent if the server running Ganymede crashes during runtime.

See the DBEditSet class for more information on Ganymede transactions.


Field Summary
(package private) static java.lang.String CLOSETRANS
           
(package private) static byte CREATE
           
(package private) static boolean debug
           
(package private) static byte DELETE
           
(package private)  boolean dirty
           
(package private) static byte EDIT
           
(package private)  java.lang.String filename
           
(package private) static java.lang.String id_string
           
(package private)  java.io.RandomAccessFile jFile
           
(package private) static byte major_version
           
(package private) static byte minor_version
           
(package private) static java.lang.String OPENTRANS
           
(package private)  DBStore store
           
(package private)  int transactionsInJournal
           
 
Fields inherited from interface arlut.csd.ganymede.ObjectStatus
CREATING, DELETING, DROPPING, EDITING
 
Constructor Summary
DBJournal(DBStore store, java.lang.String filename)
          The DBJournal constructor takes a filename and creates a DBJournal object.
 
Method Summary
(package private) static void initialize(java.io.DataOutput out)
           
 boolean isClean()
          returns true if the journal does not contain any transactions
 boolean load()
          The load() method reads in all transactions in the current DBStore Journal and makes the appropriate changes to the DBStore Object Bases.
private  void printObject(DBObject obj)
           
(package private)  void readHeaders()
          This method is used to read and check the first few fields of the journal as a sanity check on journal open/load.
 void reset()
          The reset() method is used to copy the journal file to a safe location and truncate it.
static void setDebug(boolean val)
           
 boolean writeTransaction(DBEditSet editset)
          The writeTransaction() method actually performs the full work of writing out a transaction to the DBStore Journal.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

debug

static boolean debug

id_string

static final java.lang.String id_string

major_version

static final byte major_version

minor_version

static final byte minor_version

OPENTRANS

static final java.lang.String OPENTRANS

CLOSETRANS

static final java.lang.String CLOSETRANS

CREATE

static final byte CREATE

EDIT

static final byte EDIT

DELETE

static final byte DELETE

filename

java.lang.String filename

jFile

java.io.RandomAccessFile jFile

store

DBStore store

dirty

boolean dirty

transactionsInJournal

int transactionsInJournal
Constructor Detail

DBJournal

public DBJournal(DBStore store,
                 java.lang.String filename)
          throws java.io.IOException

The DBJournal constructor takes a filename and creates a DBJournal object. If the file named does not exist, the DBJournal constructor will create the file and write the DBJournal header, leaving the file pointer pointing to the end of the file. If the Journal file does exist, the constructor will advance the file pointer to the end of the file.

In either case, the file will be made ready for new transactions to be written.

Method Detail

setDebug

public static void setDebug(boolean val)

initialize

static void initialize(java.io.DataOutput out)
                throws java.io.IOException

reset

public void reset()
           throws java.io.IOException
The reset() method is used to copy the journal file to a safe location and truncate it. reset() should be called immediately after the DBStore is dumped to disk and before the DumpLock is relinquished.

load

public boolean load()
             throws java.io.IOException

The load() method reads in all transactions in the current DBStore Journal and makes the appropriate changes to the DBStore Object Bases. This method should be called after the main body of the DBStore is loaded and before the DBStore is put into production mode.

load() will return true if the on-disk journal was in a consistent state, with no incomplete transactions. If load() encounters EOF in the middle of attempting to read in a transaction record, load() will return false. In either case, any valid and complete transaction records will be processed and integrated into the DBStore.


writeTransaction

public boolean writeTransaction(DBEditSet editset)
                         throws java.io.IOException
The writeTransaction() method actually performs the full work of writing out a transaction to the DBStore Journal. writeTransaction() should be called before the changes are actually finalized in the DBStore Object Bases. If writeTransaction() is not able to successfully write the complete transaction log to the Journal file, an IOException will be thrown. The Journal entries are structured so that if a Journal entry can't be completed, the transaction's whole entry will be ignored at load time.

isClean

public boolean isClean()
returns true if the journal does not contain any transactions

readHeaders

void readHeaders()
           throws java.io.IOException

This method is used to read and check the first few fields of the journal as a sanity check on journal open/load.

This method MUST NOT be called after the journal is open and active, or else the journal will become corrupted.


printObject

private void printObject(DBObject obj)