Top Description Fields Constructors Methods
org.hsqldb.persist

public Class Logger

extends Object
implements EventLogInterface
Class Inheritance
All Implemented Interfaces
org.hsqldb.lib.EventLogInterface
Imports
java.io.File, .FileInputStream, .IOException, java.text.SimpleDateFormat, java.util.Locale, java.util.concurrent.atomic.AtomicInteger, org.hsqldb.Database, .DatabaseType, .HsqlNameManager.HsqlName, .NumberSequence, .Row, .Session, .SessionInterface, .Statement, .Table, .TableBase, .Tokens, .TransactionManager, .TransactionManagerMV2PL, .TransactionManagerMVCC, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.index.Index, .IndexAVL, .IndexAVLMemory, org.hsqldb.lib.ArrayUtil, .EventLogInterface, .FileAccess, .FileUtil, .FrameworkLogger, .HashMap, .HsqlArrayList, .InputStreamInterface, .InputStreamWrapper, .List, .SimpleLog, .StringUtil, org.hsqldb.lib.tar.DbBackup, .TarMalformatException, org.hsqldb.result.Result, org.hsqldb.scriptio.ScriptWriterBase, .ScriptWriterText, org.hsqldb.types.RowType, .Type

The public interface of persistence and logging 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.

Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
1.7.0
Version
2.7.3

Field Summary

Modifier and TypeField and Description
public SimpleLog
public static final String
pack-priv DbBackup
public static final String
pack-priv AtomicInteger
pack-priv AtomicInteger
pack-priv boolean
private Crypto
private Database
public static final String
public FileAccess
public SimpleDateFormat
pack-priv FrameworkLogger
public boolean
public boolean
pack-priv static final int
public static final String
private LockFile
public static final String
pack-priv Log
public static final String
private boolean
private boolean
pack-priv long
public static final String
public static final String
private int
private long
pack-priv boolean
pack-priv int
private int
pack-priv int
public static final String
private int
private int
pack-priv long
pack-priv int
private boolean
pack-priv boolean
pack-priv int
private boolean
private int
pack-priv int
pack-priv boolean
pack-priv long
pack-priv boolean
pack-priv int
pack-priv int
pack-priv boolean
pack-priv String
pack-priv int
private int
private static final char
public static final String
public SimpleLog
public static final String
pack-priv FrameworkLogger
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv String
public TextTableStorageManager

Constructor Summary

AccessConstructor and Description
public
Logger(Database database)

Method Summary

Modifier and TypeMethod and Description
public void
public void
backup(String destPath, boolean script, boolean blocking, boolean compressed, boolean files)

pack-priv void
backupInternal(String destPath, boolean script, boolean blocking, boolean compressed, boolean asFiles)

public void
checkpoint(Session session, boolean defrag, boolean lobs)

Checkpoints the database.

private void
checkpointInternal(Session session, boolean defrag)

pack-priv static void
checkPower(int n, int max)

public boolean

Returns:

true if closed with no problems or false if a problem was encountered.
close
(int
The mode in which to shut down the logging process
  1. CLOSEMODE_IMMEDIATELY performs SHUTDOWN IMMEDIATELY, equivalent to a poweroff or crash.
  2. CLOSEMODE_NORMAL performs a normal SHUTDOWN that checkpoints the database normally.
  3. CLOSEMODE_COMPACT performs a shutdown compact that scripts out the contents of any CACHED tables to the log then deletes the existing *.data file that contains the data for all CACHED table before the normal checkpoint process which in turn creates a new, compact *.data file.
  4. CLOSEMODE_SCRIPT performs a SHUTDOWN SCRIPT.
closemode
)

Shuts down the logging process using the specified mode.

public DataFileCache
getCache()

Returns the Cache object or null if one doesn't exist.

public int
public long
public Crypto
public int
public int
public int
public int
private void
getEventLogger()

All usage of FrameworkLogger should call this method before using an instance.

public FileAccess
public long
public int
public int
public int
public List<String>
getPropertiesSQLArray(boolean indexRoots)

public HashMap<String, String>
public String
getSecurePath(String path, boolean allowFull, boolean includeRes)

Returns a secure path or null for a user-defined path when hsqldb.allow_full_path is false.

public int
public String
public int
public boolean
hasCache()

Returns true if Cache object exists.

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public void
public void
public void
public void
logStatementEvent(Session session, Statement statement, Object[] paramValues, Result result, int level)

public void
public boolean
public Index
newIndex(HsqlNameManager.HsqlName name, long id, TableBase table, int[] columns, boolean[] descending, boolean[] nullsLast, Type[] colTypes, boolean pk, boolean unique, boolean constraint, boolean forward)

public PersistentStore
pack-priv String
public void
open()

Opens the specified Database object's database files and starts up the logging process.

public void
public void
setCacheMaxRows(int value)

public void
setCacheSize(int value)

public void
public void
setDataFileScale(int value)

public void
public void
setDataFileSpace(boolean value)

public void
setDataFileSpace(int value)

public void
setDefagLimit(int value)

public void
public void
setEventLogLevel(int level)

public void
public void
setFilesTimestamp(long value)

public void
setLobFileCompressed(boolean value)

public void
public void
setLobFileScale(int value)

public void
public synchronized void
setLogData(boolean mode)

Sets logging on or off.

public synchronized void
setLogSize(int
size in MB
megas
)

Sets the maximum size to which the log file can grow before being automatically checkpointed.

public void
setNioDataFile(boolean value)

public void
setNioMaxSize(int value)

public synchronized void
setScriptType(int
The type
format
)

Sets the type of script file, currently 0 for text (default) 3 for compressed

public void
setSqlLogLevel(int level)

private void
public synchronized void
setWriteDelay(int
in milliseconds
delay
)

Sets the log write delay mode to number of seconds.

public synchronized void
public synchronized void
writeCommitStatement(Session session)

Used at transaction commit

public synchronized void
writeDeleteStatement(Session session, Table t, Object[] row)

Used exclusively by PersistentStore objects

public synchronized void
writeInsertStatement(Session session, Row row, Table table)

Used exclusively by PersistentStore objects

public synchronized void
writeOtherStatement(Session session, String statement)

Records a Log entry for the specified SQL statement, on behalf of the specified Session object.

public synchronized void
writeSequenceStatement(Session session, NumberSequence s)

Used at transaction commit

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

appLogback to summary
public SimpleLog appLog
appLogFileExtensionback to summary
public static final String appLogFileExtension
backupback to summary
pack-priv DbBackup backup
backupFileExtensionback to summary
public static final String backupFileExtension
backupStateback to summary
pack-priv AtomicInteger backupState
checkpointStateback to summary
pack-priv AtomicInteger checkpointState
cryptLobsback to summary
pack-priv boolean cryptLobs
cryptoback to summary
private Crypto crypto
databaseback to summary
private Database database
dataFileExtensionback to summary
public static final String dataFileExtension
fileAccessback to summary
public FileAccess fileAccess
fileDateFormatback to summary
public SimpleDateFormat fileDateFormat
fwLoggerback to summary
pack-priv FrameworkLogger fwLogger
isNewDatabaseback to summary
public boolean isNewDatabase
isSingleFileback to summary
public boolean isSingleFile
largeDataFactorback to summary
pack-priv static final int largeDataFactor
lobsFileExtensionback to summary
public static final String lobsFileExtension
lockFileback to summary
private LockFile lockFile
lockFileExtensionback to summary
public static final String lockFileExtension
logback to summary
pack-priv Log log
logFileExtensionback to summary
public static final String logFileExtension
loggingEnabledback to summary
private boolean loggingEnabled
logsStatementsback to summary
private boolean logsStatements
maxLogSizeback to summary
pack-priv long maxLogSize
newFileExtensionback to summary
public static final String newFileExtension
oldFileExtensionback to summary
public static final String oldFileExtension
propCacheMaxRowsback to summary
private int propCacheMaxRows
propCacheMaxSizeback to summary
private long propCacheMaxSize
propCompressLobsback to summary
pack-priv boolean propCompressLobs
propDataFileDefragLimitback to summary
pack-priv int propDataFileDefragLimit
propDataFileScaleback to summary
private int propDataFileScale
propDataFileSpaceback to summary
pack-priv int propDataFileSpace
propertiesFileExtensionback to summary
public static final String propertiesFileExtension
propEventLogLevelback to summary
private int propEventLogLevel
propExternalEventLogLevelback to summary
private int propExternalEventLogLevel
propFilesTimestampback to summary
pack-priv long propFilesTimestamp
propGCback to summary
pack-priv int propGC
propIsFileDatabaseback to summary
private boolean propIsFileDatabase
propLargeDataback to summary
pack-priv boolean propLargeData
propLobBlockSizeback to summary
pack-priv int propLobBlockSize
propLogDataback to summary
private boolean propLogData
propLogSizeback to summary
private int propLogSize
propMaxFreeBlocksback to summary
pack-priv int propMaxFreeBlocks
propNioDataFileback to summary
pack-priv boolean propNioDataFile
propNioMaxSizeback to summary
pack-priv long propNioMaxSize
propRefIntegrityback to summary
pack-priv boolean propRefIntegrity
propScriptFormatback to summary
pack-priv int propScriptFormat
propSqlLogLevelback to summary
pack-priv int propSqlLogLevel
propTextAllowFullPathback to summary
pack-priv boolean propTextAllowFullPath
propTextSourceDefaultback to summary
pack-priv String propTextSourceDefault
propTxModeback to summary
pack-priv int propTxMode
propWriteDelayback to summary
private int propWriteDelay
runtimeFileDelimback to summary
private static final char runtimeFileDelim
scriptFileExtensionback to summary
public static final String scriptFileExtension
sqlLogback to summary
public SimpleLog sqlLog
sqlLogFileExtensionback to summary
public static final String sqlLogFileExtension
sqlLoggerback to summary
pack-priv FrameworkLogger sqlLogger
stateBackupback to summary
pack-priv static final int stateBackup
stateCheckpointback to summary
pack-priv static final int stateCheckpoint
stateCheckpointDueback to summary
pack-priv static final int stateCheckpointDue
stateCheckpointNormalback to summary
pack-priv static final int stateCheckpointNormal
stateCheckpointRequiredback to summary
pack-priv static final int stateCheckpointRequired
stateNormalback to summary
pack-priv static final int stateNormal
tempDirectoryPathback to summary
pack-priv String tempDirectoryPath
textTableManagerback to summary
public TextTableStorageManager textTableManager

Constructor Detail

Loggerback to summary
public Logger(Database database)

Method Detail

acquireLockback to summary
public void acquireLock(String path)
backupback to summary
public void backup(String destPath, boolean script, boolean blocking, boolean compressed, boolean files)
backupInternalback to summary
pack-priv void backupInternal(String destPath, boolean script, boolean blocking, boolean compressed, boolean asFiles)
checkpointback to summary
public void checkpoint(Session session, boolean defrag, boolean lobs)

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 properties of the database.

Exceptions
HsqlException:
if there is a problem checkpointing the database
checkpointInternalback to summary
private void checkpointInternal(Session session, boolean defrag)
checkPowerback to summary
pack-priv static void checkPower(int n, int max)
closeback to summary
public boolean close(int closemode)

Shuts down the logging process using the specified mode.

Parameters
closemode:int

The mode in which to shut down the logging process

  1. CLOSEMODE_IMMEDIATELY performs SHUTDOWN IMMEDIATELY, equivalent to a poweroff or crash.
  2. CLOSEMODE_NORMAL performs a normal SHUTDOWN that checkpoints the database normally.
  3. CLOSEMODE_COMPACT performs a shutdown compact that scripts out the contents of any CACHED tables to the log then deletes the existing *.data file that contains the data for all CACHED table before the normal checkpoint process which in turn creates a new, compact *.data file.
  4. CLOSEMODE_SCRIPT performs a SHUTDOWN SCRIPT.
Returns:boolean

true if closed with no problems or false if a problem was encountered.

getCacheback to summary
public DataFileCache getCache()

Returns the Cache object or null if one doesn't exist.

getCacheMaxRowsback to summary
public int getCacheMaxRows()
getCacheSizeback to summary
public long getCacheSize()
getCryptoback to summary
public Crypto getCrypto()
getDataFileFactorback to summary
public int getDataFileFactor()
getDataFileScaleback to summary
public int getDataFileScale()
getDataFileSpaceback to summary
public int getDataFileSpace()
getDefragLimitback to summary
public int getDefragLimit()
getEventLoggerback to summary
private void getEventLogger()

All usage of FrameworkLogger should call this method before using an instance. It ensures and requires that no logging should take place before a new database unique name has been created for a new database or read from the .script file for an old database.

An instance is returned when: - database unique name has been created - FrameworkLogger would use log4j Otherwise null is returned. This tactic avoids usage of file-based jdk logging for the time being.

getFileAccessback to summary
public FileAccess getFileAccess()
getFilesTimestampback to summary
public long getFilesTimestamp()
getLobBlockSizeback to summary
public int getLobBlockSize()
getLobFileScaleback to summary
public int getLobFileScale()
getLogSizeback to summary
public int getLogSize()
getPropertiesSQLArrayback to summary
public List<String> getPropertiesSQLArray(boolean indexRoots)
getPropertyValueMapback to summary
public HashMap<String, String> getPropertyValueMap()
getSecurePathback to summary
public String getSecurePath(String path, boolean allowFull, boolean includeRes)

Returns a secure path or null for a user-defined path when hsqldb.allow_full_path is false. Returns the path otherwise.

getSqlEventLogLevelback to summary
public int getSqlEventLogLevel()
getTempDirectoryPathback to summary
public String getTempDirectoryPath()
getWriteDelayback to summary
public int getWriteDelay()
hasCacheback to summary
public boolean hasCache()

Returns true if Cache object exists.

hasLockFileback to summary
public boolean hasLockFile()
isAllowedFullPathback to summary
public boolean isAllowedFullPath()
isCurrentlyLoggedback to summary
public boolean isCurrentlyLogged()
isFileDatabaseback to summary
public boolean isFileDatabase()
isLoggedback to summary
public boolean isLogged()
isNewDatabaseback to summary
public boolean isNewDatabase()
logDetailEventback to summary
public void logDetailEvent(String message)

Implements org.hsqldb.lib.EventLogInterface.logDetailEvent.

logInfoEventback to summary
public void logInfoEvent(String message)

Implements org.hsqldb.lib.EventLogInterface.logInfoEvent.

logSevereEventback to summary
public void logSevereEvent(String message, Throwable t)

Implements org.hsqldb.lib.EventLogInterface.logSevereEvent.

logStatementEventback to summary
public void logStatementEvent(Session session, Statement statement, Object[] paramValues, Result result, int level)
logWarningEventback to summary
public void logWarningEvent(String message, Throwable t)

Implements org.hsqldb.lib.EventLogInterface.logWarningEvent.

needsCheckpointResetback to summary
public boolean needsCheckpointReset()
newIndexback to summary
public Index newIndex(HsqlNameManager.HsqlName name, long id, TableBase table, int[] columns, boolean[] descending, boolean[] nullsLast, Type[] colTypes, boolean pk, boolean unique, boolean constraint, boolean forward)
newStoreback to summary
public PersistentStore newStore(Session session, PersistentStoreCollection collection, TableBase table)
newUniqueNameback to summary
pack-priv String newUniqueName()
openback to summary
public void open()

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.

Exceptions
HsqlException:
if there is a problem, such as the case when the specified files are in use by another process
releaseLockback to summary
public void releaseLock()
setCacheMaxRowsback to summary
public void setCacheMaxRows(int value)
setCacheSizeback to summary
public void setCacheSize(int value)
setCheckpointRequiredback to summary
public void setCheckpointRequired()
setDataFileScaleback to summary
public void setDataFileScale(int value)
setDataFileScaleNoCheckback to summary
public void setDataFileScaleNoCheck(int value)
setDataFileSpaceback to summary
public void setDataFileSpace(boolean value)
setDataFileSpaceback to summary
public void setDataFileSpace(int value)
setDefagLimitback to summary
public void setDefagLimit(int value)
setDefaultTextTablePropertiesback to summary
public void setDefaultTextTableProperties(String source, HsqlProperties props)
setEventLogLevelback to summary
public void setEventLogLevel(int level)
setExternalEventLogLevelback to summary
public void setExternalEventLogLevel(int level)
setFilesTimestampback to summary
public void setFilesTimestamp(long value)
setLobFileCompressedback to summary
public void setLobFileCompressed(boolean value)
setLobFileCompressedNoCheckback to summary
public void setLobFileCompressedNoCheck(boolean value)
setLobFileScaleback to summary
public void setLobFileScale(int value)
setLobFileScaleNoCheckback to summary
public void setLobFileScaleNoCheck(int value)
setLogDataback to summary
public synchronized void setLogData(boolean mode)

Sets logging on or off.

setLogSizeback to summary
public synchronized void setLogSize(int megas)

Sets the maximum size to which the log file can grow before being automatically checkpointed.

Parameters
megas:int

size in MB

setNioDataFileback to summary
public void setNioDataFile(boolean value)
setNioMaxSizeback to summary
public void setNioMaxSize(int value)
setScriptTypeback to summary
public synchronized void setScriptType(int format)

Sets the type of script file, currently 0 for text (default) 3 for compressed

Parameters
format:int

The type

setSqlLogLevelback to summary
public void setSqlLogLevel(int level)
setVariablesback to summary
private void setVariables()
setWriteDelayback to summary
public synchronized void setWriteDelay(int delay)

Sets the log write delay mode to number of seconds. By default executed commands written to the log are committed fully at most 0.5 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:int

in milliseconds

synchLogback to summary
public synchronized void synchLog()
writeCommitStatementback to summary
public synchronized void writeCommitStatement(Session session)

Used at transaction commit

writeDeleteStatementback to summary
public synchronized void writeDeleteStatement(Session session, Table t, Object[] row)

Used exclusively by PersistentStore objects

writeInsertStatementback to summary
public synchronized void writeInsertStatement(Session session, Row row, Table table)

Used exclusively by PersistentStore objects

writeOtherStatementback to summary
public synchronized void writeOtherStatement(Session session, String statement)

Records a Log entry for the specified SQL statement, on behalf of the specified Session object.

writeSequenceStatementback to summary
public synchronized void writeSequenceStatement(Session session, NumberSequence s)

Used at transaction commit