com.knowgate.scheduler
Class SchedulerDaemon

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

public class SchedulerDaemon
extends java.lang.Thread

Scheduler daemon

Keeps a thread pool and an atom queue for feeding the pool.


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
SchedulerDaemon(java.lang.String sPropertiesFilePath)
          Create new SchedulerDaemon
 
Method Summary
 void abortJob(java.lang.String sGuJob)
          Abort a given Job
 AtomQueue atomQueue()
           
 java.util.Date creationDate()
          Get date when this SchedulerDaemon was created
 DBBind databaseBind()
           
 void haltAll()
          Halt worker threads and set running jobs status to suspended Wait until all running atoms are finished and then stop all worker threads
static void main(java.lang.String[] argv)
           
 void registerCallback(WorkerThreadCallback oNewCallback)
           
 void run()
          Create AtomQueue and start WorkerThreadPool
 java.util.Date startDate()
          Get date when this SchedulerDaemon was started for the last time
 void stopAll()
          Stop worker threads and set running jobs status to interrupted Default delay for forcing threads to stop is 10 seconds
 void stopAll(long lDelayMilis)
          Stop worker threads and set running jobs status to interrupted Call haltAll() Wait until the specified amount of miliseconds and force all worker threads still alive to stop.
 java.util.Date stopDate()
          Get date when this SchedulerDaemon was stopped for the last time
 WorkerThreadPool threadPool()
           
 void unregisterCallback(java.lang.String sCallbackName)
           
 
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

SchedulerDaemon

public SchedulerDaemon(java.lang.String sPropertiesFilePath)
                throws java.lang.ClassNotFoundException,
                       java.io.FileNotFoundException,
                       java.io.IOException,
                       java.sql.SQLException

Create new SchedulerDaemon

Parameters:
sPropertiesFilePath - Full path to hipergate.cnf file.
Constructor will read the following properties from hipergate.cnf:
driver JDBC driver class
dburl URL for database connection
dbuser Database User
dbpassword Database User Password
Throws:
java.lang.ClassNotFoundException
java.io.FileNotFoundException
java.io.IOException
java.sql.SQLException
Method Detail

creationDate

public java.util.Date creationDate()
Get date when this SchedulerDaemon was created

Returns:
Date

startDate

public java.util.Date startDate()
Get date when this SchedulerDaemon was started for the last time

Returns:
Date

stopDate

public java.util.Date stopDate()
Get date when this SchedulerDaemon was stopped for the last time

Returns:
Date

atomQueue

public AtomQueue atomQueue()

threadPool

public WorkerThreadPool threadPool()

databaseBind

public DBBind databaseBind()

run

public void run()

Create AtomQueue and start WorkerThreadPool

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

registerCallback

public void registerCallback(WorkerThreadCallback oNewCallback)
                      throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

unregisterCallback

public void unregisterCallback(java.lang.String sCallbackName)

abortJob

public void abortJob(java.lang.String sGuJob)
              throws java.sql.SQLException,
                     java.lang.ClassNotFoundException,
                     java.lang.IllegalAccessException,
                     java.lang.InstantiationException,
                     java.io.FileNotFoundException

Abort a given Job

Parameters:
sGuJob - GUID of Job to be aborted
Throws:
SQLException, - ClassNotFoundException
java.sql.SQLException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.io.FileNotFoundException
Since:
5.0

haltAll

public void haltAll()
             throws java.lang.IllegalStateException

Halt worker threads and set running jobs status to suspended

Wait until all running atoms are finished and then stop all worker threads

Throws:
java.lang.IllegalStateException - If worker threads are not running

stopAll

public void stopAll(long lDelayMilis)
             throws java.lang.IllegalStateException,
                    java.sql.SQLException

Stop worker threads and set running jobs status to interrupted

Call haltAll() Wait until the specified amount of miliseconds and force all worker threads still alive to stop. This method must only be used when stalled worker threads cannot be stopped by calling haltAll().

Parameters:
lDelayMilis - long Delay (in miliseconds) to wait before executing threads are forced to stop
Throws:
java.lang.IllegalStateException - If worker threads are not running
java.sql.SQLException

stopAll

public void stopAll()
             throws java.lang.IllegalStateException,
                    java.sql.SQLException

Stop worker threads and set running jobs status to interrupted

Default delay for forcing threads to stop is 10 seconds

Throws:
java.lang.IllegalStateException - If worker threads are not running
java.sql.SQLException

main

public static void main(java.lang.String[] argv)
                 throws java.lang.ClassNotFoundException,
                        java.sql.SQLException,
                        java.io.IOException
Throws:
java.lang.ClassNotFoundException
java.sql.SQLException
java.io.IOException