com.splout.db.common
Class TimeoutThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.splout.db.common.TimeoutThread
All Implemented Interfaces:
java.lang.Runnable

public class TimeoutThread
extends java.lang.Thread

A Thread that is in charge of killing long-running queries.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TimeoutThread(long timeout)
           
 
Method Summary
 void endQuery(com.almworks.sqlite4java.SQLiteConnection connection)
          The same Thread that provided this connection in startQuery() removes it from the monitoring list.
 void run()
           
 void startQuery(com.almworks.sqlite4java.SQLiteConnection connection, java.lang.String query)
          A Thread provides its thread-local connection to be monitored when a query starts.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeoutThread

public TimeoutThread(long timeout)
Parameters:
timeout - The timeout in milliseconds. If a SQLite connection monitored by this Thread has a query that runs for more than this, it will be interrupted and the query will return an error.
Method Detail

run

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

startQuery

public void startQuery(com.almworks.sqlite4java.SQLiteConnection connection,
                       java.lang.String query)
A Thread provides its thread-local connection to be monitored when a query starts. The SQL query is provided just for logging purposes.


endQuery

public void endQuery(com.almworks.sqlite4java.SQLiteConnection connection)
The same Thread that provided this connection in startQuery() removes it from the monitoring list. So it is important to understand that this class makes the assumption that each SQLite Thread will use only one connection (Thread-local). SQLite4JavaManager behaves like this.



Copyright © 2012-2013 Datasalt Systems S.L.. All Rights Reserved.