| org.space4j.Logger
All known Subclasses: org.space4j.implementation.SimpleLogger,
Logger | public interface Logger (Code) | | 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 | |
public long | getLogNumber() Get the current log number. | public void | logCommand(Command cmd) | public Space | readSnapshot() Recover the last snapshot from disk and recreate a Space from it. | public void | reapplyCommandsFromLog(Space4J space4j) 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. | public void | takeSnapshot(Space space) Take a snapshot of the Space to disk. | public void | takeSnapshot(Space space, long snapnumber) Take a snapshot of the Space to disk. |
getLogNumber | public long getLogNumber()(Code) | | Get the current log number.
The current log number. |
logCommand | public void logCommand(Command cmd) throws LoggerException(Code) | | Log a command to a log file on disk.
Parameters: cmd - The command to log |
readSnapshot | public Space readSnapshot() throws LoggerException(Code) | | Recover the last snapshot from disk and recreate a Space from it.
A space recovered from the snapshot or null if there were no space to recover in disk. |
reapplyCommandsFromLog | public void reapplyCommandsFromLog(Space4J space4j) throws LoggerException, CommandException(Code) | | 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. |
takeSnapshot | public void takeSnapshot(Space space) throws LoggerException(Code) | | Take a snapshot of the Space to disk. The Space will be serialized and written to disk.
Parameters: space - The space to be saved. |
takeSnapshot | public void takeSnapshot(Space space, long snapnumber) throws LoggerException(Code) | | Take a snapshot of the Space to disk. The Space will be serialized and written to disk.
Parameters: space - The space to be saved. Parameters: snapnumber - The number of the snapshot to be saved. |
|
|