org.globus.exec.monitoring
Class SchedulerEventGenerator

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.globus.exec.monitoring.SchedulerEventGenerator
All Implemented Interfaces:
java.lang.Runnable

class SchedulerEventGenerator
extends java.lang.Thread

Scheduler Event Generator monitor thread. The Seg object creates a Scheduler Event Generator process to monitor job state changes associated with a particular scheduler. The Seg object will repeatedly start the SEG process if it terminates prematurely, until its shutdown() method is called.


Field Summary
private  java.io.File globusLocation
          Path to the SEG executable
private  long lastRestart
          Used to keep track of the last restart time for the SEG process---if it was too recent (less than our THROTTLE_RESTART_THRESHOLD) wait THROTTLE_RESTART_TIME before trying again.
private static org.apache.commons.logging.Log logger
           
private  JobStateMonitor monitor
          Monitor which created this SchedulerEventGenerator.
private  java.lang.Process proc
          SEG Process handle
private static java.lang.Runtime runtime
          Reference to the runtime used to start the SEG process
private  java.lang.String schedulerName
          Path to the SEG executable
private static java.lang.String SEG_EXECUTABLE_NAME
           
private  boolean shutdownCalled
          Flag indicating that the SEG process should no longer be restarted and the thread should terminate.
private  long THROTTLE_RESTART_THRESHOLD
          When SEG terminates within this amount of time of being started, assume something might be wrong and delay again.
private  long THROTTLE_RESTART_TIME
          When throttling process restarts, wait this many milliseconds before next restart attempt.
private  java.util.Date timeStamp
          Timestamp of last event we've received from a SEG.
private  java.lang.String userName
          Username of the account to run the SEG as.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SchedulerEventGenerator(java.io.File globusLocation, java.lang.String userName, java.lang.String schedulerName, JobStateMonitor monitor, boolean segDaemon)
          SEG constructor.
 
Method Summary
private  void cleanProcess()
           
 void run()
          Start and monitor a SEG process.
 void shutdown()
          Tell a SEG process to terminate.
 void start(java.util.Date timeStamp)
           
private  boolean startSegProcess(java.util.Date timeStamp)
          Start a scheduler event generator process.
private  void throttleRestart()
          Delay THROTTLE_RESTART_TIME before returning unless either The SEG process wasn't restarted within THROTTLE_RESTART_THRESHOLD The shutdown method has been called
 
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
 

Field Detail

logger

private static org.apache.commons.logging.Log logger

runtime

private static java.lang.Runtime runtime
Reference to the runtime used to start the SEG process


globusLocation

private java.io.File globusLocation
Path to the SEG executable


userName

private java.lang.String userName
Username of the account to run the SEG as. This is currently ignored.


schedulerName

private java.lang.String schedulerName
Path to the SEG executable


proc

private java.lang.Process proc
SEG Process handle


shutdownCalled

private boolean shutdownCalled
Flag indicating that the SEG process should no longer be restarted and the thread should terminate.


timeStamp

private java.util.Date timeStamp
Timestamp of last event we've received from a SEG.


monitor

private JobStateMonitor monitor
Monitor which created this SchedulerEventGenerator. We call its addEvent() method when a new event is read from the SEG process.


lastRestart

private long lastRestart
Used to keep track of the last restart time for the SEG process---if it was too recent (less than our THROTTLE_RESTART_THRESHOLD) wait THROTTLE_RESTART_TIME before trying again.


THROTTLE_RESTART_TIME

private final long THROTTLE_RESTART_TIME
When throttling process restarts, wait this many milliseconds before next restart attempt.

See Also:
Constant Field Values

THROTTLE_RESTART_THRESHOLD

private final long THROTTLE_RESTART_THRESHOLD
When SEG terminates within this amount of time of being started, assume something might be wrong and delay again.

See Also:
Constant Field Values

SEG_EXECUTABLE_NAME

private static final java.lang.String SEG_EXECUTABLE_NAME
See Also:
Constant Field Values
Constructor Detail

SchedulerEventGenerator

public SchedulerEventGenerator(java.io.File globusLocation,
                               java.lang.String userName,
                               java.lang.String schedulerName,
                               JobStateMonitor monitor,
                               boolean segDaemon)
SEG constructor.

Parameters:
globusLocation - Path to the Globus Toolkit installation.
userName - Username to sudo(8) to start the SEG.
schedulerName - Name of the scheduler SEG module to use (fork, lsf, etc).
Method Detail

run

public void run()
Start and monitor a SEG process. When the SEG terminates by itself for whatever reason, this thread will restart it using the timestamp of the last item which was in the event cache.


startSegProcess

private boolean startSegProcess(java.util.Date timeStamp)
                         throws java.io.IOException
Start a scheduler event generator process. This function is called to start a new scheduler event generator process. This process will monitor the output of the scheduler and send this object job state change notifications via the processes's standard output stream. If the shutdown method of this object has been called, then the process will not be started.

Throws:
java.io.IOException

throttleRestart

private void throttleRestart()
Delay THROTTLE_RESTART_TIME before returning unless either


cleanProcess

private void cleanProcess()

shutdown

public void shutdown()
              throws java.io.IOException
Tell a SEG process to terminate. This function will cause the thread associated with this object to terminate once all input has been processed.

Throws:
java.io.IOException

start

public void start(java.util.Date timeStamp)