com.knowgate.scheduler
Class WorkerThread

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

public class WorkerThread
extends java.lang.Thread

Scheduled Job Worker 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
WorkerThread(WorkerThreadPool oThreadPool, AtomConsumer oAtomConsumer)
          Create WorkerThread
 
Method Summary
 Atom activeAtom()
           
 Job activeJob()
           
 int getDelayMS()
           
 void getDelayMS(int iMiliseconds)
           
 java.lang.String getProperty(java.lang.String sKey)
          Get Environment property from hipergate.cnf
 long getRunningTimeMS()
           
 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()
           
 void registerCallback(WorkerThreadCallback oNewCallback)
          Register a thread callback object
 void run()
          Process atoms obtained throught AtomConsumer Each worker WorkerThread will enter an endless loop until the queue is empty or an interrupt signal is received.
 void setConsumer(AtomConsumer oAtomConsumer)
           
 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

WorkerThread

public WorkerThread(WorkerThreadPool oThreadPool,
                    AtomConsumer oAtomConsumer)
Create WorkerThread

Parameters:
oThreadPool -
oAtomConsumer -
Method Detail

getDelayMS

public int getDelayMS()

getDelayMS

public void getDelayMS(int iMiliseconds)

getRunningTimeMS

public long getRunningTimeMS()

setConsumer

public void setConsumer(AtomConsumer oAtomConsumer)

getProperty

public java.lang.String getProperty(java.lang.String sKey)
Get Environment property from hipergate.cnf

Parameters:
sKey - Property Name
Returns:
Property Value or null if not found

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()

Process atoms obtained throught AtomConsumer

Each worker WorkerThread will enter an endless loop until the queue is empty or an interrupt signal is received.
If an exception is thrown while creating of processing atoms the workerthread will be aborted.

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.