Class NanoDBServer

  • All Implemented Interfaces:
    ServerProperties

    public class NanoDBServer
    extends java.lang.Object
    implements ServerProperties

    This class provides the entry-point operations for managing the database server, and executing commands against it. While it is certainly possible to implement these operations separately, these implementations are strongly recommended since they include all necessary supporting steps, such as firing before- and after-command events, acquiring and releasing locks, and other critical resource-management tasks.

    This class also includes operations to parse strings into command objects, so that code can construct SQL statements as strings and then issue them against the database. Sometimes it is easier to create a SQL string than it is to construct the corresponding command objects.

    • Field Detail

      • logger

        private static org.apache.logging.log4j.Logger logger
        A logging object for reporting anything interesting that happens.
      • propertyRegistry

        private PropertyRegistry propertyRegistry
        The property registry for this database server.
      • functionDirectory

        private FunctionDirectory functionDirectory
        The function directory for this database server.
      • eventDispatcher

        private EventDispatcher eventDispatcher
        The event dispatcher for this database server.
      • storageManager

        private StorageManager storageManager
        The storage manager for this database server.
      • schemaLock

        private java.util.concurrent.locks.ReentrantReadWriteLock schemaLock
        A read-write lock to force DDL operations to occur serially, and without any overlap from DML operations.
    • Constructor Detail

      • NanoDBServer

        public NanoDBServer()
    • Method Detail

      • startup

        public void startup()
        This static method encapsulates all of the operations necessary for cleanly starting the NanoDB server. Database server properties are initialized from the JVM system properties, and/or defaults are used.
      • startup

        public void startup​(java.util.Properties initialProperties)
        This static method encapsulates all of the operations necessary for cleanly starting the NanoDB server. Database server properties are initialized from the JVM system properties, and/or defaults are used, but these values may optionally be overridden by the initial properties specified as an argument.
        Parameters:
        initialProperties - an optional set of database configuration properties which will override system properties and default values, or null if no initial properties should be provided.
      • getEventDispatcher

        public EventDispatcher getEventDispatcher()
        Returns the event-dispatcher for this database server.
        Returns:
        the event-dispatcher for this database server.
      • getPropertyRegistry

        public PropertyRegistry getPropertyRegistry()
        Returns the property registry for this database server.
        Returns:
        the property registry for this database server.
      • getFunctionDirectory

        public FunctionDirectory getFunctionDirectory()
        Returns the function directory for this database server.
        Returns:
        the function directory for this database server.
      • getStorageManager

        public StorageManager getStorageManager()
        Returns the storage manager for this database server.
        Returns:
        the storage manager for this database server.
      • parseCommand

        public Command parseCommand​(java.lang.String command)
      • getQueryPlanner

        public Planner getQueryPlanner()
        Returns a query-planner object of the type specified in the current server properties. If the planner cannot be instantiated for some reason, a RuntimeException will be thrown.
        Returns:
        a query-planner object of the type specified in the current server properties.
        Throws:
        java.lang.RuntimeException - if the specified planner class cannot be instantiated for some reason.
      • doCommand

        public CommandResult doCommand​(java.lang.String command,
                                       boolean includeTuples)
        Parse and execute a single command, returning a CommandResult object describing the results. The tuples produced by the command may optionally be included in the results as well.
        Parameters:
        command - the SQL operation to perform
        includeTuples - if true, the results will include all tuples produced by the command
        Returns:
        an object describing the outcome of the command execution
      • doCommands

        public java.util.List<CommandResult> doCommands​(java.lang.String commands,
                                                        boolean includeTuples)
        Parse and execute one or more commands, returning a list of CommandResult object describing the results. The tuples produced by the commands may optionally be included in the results as well.
        Parameters:
        commands - one or more SQL operations to perform
        includeTuples - if true, the results will include all tuples produced by the commands
        Returns:
        a list of objects describing the outcome of the command execution
      • doCommand

        public CommandResult doCommand​(Command command,
                                       boolean includeTuples)
        Executes a single database command, generating a CommandResult holding details about the operation, and optionally any tuples generated by the operation. This method also takes care of other command-related details, such as firing "before-command" and "after-command" events, and acquiring and releasing appropriate locks.
        Parameters:
        command - the command to execute
        includeTuples - a value of true causes the command's tuples to be stored into the command-result; false causes any tuples to be discarded.
        Returns:
        a command-result describing the results of the operation
      • shutdown

        public boolean shutdown()
        This method encapsulates all of the operations necessary for cleanly shutting down the NanoDB server.
        Returns:
        true if the database server was shutdown cleanly, or false if an error occurred during shutdown.