com.knowgate.scheduler
Class SingleThreadExecutor

java.lang.Object
  extended by java.lang.Thread
      extended by com.knowgate.scheduler.SingleThreadExecutor
All Implemented Interfaces:
java.lang.Runnable

public class SingleThreadExecutor
extends java.lang.Thread

Single Thread Scheduler Executor

SingleThreadExecutor is a class that processes jobs and atoms in a simple way, unlike SchedulerDaemon witch is based on an AtomQueue and a WorkerThreadPool, SingleThreadExecutor uses directly the database for tracking execution progress for a single thread.


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
SingleThreadExecutor(DBBind oDbb, java.lang.String sJobId)
          Create new SingleThreadExecutor for a single Job
SingleThreadExecutor(java.util.Properties oProps, java.lang.String sJobId)
          Create new SingleThreadExecutor for a single Job
SingleThreadExecutor(java.lang.String sPropertiesFilePath)
          Create new SingleThreadExecutor
SingleThreadExecutor(java.lang.String sPropertiesFilePath, java.lang.String sJobId)
          Create new SingleThreadExecutor for a single Job
 
Method Summary
 Atom activeAtom()
           
 Job activeJob()
           
 void halt()
          Halt thread execution commiting all operations in course before stopping If a thread is dead-locked by any reason halting it will not cause any effect.
 java.lang.String lastError()
           
static void main(java.lang.String[] argv)
           
 void registerCallback(WorkerThreadCallback oNewCallback)
          Register a thread callback object
 void run()
           
 boolean unregisterCallback(java.lang.String sCallbackName)
          Unregister a thread callback object
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SingleThreadExecutor

public SingleThreadExecutor(java.lang.String sPropertiesFilePath)
                     throws java.io.FileNotFoundException,
                            java.io.IOException

Create new SingleThreadExecutor

Parameters:
sPropertiesFilePath - Absolute path to hipergate.cnf properties file
Throws:
java.io.FileNotFoundException
java.io.IOException

SingleThreadExecutor

public SingleThreadExecutor(java.lang.String sPropertiesFilePath,
                            java.lang.String sJobId)
                     throws java.io.FileNotFoundException,
                            java.io.IOException

Create new SingleThreadExecutor for a single Job

Parameters:
sPropertiesFilePath - Absolute path to hipergate.cnf properties file
sJobId - GUID of Job for which to process atoms, if null the executor will process atoms for all pending jobs
Throws:
java.io.FileNotFoundException
java.io.IOException

SingleThreadExecutor

public SingleThreadExecutor(java.util.Properties oProps,
                            java.lang.String sJobId)

Create new SingleThreadExecutor for a single Job

Parameters:
oProps - Environment properties (usually taken from hipergate.cnf)
sJobId - GUID of Job for which to process atoms, if null the executor will process atoms for all pending jobs

SingleThreadExecutor

public SingleThreadExecutor(DBBind oDbb,
                            java.lang.String sJobId)

Create new SingleThreadExecutor for a single Job

Parameters:
oDbb - DBBind used for accesing the satabase
sJobId - GUID of Job for which to process atoms, if null the executor will process atoms for all pending jobs
Method Detail

activeAtom

public Atom activeAtom()

activeJob

public Job activeJob()

lastError

public java.lang.String lastError()

registerCallback

public void registerCallback(WorkerThreadCallback oNewCallback)
                      throws java.lang.IllegalArgumentException
Register a thread callback object

Parameters:
oNewCallback - WorkerThreadCallback subclass instance
Throws:
java.lang.IllegalArgumentException - If a callback with same name has oNewCallback was already registered

unregisterCallback

public boolean unregisterCallback(java.lang.String sCallbackName)
Unregister a thread callback object

Parameters:
sCallbackName - Name of callback to be unregistered
Returns:
true if a callback with such name was found and unregistered, false otherwise

run

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

halt

public void halt()

Halt thread execution commiting all operations in course before stopping

If a thread is dead-locked by any reason halting it will not cause any effect.
halt() method only sends a signals to the each WokerThread telling it that must finish pending operations and stop.


main

public static void main(java.lang.String[] argv)
                 throws java.io.FileNotFoundException,
                        java.io.IOException,
                        java.sql.SQLException,
                        java.lang.ClassNotFoundException,
                        java.lang.IllegalAccessException,
                        java.lang.InstantiationException,
                        org.xml.sax.SAXException
Throws:
java.io.FileNotFoundException
java.io.IOException
java.sql.SQLException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
org.xml.sax.SAXException