DODS 5.1 API

com.lutris.appserver.server.sql.standard
Class StandardLogicalDatabase

java.lang.Object
  |
  +--com.lutris.appserver.server.sql.standard.StandardLogicalDatabase
All Implemented Interfaces:
LogicalDatabase
Direct Known Subclasses:
InformixLogicalDatabase, OracleLogicalDatabase

public class StandardLogicalDatabase
extends java.lang.Object
implements LogicalDatabase

Represents a logical database. Each logical database has a connection allocator and a object id allocator. The standard implementation of a local database is used when the database is described as of type Standard in DatabaseManager.DB.dbname.ClassType

The configuration data is specified in the section: DatabaseManager.DB.dbName

The following is a description of the sub fields:

Since:
LBS1.8
Version:
$Revision: 1.2 $
Author:
Paul Morgan
, Kyle Clark

Field Summary
protected  ConnectionAllocator connectionAllocator
          Database connection allocator.
protected  java.lang.String dbName
          The symbolic name of this logical database.
protected  java.lang.String dbType
          The database vendor type.
protected  java.sql.Driver driver
          Driver object object.
protected  ObjectIdAllocator objectIdAllocator
          Object id manager.
 
Constructor Summary
StandardLogicalDatabase()
          Default constructor to configure a single logical database.
StandardLogicalDatabase(java.lang.String dbName, com.lutris.util.Config dbConfig)
          Creates and configures a single logical database.
 
Method Summary
 DBConnection allocateConnection()
          Return the connection allocator object associated with this logical database.
 ObjectId allocateObjectId()
          Return an object id for this logical database.
 void checkOId(ObjectId oid)
          Check does oid belong to Object id's range [minOId, currentOId]
 DBQuery createQuery()
          Return a query for use on this logical database.
 DBTransaction createTransaction()
          Return a transaction for use on this logical database.
 int getActiveConnectionCount()
          Return the number of currently active connections.
 int getMaxConnectionCount()
          Return the maximum number of connections active at one time.
 java.util.Date getMaxConnectionCountDate()
          Return the time when the maximum connection count occured.
 java.lang.String getName()
          Return the symbolic name of this logical database.
 long getRequestCount()
          Return the number of database requests.
 java.lang.String getType()
          Return a description of the logical database type.
 void init(java.lang.String dbName, com.lutris.util.Config dbConfig)
          Initialize a single logical database.
 ConnectionAllocator loadConnectionAllocator(com.lutris.util.Config connectionConfig)
          Return the connection allocator.
 ObjectIdAllocator loadObjectIdAllocator(com.lutris.util.Config objIdConfig)
          Return the object id allocator.
 void resetMaxConnectionCount()
          Reset the maximum connection count and date.
 void shutdown()
          Immediately shutdown the logical database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionAllocator

protected ConnectionAllocator connectionAllocator
Database connection allocator.


objectIdAllocator

protected ObjectIdAllocator objectIdAllocator
Object id manager.


driver

protected java.sql.Driver driver
Driver object object. Important: a reference to this must be maintained or the driver class might be garbage collected out from under us.


dbName

protected java.lang.String dbName
The symbolic name of this logical database.


dbType

protected java.lang.String dbType
The database vendor type.

Constructor Detail

StandardLogicalDatabase

public StandardLogicalDatabase()
Default constructor to configure a single logical database. Note that the init() method must be called to configure the database.


StandardLogicalDatabase

public StandardLogicalDatabase(java.lang.String dbName,
                               com.lutris.util.Config dbConfig)
                        throws com.lutris.util.ConfigException,
                               java.sql.SQLException
Creates and configures a single logical database.

Parameters:
dbName - The logical name of the database. Used to
dbConfig - The configuration object for this logical database. get config parameters.
Throws:
com.lutris.util.ConfigException - If there is an error in the configuration file.
java.sql.SQLException - If a SQL error occurs.
Method Detail

init

public void init(java.lang.String dbName,
                 com.lutris.util.Config dbConfig)
          throws com.lutris.util.ConfigException,
                 java.sql.SQLException
Initialize a single logical database. Used after the default constructor is called.

Specified by:
init in interface LogicalDatabase
Parameters:
dbName - The logical name of the database.
dbConfig - The configuration object for this logical database.
Throws:
com.lutris.util.ConfigException - If there is an error in the configuration file.
java.sql.SQLException - If a SQL error occurs.

checkOId

public void checkOId(ObjectId oid)
              throws ObjectIdException
Check does oid belong to Object id's range [minOId, currentOId]

Specified by:
checkOId in interface LogicalDatabase
Parameters:
oid - oid which will be checked.
Throws:
ObjectIdException - If a oid does't belong to range.

loadConnectionAllocator

public ConnectionAllocator loadConnectionAllocator(com.lutris.util.Config connectionConfig)
                                            throws com.lutris.util.ConfigException
Return the connection allocator.

Parameters:
connectionConfig - The configuration object for the connection allocator.
Returns:
The connection allocator.
Throws:
com.lutris.util.ConfigException - If there is an error in the configuration file.

loadObjectIdAllocator

public ObjectIdAllocator loadObjectIdAllocator(com.lutris.util.Config objIdConfig)
                                        throws com.lutris.util.ConfigException
Return the object id allocator.

Parameters:
objIdConfig - The configuration object for the object id allocator.
Returns:
The object id allocator.
Throws:
com.lutris.util.ConfigException - If there is an error in the configuration file.

allocateConnection

public DBConnection allocateConnection()
                                throws java.sql.SQLException
Return the connection allocator object associated with this logical database.

Specified by:
allocateConnection in interface LogicalDatabase
Returns:
The connection allocator.
Throws:
java.sql.SQLException - if SQL error occurs allocating connection.

allocateObjectId

public ObjectId allocateObjectId()
                          throws ObjectIdException
Return an object id for this logical database.

Specified by:
allocateObjectId in interface LogicalDatabase
Returns:
The object id.
Throws:
ObjectIdException - if an error occurs allocating an object id.

createTransaction

public DBTransaction createTransaction()
                                throws java.sql.SQLException
Return a transaction for use on this logical database.

Specified by:
createTransaction in interface LogicalDatabase
Returns:
The transaction object.
Throws:
java.sql.SQLException - if a SQL error occurs.

createQuery

public DBQuery createQuery()
                    throws java.sql.SQLException
Return a query for use on this logical database.

Specified by:
createQuery in interface LogicalDatabase
Returns:
The query object.
Throws:
java.sql.SQLException - if a SQL error occurs.

shutdown

public void shutdown()
Immediately shutdown the logical database. This is normally only called by the database manager on shutdown.

Specified by:
shutdown in interface LogicalDatabase

getName

public java.lang.String getName()
Return the symbolic name of this logical database.

Specified by:
getName in interface LogicalDatabase
Returns:
The symbolic name.

getType

public java.lang.String getType()
Return a description of the logical database type.

Specified by:
getType in interface LogicalDatabase
Returns:
The type.

getActiveConnectionCount

public int getActiveConnectionCount()
Return the number of currently active connections.

Specified by:
getActiveConnectionCount in interface LogicalDatabase
Returns:
The number of connections.

getMaxConnectionCount

public int getMaxConnectionCount()
Return the maximum number of connections active at one time.

Specified by:
getMaxConnectionCount in interface LogicalDatabase
Returns:
The number of connections.

getMaxConnectionCountDate

public java.util.Date getMaxConnectionCountDate()
Return the time when the maximum connection count occured.

Specified by:
getMaxConnectionCountDate in interface LogicalDatabase
Returns:
The Date when the maximum connection count occured.

resetMaxConnectionCount

public void resetMaxConnectionCount()
Reset the maximum connection count and date.

Specified by:
resetMaxConnectionCount in interface LogicalDatabase

getRequestCount

public long getRequestCount()
Return the number of database requests.

Specified by:
getRequestCount in interface LogicalDatabase
Returns:
The number of database requests (queries or transactions).

DODS 5.1 API