org.space4j
Interface Logger

All Known Implementing Classes:
SimpleLogger

public interface Logger

An interface defining how a Logger Object should work. A Logger is responsible for logging the commands to disk, taking snapshots of the Space to disk, recovering snapshots of the Space from disk, and reapplying the logged Commands.


Method Summary
 long getLogNumber()
          Get the current log number.
 void logCommand(Command cmd)
          Log a command to a log file on disk.
 Space readSnapshot()
          Recover the last snapshot from disk and recreate a Space from it.
 void reapplyCommandsFromLog(Space4J space4j)
          Read the last commands from the log and re-apply them to this Space4J.
 void takeSnapshot(Space space)
          Take a snapshot of the Space to disk.
 void takeSnapshot(Space space, long snapnumber)
          Take a snapshot of the Space to disk.
 

Method Detail

logCommand

void logCommand(Command cmd)
                throws LoggerException
Log a command to a log file on disk.

Parameters:
cmd - The command to log
Throws:
LoggerException

takeSnapshot

void takeSnapshot(Space space)
                  throws LoggerException
Take a snapshot of the Space to disk. The Space will be serialized and written to disk.

Parameters:
space - The space to be saved.
Throws:
LoggerException

takeSnapshot

void takeSnapshot(Space space,
                  long snapnumber)
                  throws LoggerException
Take a snapshot of the Space to disk. The Space will be serialized and written to disk.

Parameters:
space - The space to be saved.
snapnumber - The number of the snapshot to be saved.
Throws:
LoggerException

readSnapshot

Space readSnapshot()
                   throws LoggerException
Recover the last snapshot from disk and recreate a Space from it.

Returns:
A space recovered from the snapshot or null if there were no space to recover in disk.
Throws:
LoggerException

reapplyCommandsFromLog

void reapplyCommandsFromLog(Space4J space4j)
                            throws LoggerException,
                                   CommandException
Read the last commands from the log and re-apply them to this Space4J. The last commands are the commands after the last snapshot, in other words, those that were not reflected by the last snaphot. OBS: Let's say there is a crash before the system can take a snapshot. The log will be used to reconstruct the space. Actually the rule to initialization is: "Recover the last snapshot and recover the commands after the last snapshot.

Parameters:
space4j - The Space4J that will redo the commands.
Throws:
LoggerException
CommandException

getLogNumber

long getLogNumber()
Get the current log number.

Returns:
The current log number.


Copyright © 2005 Space4J Team. All Rights Reserved.