Class DatabaseSystem


  • public final class DatabaseSystem
    extends TransactionSystem
    This class provides information about shared resources available for the entire database system running in this VM. Shared information includes configuration details, DataCellCache, plug-ins, user management, etc.
    • Field Detail

      • statement_cache

        private StatementCache statement_cache
        The StatementCache that maintains a cache of parsed queries.
      • query_logging

        private boolean query_logging
        True if all queries on the database should be logged in the 'commands.log' file in the log directory.
      • worker_pool

        private WorkerPool worker_pool
        The WorkerPool object that manages access to the database(s) in the system.
      • database_list

        private java.util.ArrayList database_list
        The list of Database objects that this system is being managed by this VM.
      • shutdown

        private boolean shutdown
        Set to true when the database is shut down.
      • user_manager

        private UserManager user_manager
        The UserManager object that handles users connected to the database engine.
      • shut_down_delegates

        private final java.util.ArrayList shut_down_delegates
    • Constructor Detail

      • DatabaseSystem

        public DatabaseSystem()
        Constructor.
    • Method Detail

      • init

        public void init​(DBConfig config)
        Inits the DatabaseSystem with the configuration properties of the system. This can only be called once, and should be called at database boot time.
        Overrides:
        init in class TransactionSystem
      • logQueries

        public boolean logQueries()
        If query logging is enabled (all queries are output to 'commands.log' in the log directory), this returns true. Otherwise it returns false.
      • dispose

        public void dispose()
        Disposes all the resources associated with this DatabaseSystem and invalidates this object.
        Overrides:
        dispose in class TransactionSystem
      • getStatementCache

        public StatementCache getStatementCache()
        Returns the StatementCache that is used to cache StatementTree objects that are being queried by the database. This is used to reduce the SQL command parsing overhead.

        If this method returns 'null' then statement caching is disabled.

      • getUserManager

        UserManager getUserManager()
        Returns the UserManager object that handles users that are connected to the database. The aim of this class is to unify the way users are handled by the engine. It allows us to perform queries to see who's connected, and any inter-user communication (triggers).
      • waitUntilAllWorkersQuiet

        void waitUntilAllWorkersQuiet()
        Waits until all executing commands have stopped. This is best called right after a call to 'setIsExecutingCommands(false)'. If these two commands are run, the database is in a known state where no commands can be executed.

        NOTE: This can't be called from the WorkerThread. Deadlock will result if we were allowed to do this.

      • setIsExecutingCommands

        void setIsExecutingCommands​(boolean status)
        Controls whether the database system is allowed to execute commands or not. If this is set to true, then calls to 'execute' will be executed as soon as there is a free worker thread available. Otherwise no commands are executed until this is enabled.
      • execute

        void execute​(User user,
                     DatabaseConnection database,
                     java.lang.Runnable runner)
        Executes database functions from the 'run' method of the given runnable instance on the first available worker thread. All database functions must go through a worker thread. If we ensure this, we can easily stop all database functions from executing if need be. Also, we only need to have a certain number of threads active at any one time rather than a unique thread for each connection.
      • registerShutDownDelegate

        void registerShutDownDelegate​(java.lang.Runnable delegate)
        Registers the delegate that is executed when the shutdown thread is activated. Only one delegate may be registered with the database system. This is only called once and shuts down the relevant database services.
      • startShutDownThread

        void startShutDownThread()
        This starts the ShutDown thread that is used to shut down the database server. Since the actual shutdown method is dependent on the type of database we are running (server or stand-alone) we delegate the shutdown method to the registered shutdown delegate.
      • hasShutDown

        boolean hasShutDown()
        Returns true if 'shutDown' method has been called.
      • waitUntilShutdown

        void waitUntilShutdown()
        Wait until the shutdown thread has completed. (Shutdown process has finished).