edu.ucsb.adl.bucket99
Class QueryThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--edu.ucsb.adl.bucket99.QueryThread
All Implemented Interfaces:
QueryThread, java.lang.Runnable

public final class QueryThread
extends java.lang.Thread
implements QueryThread

A thread that executes an SQL query on behalf of the query driver for a collection. The thread reserves a database connection from the driver's connection pool, executes the query, requests standard ADL metadata views for each returned holding identifier, and adds the results to the query's result accumulator. Duplicate holding identifiers are discarded. Upon completion, the thread logs a record containing the following fields:

All of the above times are in the semantics of System.currentTimeMillis.

Version:
$Header: /export/home/gjanee/bucket99/edu/ucsb/adl/bucket99/RCS/QueryThread.java,v 1.7 2006/06/23 02:25:01 gjanee Exp $

$Log: QueryThread.java,v $ Revision 1.7 2006/06/23 02:25:01 gjanee
Minor change to support metadata caching. Minor change to accomodate Java 1.5.

Revision 1.6 2004/09/14 00:08:22 gjanee
Minor change to better handle formatting of SQL exceptions.

Revision 1.5 2003/06/12 17:09:07 gjanee
Query results are now Result objects, i.e., triplets of standard metadata views. Added validation of query results.

Revision 1.4 2002/09/26 16:09:26 gjanee
Added the ability to preemptively cancel a running query.

Revision 1.3 2001/08/23 23:03:42 gjanee
Minor change to support string holding identifiers.

Revision 1.2 2000/10/26 13:12:06 gjanee
Disabled JDBC escape processing to avoid a syntax conflict with the MapInfo SpatialWare DataBlade over the use of curly braces ("{}").

Revision 1.1 2000/10/11 17:42:54 gjanee
Initial revision

Author:
Greg Janée
Alexandria Digital Library

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
QueryThread(java.lang.String collection, edu.ucsb.adl.middleware.Query query, java.lang.String sqlQuery, edu.ucsb.adl.middleware.ResultAccumulator accumulator, edu.ucsb.adl.bucket99.ConnectionPool pool, edu.ucsb.adl.bucket99.QueryDriver queryDriver, edu.ucsb.adl.middleware.MetadataDriver metadataDriver, boolean validateResults, edu.ucsb.adl.bucket99.Log log)
          Creates a QueryThread.
 
Method Summary
 java.lang.String getCollection()
          Returns the name of the collection on whose behalf the thread is running.
 java.lang.String getProcessingState()
          Returns the thread's state.
 edu.ucsb.adl.middleware.Query getQuery()
          Returns the query the thread is executing.
 java.lang.String getSqlQuery()
          Returns the SQL query the thread is executing.
 void run()
           
 void stopASAP()
          Requests that the thread stop as soon as possible.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.ucsb.adl.middleware.QueryThread
start
 

Constructor Detail

QueryThread

public QueryThread(java.lang.String collection,
                   edu.ucsb.adl.middleware.Query query,
                   java.lang.String sqlQuery,
                   edu.ucsb.adl.middleware.ResultAccumulator accumulator,
                   edu.ucsb.adl.bucket99.ConnectionPool pool,
                   edu.ucsb.adl.bucket99.QueryDriver queryDriver,
                   edu.ucsb.adl.middleware.MetadataDriver metadataDriver,
                   boolean validateResults,
                   edu.ucsb.adl.bucket99.Log log)
Creates a QueryThread.

Parameters:
collection - The name of the collection, e.g., "adl_catalog".
query - The query to execute.
sqlQuery - The query to execute in SQL form.
accumulator - The accumulator to which results are to be sent.
pool - The connection pool.
queryDriver - The query driver creating the thread.
metadataDriver - The metadata driver to use to obtain metadata views.
validateResults - Indicates if query results should be validated.
log - The log file to log to, or null if logging is not desired.
Throws:
java.lang.NullPointerException - If any argument other than log is null.
Method Detail

stopASAP

public void stopASAP()
Requests that the thread stop as soon as possible.

Specified by:
stopASAP in interface QueryThread

getProcessingState

public java.lang.String getProcessingState()
Returns the thread's state.

Returns:
A description of the thread's state.

getCollection

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

Specified by:
getCollection in interface QueryThread
Returns:
The collection name, e.g., "adl_catalog".

getQuery

public edu.ucsb.adl.middleware.Query getQuery()
Returns the query the thread is executing.

Returns:
The query.

getSqlQuery

public java.lang.String getSqlQuery()
Returns the SQL query the thread is executing.

Returns:
The query.

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread