| java.lang.Object org.hsqldb.persist.Logger
Logger | public class Logger (Code) | | The public interface of logging and cache classes.
Implements a storage manager wrapper that provides a consistent,
always available interface to storage management for the Database
class, despite the fact not all Database objects actually use file
storage.
The Logger class makes it possible to avoid testing for a
null Log Database attribute again and again, in many different places,
and generally avoids tight coupling between Database and Log, opening
the doors for multiple logs/caches in the future. In this way, the
Database class does not need to know the details of the Logging/Cache
implementation, lowering its breakability factor and promoting
long-term code flexibility.
author: fredt@users version: 1.8.0 since: 1.7.0 |
Constructor Summary | |
public | Logger() |
Method Summary | |
public void | acquireLock(String path) | public synchronized void | checkpoint(boolean mode) Checkpoints the database. | public boolean | closeLog(int closemode) Shuts down the logging process using the specified mode. | public void | closeTextCache(Table table) Closes the TextCache object. | public DataFileCache | getCache() Returns the Cache object or null if one doesn't exist. | public int | getLogSize() | public int | getScriptType() | public int | getWriteDelay() | public boolean | hasCache() Returns the Cache object or null if one doesn't exist. | public boolean | hasLog() Determines if the logging process actually does anything. | public synchronized void | logConnectUser(Session session) Records a Log entry representing a new connection action on the
specified Session object. | public boolean | needsCheckpoint() | public void | openLog(Database db) Opens the specified Database object's database files and starts up
the logging process. | public DataFileCache | openTextCache(Table table, String source, boolean readOnlyData, boolean reversed) Opens the TextCache object. | public void | releaseLock() | public synchronized void | setLogSize(int megas) Sets the maximum size to which the log file can grow
before being automatically checkpointed. | public synchronized void | setScriptType(int i) | public synchronized void | setWriteDelay(int delay) Sets the log write delay mode to number of seconds. | public synchronized void | synchLog() | public synchronized void | synchLogForce() | public synchronized void | writeCommitStatement(Session session) | public synchronized void | writeDeleteStatement(Session session, Table t, Object[] row) | public synchronized void | writeInsertStatement(Session session, Table table, Object[] row) | public synchronized void | writeSequenceStatement(Session session, NumberSequence s) | public synchronized void | writeToLog(Session session, String statement) Records a Log entry for the specified SQL statement, on behalf of
the specified Session object. |
needsCheckpoint | boolean needsCheckpoint(Code) | | |
acquireLock | public void acquireLock(String path) throws HsqlException(Code) | | Attempts to aquire a cooperative lock condition on the database files
|
checkpoint | public synchronized void checkpoint(boolean mode) throws HsqlException(Code) | | Checkpoints the database.
The most important effect of calling this method is to cause the
log file to be rewritten in the most efficient form to
reflect the current state of the database, i.e. only the DDL and
insert DML required to recreate the database in its present state.
Other house-keeping duties are performed w.r.t. other database
files, in order to ensure as much as possible the ACID properites
of the database.
throws: HsqlException - if there is a problem checkpointing thedatabase |
closeLog | public boolean closeLog(int closemode)(Code) | | Shuts down the logging process using the specified mode.
Parameters: closemode - The mode in which to shut down the loggingprocess - closemode -1 performs SHUTDOWN IMMEDIATELY, equivalentto a poweroff or crash.
- closemode 0 performs a normal SHUTDOWN thatcheckpoints the database normally.
- closemode 1 performs a shutdown compact that scriptsout the contents of any CACHED tables to the log thendeletes the existing *.data file that contains the datafor all CACHED table before the normal checkpoint processwhich in turn creates a new, compact *.data file.
- closemode 2 performs a SHUTDOWN SCRIPT.
true if closed with no problems or false if a problem wasencountered. |
getLogSize | public int getLogSize()(Code) | | |
getScriptType | public int getScriptType()(Code) | | |
getWriteDelay | public int getWriteDelay()(Code) | | |
hasCache | public boolean hasCache()(Code) | | Returns the Cache object or null if one doesn't exist.
|
hasLog | public boolean hasLog()(Code) | | Determines if the logging process actually does anything.
In-memory Database objects do not need to log anything. This
method is essentially equivalent to testing whether this logger's
database is an in-memory mode database.
true if this object encapsulates a non-null Log instance,else false |
logConnectUser | public synchronized void logConnectUser(Session session) throws HsqlException(Code) | | Records a Log entry representing a new connection action on the
specified Session object.
Parameters: session - the Session object for which to record the logentry throws: HsqlException - if there is a problem recording the Logentry |
needsCheckpoint | public boolean needsCheckpoint()(Code) | | |
openLog | public void openLog(Database db) throws HsqlException(Code) | | Opens the specified Database object's database files and starts up
the logging process.
If the specified Database object is a new database, its database
files are first created.
Parameters: db - the Database throws: HsqlException - if there is a problem, such as the case whenthe specified files are in use by another process |
releaseLock | public void releaseLock()(Code) | | |
setLogSize | public synchronized void setLogSize(int megas)(Code) | | Sets the maximum size to which the log file can grow
before being automatically checkpointed.
Parameters: megas - size in MB |
setScriptType | public synchronized void setScriptType(int i) throws HsqlException(Code) | | Sets the type of script file, currently 0 for text (default)
1 for binary and 3 for compressed
Parameters: i - The type |
setWriteDelay | public synchronized void setWriteDelay(int delay)(Code) | | Sets the log write delay mode to number of seconds. By default
executed commands written to the log are committed fully at most
60 second after they are executed. This improves performance for
applications that execute a large number
of short running statements in a short period of time, but risks
failing to log some possibly large number of statements in the
event of a crash. A small value improves recovery.
A value of 0 will severly slow down logging when autocommit is on,
or many short transactions are committed.
Parameters: delay - in seconds |
synchLog | public synchronized void synchLog()(Code) | | Called after commits or after each statement when autocommit is on
|
synchLogForce | public synchronized void synchLogForce()(Code) | | |
writeToLog | public synchronized void writeToLog(Session session, String statement) throws HsqlException(Code) | | Records a Log entry for the specified SQL statement, on behalf of
the specified Session object.
Parameters: session - the Session object for which to record the Logentry Parameters: statement - the SQL statement to Log throws: HsqlException - if there is a problem recording the entry |
|
|