com.mckoi.database
Class TransactionSystem

java.lang.Object
  extended by com.mckoi.database.TransactionSystem
Direct Known Subclasses:
DatabaseSystem

public class TransactionSystem
extends java.lang.Object

A class that provides information and global functions for the transaction layer in the engine. Shared information includes configuration details, logging, etc.

Author:
Tobias Downer

Constructor Summary
TransactionSystem()
          Constructor.
 
Method Summary
 void addFunctionFactory(FunctionFactory factory)
          Registers a new FunctionFactory with the database system.
 boolean alwaysReindexDirtyTables()
          Returns the status of the 'always_reindex_dirty_tables' property.
 DebugLogger Debug()
          Returns the DebugLogger object that is used to log debug message.
 void dispose()
          Disposes this object.
 boolean dontSynchFileSystem()
          Returns true if we shouldn't synchronize with the file system when important indexing information is flushed to the disk.
 void flushCachedFunctionLookup()
          Flushes the 'FunctionLookup' object returned by the getFunctionLookup method.
 LoggingBufferManager getBufferManager()
          Returns the LoggingBufferManager object enabling us to create no file stores in the file system.
 boolean getConfigBoolean(java.lang.String property, boolean default_val)
          Returns a configuration value, or the default if it's not found.
 int getConfigInt(java.lang.String property, int default_val)
          Returns a configuration value, or the default if it's not found.
 java.lang.String getConfigString(java.lang.String property, java.lang.String default_val)
          Returns a configuration value, or the default if it's not found.
 java.io.File getDatabasePath()
          Returns the path of the database in the local file system if the database exists within the local file system.
 FunctionLookup getFunctionLookup()
          Returns a FunctionLookup object that will search through the function factories in this database system and find and resolve a function.
 java.io.File getLogDirectory()
          Returns the current log directory or null if no logging should occur.
 RegexLibrary getRegexLibrary()
          Returns the regular expression library from the configuration file.
 boolean ignoreIdentifierCase()
          Returns true if the parser should ignore case when searching for schema/table/column identifiers.
 void init(DBConfig config)
          Inits the TransactionSystem with the configuration properties of the system.
 boolean lookupComparisonListEnabled()
          Returns true if we should generate lookup caches in InsertSearch otherwise returns false.
 Transaction.CheckExpression prepareTransactionCheckConstraint(DataTableDef table_def, Transaction.CheckExpression check)
          Given a Transaction.CheckExpression, this will prepare the expression and return a new prepared CheckExpression.
 boolean readOnlyAccess()
          Returns true if the database is in read only mode.
 void setDebugLevel(int level)
          Sets the debug minimum level that is output to the logger.
 void setDebugOutput(java.io.Writer writer)
          Sets the Writer output for the debug logger.
 void setLogDirectory(java.io.File log_path)
          Sets the log directory.
 void setupRowCache(int max_cache_size, int max_cache_entry_size)
          Hack - set up the DataCellCache in DatabaseSystem so we can use the MasterTableDataSource object without having to boot a new DatabaseSystem.
 boolean softIndexStorage()
          Returns true if all table indices are kept behind a soft reference that can be garbage collected.
 Stats stats()
          Returns a com.mckoi.util.Stats object that can be used to keep track of database statistics for this VM.
 com.mckoi.database.StoreSystem storeSystem()
          Returns the StoreSystem encapsulation being used in this database.
 boolean tableLockingEnabled()
          Returns true if the database should perform checking of table locks.
 boolean transactionErrorOnDirtySelect()
          Returns true if during commit the engine should look for any selects on a modified table and fail if they are detected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionSystem

public TransactionSystem()
Constructor.

Method Detail

getConfigString

public final java.lang.String getConfigString(java.lang.String property,
                                              java.lang.String default_val)
Returns a configuration value, or the default if it's not found.


getConfigInt

public final int getConfigInt(java.lang.String property,
                              int default_val)
Returns a configuration value, or the default if it's not found.


getConfigBoolean

public final boolean getConfigBoolean(java.lang.String property,
                                      boolean default_val)
Returns a configuration value, or the default if it's not found.


init

public void init(DBConfig config)
Inits the TransactionSystem with the configuration properties of the system. This can only be called once, and should be called at database boot time.


setupRowCache

public void setupRowCache(int max_cache_size,
                          int max_cache_entry_size)
Hack - set up the DataCellCache in DatabaseSystem so we can use the MasterTableDataSource object without having to boot a new DatabaseSystem.


readOnlyAccess

public boolean readOnlyAccess()
Returns true if the database is in read only mode. In read only mode, any 'write' operations are not permitted.


getDatabasePath

public java.io.File getDatabasePath()
Returns the path of the database in the local file system if the database exists within the local file system. If the database is not within the local file system then null is returned. It is recommended this method is not used unless for legacy or compatability purposes.


tableLockingEnabled

public boolean tableLockingEnabled()
Returns true if the database should perform checking of table locks.


lookupComparisonListEnabled

public boolean lookupComparisonListEnabled()
Returns true if we should generate lookup caches in InsertSearch otherwise returns false.


softIndexStorage

public boolean softIndexStorage()
Returns true if all table indices are kept behind a soft reference that can be garbage collected.


alwaysReindexDirtyTables

public boolean alwaysReindexDirtyTables()
Returns the status of the 'always_reindex_dirty_tables' property.


dontSynchFileSystem

public boolean dontSynchFileSystem()
Returns true if we shouldn't synchronize with the file system when important indexing information is flushed to the disk.


transactionErrorOnDirtySelect

public boolean transactionErrorOnDirtySelect()
Returns true if during commit the engine should look for any selects on a modified table and fail if they are detected.


ignoreIdentifierCase

public boolean ignoreIdentifierCase()
Returns true if the parser should ignore case when searching for schema/table/column identifiers.


getBufferManager

public LoggingBufferManager getBufferManager()
Returns the LoggingBufferManager object enabling us to create no file stores in the file system. This provides access to the buffer scheme that has been configured.


getRegexLibrary

public RegexLibrary getRegexLibrary()
Returns the regular expression library from the configuration file.


storeSystem

public final com.mckoi.database.StoreSystem storeSystem()
Returns the StoreSystem encapsulation being used in this database.


setDebugOutput

public final void setDebugOutput(java.io.Writer writer)
Sets the Writer output for the debug logger.


setDebugLevel

public final void setDebugLevel(int level)
Sets the debug minimum level that is output to the logger.


Debug

public final DebugLogger Debug()
Returns the DebugLogger object that is used to log debug message. This method must always return a debug logger that we can log to.


addFunctionFactory

public void addFunctionFactory(FunctionFactory factory)
Registers a new FunctionFactory with the database system. The function factories are used to resolve a function name into a Function object. Function factories are checked in the order they are added to the database system.


flushCachedFunctionLookup

public void flushCachedFunctionLookup()
Flushes the 'FunctionLookup' object returned by the getFunctionLookup method. This should be called if the function factory list has been modified in some way.


getFunctionLookup

public FunctionLookup getFunctionLookup()
Returns a FunctionLookup object that will search through the function factories in this database system and find and resolve a function. The returned object may throw an exception from the 'generateFunction' method if the FunctionDef is invalid. For example, if the number of parameters is incorrect or the name can not be found.


prepareTransactionCheckConstraint

public Transaction.CheckExpression prepareTransactionCheckConstraint(DataTableDef table_def,
                                                                     Transaction.CheckExpression check)
Given a Transaction.CheckExpression, this will prepare the expression and return a new prepared CheckExpression. The default implementation of this is to do nothing. However, a sub-class of the system choose to prepare the expression, such as resolving the functions via the function lookup, and resolving the sub-queries, etc.


stats

public final Stats stats()
Returns a com.mckoi.util.Stats object that can be used to keep track of database statistics for this VM.


setLogDirectory

public final void setLogDirectory(java.io.File log_path)
Sets the log directory. This should preferably be called during initialization. If the log directory is not set or is set to 'null' then no logging to files occurs.


getLogDirectory

public final java.io.File getLogDirectory()
Returns the current log directory or null if no logging should occur.


dispose

public void dispose()
Disposes this object.