edu.ucsb.adl.bucket99
Class QueryDriver

java.lang.Object
  |
  +--edu.ucsb.adl.bucket99.QueryDriver
All Implemented Interfaces:
QueryDriver

public final class QueryDriver
extends java.lang.Object
implements QueryDriver

Driver for the ADL query service. The driver maintains a pool of database connections, manages query threads, and logs requests to a log file. Translation of queries to SQL is performed by a separate, dynamically-loaded class. See class QueryThread for a description of the records logged by this driver.

This class reads the following properties from the Bucket99 driver configuration file bucket99.conf. Property values may be indirectly specified using the notation @P where P is the name of another property (see ExtendedProperties for more information).

query.database_driver_class
The fully-qualified name of the database driver class, e.g., "com.informix.jdbc.IfxDriver".
query.database_url
The database's connection URL.
query.database_properties
The name of a Java properties file containing database connection properties, or the string "none". If the filename is not absolute, it is interpreted relative to the directory containing the Bucket99 configuration file.
query.database_name
A short, descriptive name for the database, e.g., "informix@@myhost". Used for status reporting only. If not desired, leave empty.
query.minimum_connections
The number of database connections the driver attempts to keep open, e.g., "1".
query.maximum_connections
The maximum number of database connections open at any given time, e.g., "3".
query.test_query
The SQL query used to test database connections, e.g., "select 1 from dual".
query.connection_lifetime
The lifetime of database connections in milliseconds, e.g., "3600000" is one hour.
query.connection_reaper_cycle_time
The duration of the connection reaper's cycle in milliseconds, e.g., "300000" is 5 minutes.
query.translator_class
The fully-qualified name of the query translator class, e.g., "edu.ucsb.adl.bucket99.PythonQueryTranslator".
query.validation
Must be either "on" or "off". If "on", the standard ADL metadata views in query results are validated for correctness.
query.log_file
The name of the file to log invocation records to; or, if the value is of the form "j2se-logger:L", the name L of the Java Logger to log invocation records to (at logging level INFO); or the string "none" if logging is not desired. If the filename is not absolute, it is interpreted relative to the directory containing the Bucket99 configuration file.
In the above, property values that are time durations in milliseconds may have a single-character suffix added to specify a different unit of measure. Recognized suffixes are "s" (seconds), "m" (minutes), "h" (hours), and "d" (days).

Version:
$Header: /export/home/gjanee/bucket99/edu/ucsb/adl/bucket99/RCS/QueryDriver.java,v 1.13 2006/06/23 02:58:57 gjanee Exp $

$Log: QueryDriver.java,v $ Revision 1.13 2006/06/23 02:58:57 gjanee
Incidental support for metadata caching. The driver now looks at the collection-specific middleware configuration file to determine what kind of metadata driver to create. This is an improvement over the old behavior (the driver was hard-coded to always create Bucket99 metadata drivers), but it's also a bit of a hack.

Revision 1.12 2004/09/23 17:16:35 gjanee
Rewrite to use class edu.ucsb.adl.middleware.ExtendedProperties.

Revision 1.11 2004/03/17 19:39:32 gjanee
Minor change to accommodate a change to ConnectionPool.Status.

Revision 1.10 2004/03/11 20:25:13 gjanee
Added support for different units of measure in time duration properties.

Revision 1.9 2004/03/06 00:08:11 gjanee
Added support for multiple middleware instances. A middleware instance is represented by a Global object that is tied to a main middleware configuration file. All service objects now maintain a reference to the appropriate Global object. Instance-wide variables formerly coded as class variables are now held by the Global object; various methods that return instance-wide variables now accept a Global object as an argument. The Global object is now passed to all service drivers.

Revision 1.8 2003/06/13 04:03:54 gjanee
Added support for logging to Java loggers. Modified the interpretation of the query.log_file property.

Revision 1.7 2003/06/12 16:51:12 gjanee
Added validation of query results. Added the query.validation property.

Revision 1.6 2002/09/28 21:10:00 gjanee
Minor documentation change.

Revision 1.5 2002/09/28 20:59:18 gjanee
Configuration file renames. Renamed the Bucket99 configuration file to bucket99.conf.

Revision 1.4 2002/09/26 15:09:49 gjanee
Added support for a separate Java properties file containing database connection properties. Added property query.database_properties. Added support for short, descriptive database names. Added property query.database_name and method getDatabaseName.

Revision 1.3 2001/10/09 20:31:16 gjanee
Added support for relative filenames.

Revision 1.2 2001/08/20 19:46:26 gjanee
Switched to the new configuration file structure. In the new structure, an entirely collection-independent "main" configuration file refers to a directory of subdirectories, one subdirectory per collection; each subdirectory holds a collection-specific middleware configuration file in addition to any configuration files required by the collection driver.

Revision 1.1 2000/10/12 16:44:58 gjanee
Initial revision

Author:
Greg Janée
Alexandria Digital Library

Method Summary
static edu.ucsb.adl.bucket99.QueryDriver createDriver(edu.ucsb.adl.middleware.Global global, java.io.File directory, java.lang.String collection)
          Creates a QueryDriver for a collection.
 edu.ucsb.adl.middleware.QueryThread createQueryThread(java.lang.String collection, edu.ucsb.adl.middleware.Query query, edu.ucsb.adl.middleware.ResultAccumulator accumulator)
          Creates a thread that processes a query on behalf of the collection.
 void destroy()
          Frees all resources held by the driver.
 edu.ucsb.adl.bucket99.QueryThread[] getActiveThreads()
          Returns all currently active query threads.
static edu.ucsb.adl.bucket99.QueryDriver[] getAllInstances(edu.ucsb.adl.middleware.Global global)
          Returns all Bucket99 query drivers, i.e., all instances of this class.
 java.lang.String getCollection()
          Returns the name of the collection on whose behalf the driver is running.
 java.lang.String getDatabaseName()
          Returns a short, descriptive name for the database.
 ConnectionPool.Status getPoolStatus()
          Returns the status of the driver's connection pool.
 void threadStarting(edu.ucsb.adl.bucket99.QueryThread thread)
          For use by QueryThread only.
 void threadTerminated(edu.ucsb.adl.bucket99.QueryThread thread)
          For use by QueryThread only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAllInstances

public static edu.ucsb.adl.bucket99.QueryDriver[] getAllInstances(edu.ucsb.adl.middleware.Global global)
Returns all Bucket99 query drivers, i.e., all instances of this class.

Parameters:
global - The global object representing this instance of the middleware.
Returns:
The drivers.

createDriver

public static edu.ucsb.adl.bucket99.QueryDriver createDriver(edu.ucsb.adl.middleware.Global global,
                                                             java.io.File directory,
                                                             java.lang.String collection)
                                                      throws InternalErrorException
Creates a QueryDriver for a collection.

Parameters:
global - The global object representing this instance of the middleware.
directory - The pathname of the directory containing the Bucket99 driver configuration file.
collection - The name of the collection, e.g., "adl_catalog".
Returns:
A QueryDriver.
Throws:
InternalErrorException - If any error is encountered.

getCollection

public java.lang.String getCollection()
Returns the name of the collection on whose behalf the driver is running.

Returns:
The collection name, e.g., "adl_catalog".

getDatabaseName

public java.lang.String getDatabaseName()
Returns a short, descriptive name for the database.

Returns:
The database name (e.g., "informix@myhost") or null.

getPoolStatus

public ConnectionPool.Status getPoolStatus()
Returns the status of the driver's connection pool.

Returns:
The connection pool's status.

createQueryThread

public edu.ucsb.adl.middleware.QueryThread createQueryThread(java.lang.String collection,
                                                             edu.ucsb.adl.middleware.Query query,
                                                             edu.ucsb.adl.middleware.ResultAccumulator accumulator)
                                                      throws MiddlewareException
Creates a thread that processes a query on behalf of the collection.

Specified by:
createQueryThread in interface QueryDriver
Parameters:
collection - The collection name, e.g., "adl_catalog".
query - The query.
accumulator - The result accumulator to which query results are to be sent.
Returns:
A query thread.
Throws:
UnsupportedException - If the query is not supported.
InternalErrorException - If the thread cannot otherwise be created.
MiddlewareException
See Also:
QueryService

threadStarting

public void threadStarting(edu.ucsb.adl.bucket99.QueryThread thread)
For use by QueryThread only.


threadTerminated

public void threadTerminated(edu.ucsb.adl.bucket99.QueryThread thread)
For use by QueryThread only.


getActiveThreads

public edu.ucsb.adl.bucket99.QueryThread[] getActiveThreads()
Returns all currently active query threads.

Returns:
The threads.

destroy

public void destroy()
Frees all resources held by the driver.

Specified by:
destroy in interface QueryDriver