arlut.csd.ganymede
Class scheduleHandle

java.lang.Object
  |
  +--arlut.csd.ganymede.scheduleHandle
All Implemented Interfaces:
java.io.Serializable

public class scheduleHandle
extends java.lang.Object
implements java.io.Serializable

Handle object used to help manage background tasks registered in the Ganymede Server's GanymedeScheduler. In addition to being used by the server's task scheduler to organize and track registered tasks, vectors of serialized scheduleHandle objects are passed to the Ganymede admin console's changeTasks method.

Within the Ganymede server, scheduleHandle objects are held within the GanymedeScheduler to track the status of each registered task. When the GanymedeScheduler needs to run a background task, the scheduleHandle's runTask() method is called. runTask() creates a pair of threads, one to run the task and another taskMonitor thread to wait for the task to be completed. When the thread running the task completes, the task's taskMonitor calls the scheduleHandle's notifyCompletion() method, which in turn notifies the GanymedeScheduler that the task has completed its execution.

The various scheduling methods in scheduleHandle will throw an IllegalArgumentException if called post-serialization on the Ganymede client.

See Also:
Serialized Form

Field Summary
(package private) static boolean debug
           
(package private)  java.util.Date incepDate
          when was this task first registered? used to present a consistently sorted list on the client
(package private)  int interval
          0 if this is a one-shot, otherwise, the count in minutes
(package private)  java.lang.String intervalString
          For reporting our interval status to the admin console
(package private)  boolean isRunning
           
(package private)  java.util.Date lastTime
          When was this task last issued?
(package private)  java.lang.Thread monitor
          If this task is currently running, this field will point to a monitor thread that is waiting for the task's thread to complete before reporting completion.
(package private)  java.lang.String name
          For reporting our name to the admin console
(package private)  java.lang.Object[] options
          Any options that we need to pass to the task?
(package private)  boolean rerun
          if we are doing a on-demand and we get a request while running it, we'll want to immediately re-run it on completion
(package private)  GanymedeScheduler scheduler
          The GanymedeScheduler that this task is registered in.
(package private)  java.util.Date startTime
          When will this task next be issued?
(package private)  boolean suspend
           
(package private)  java.lang.Runnable task
          The task to run
(package private)  java.lang.Thread thread
          If this task is currently running, this field will point to the running thread, otherwise it will be null.
 
Constructor Summary
scheduleHandle(GanymedeScheduler scheduler, java.util.Date time, int interval, java.lang.Runnable task, java.lang.String name)
           
 
Method Summary
(package private)  void disable()
          Server-side method to disable future invocations of this task
(package private)  void enable()
          Server-side method to enable future invocations of this task
(package private)  boolean isOnDemand()
          Returns true if this task is not scheduled for periodic execution
(package private)  void notifyCompletion()
          This method is called by our taskMonitor when our task completes.
(package private)  boolean reschedule()
          Server-side method to determine whether this task should be rescheduled.
(package private)  boolean runAgain()
          This method lets the GanymedeScheduler check to see whether this task should be re-run when it terminates
(package private)  void runOnCompletion()
          Server-side method to request that this task be re-run after its current completion.
(package private)  void runOnCompletion(java.lang.Object[] _options)
          Server-side method to request that this task be re-run after its current completion.
(package private)  void runTask()
          Runs this task in a background thread.
(package private)  void setInterval(int interval)
          Server-side method to change the interval for this task
(package private)  void setOptions(java.lang.Object[] _options)
          This method is used to set an options array for the next run of the task associated with this handle, if that task is a GanymedeBuilderTask.
(package private)  void stop()
          Server-side method to bring this task to an abrupt halt.
(package private)  void unregister()
          Server-side method to request that this task not be kept after its current completion.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

debug

static final boolean debug

isRunning

boolean isRunning

suspend

boolean suspend

rerun

boolean rerun
if we are doing a on-demand and we get a request while running it, we'll want to immediately re-run it on completion

lastTime

java.util.Date lastTime
When was this task last issued?

startTime

java.util.Date startTime
When will this task next be issued?

incepDate

java.util.Date incepDate
when was this task first registered? used to present a consistently sorted list on the client

intervalString

java.lang.String intervalString
For reporting our interval status to the admin console

name

java.lang.String name
For reporting our name to the admin console

options

transient java.lang.Object[] options
Any options that we need to pass to the task?

interval

transient int interval
0 if this is a one-shot, otherwise, the count in minutes

task

transient java.lang.Runnable task
The task to run

thread

transient java.lang.Thread thread
If this task is currently running, this field will point to the running thread, otherwise it will be null.

monitor

transient java.lang.Thread monitor
If this task is currently running, this field will point to a monitor thread that is waiting for the task's thread to complete before reporting completion. The monitor thread is effectively a wrapper thread that lets any arbitrary Runnable be scheduled and managed by GanymedeScheduler.

scheduler

transient GanymedeScheduler scheduler
The GanymedeScheduler that this task is registered in.
Constructor Detail

scheduleHandle

public scheduleHandle(GanymedeScheduler scheduler,
                      java.util.Date time,
                      int interval,
                      java.lang.Runnable task,
                      java.lang.String name)
Parameters:
scheduler - Reference to the server's GanymedeScheduler
time - Anchor point for interval calculations
interval - Number of seconds between runs of this task
task - Java Runnable object to be run in a thread
name - Name to report for this task
Method Detail

setOptions

void setOptions(java.lang.Object[] _options)

This method is used to set an options array for the next run of the task associated with this handle, if that task is a GanymedeBuilderTask.

If the task associated with this handle is not a GanymedeBuilderTask, the options will be ignored. Since setOptions() is synchronized, options may only be set at a time when runTask() is not busy issuing the task in the background. runTask() clears the options set, so setOptions() only affects the next launching of the task.


runTask

void runTask()

Runs this task in a background thread. A second background thread is created to handle a taskMonitor to wait and report when the task completes.

This method is invalid on the client.


notifyCompletion

void notifyCompletion()

This method is called by our taskMonitor when our task completes. This method has no meaning outside of the context of the taskMonitor spawned by this handle, and should not be called from any other code.


reschedule

boolean reschedule()

Server-side method to determine whether this task should be rescheduled. Increments the startTime and returns true if this is a periodically executed task.


runAgain

boolean runAgain()

This method lets the GanymedeScheduler check to see whether this task should be re-run when it terminates


isOnDemand

boolean isOnDemand()

Returns true if this task is not scheduled for periodic execution


runOnCompletion

void runOnCompletion()

Server-side method to request that this task be re-run after its current completion. Intended for on-demand tasks that are requested by the GanymedeScheduler while they are already running.


runOnCompletion

void runOnCompletion(java.lang.Object[] _options)

Server-side method to request that this task be re-run after its current completion. Intended for on-demand tasks that are requested by the GanymedeScheduler while they are already running.


unregister

void unregister()

Server-side method to request that this task not be kept after its current completion. Used to remove a task from the Ganymede scheduler.


stop

void stop()

Server-side method to bring this task to an abrupt halt.


disable

void disable()

Server-side method to disable future invocations of this task


enable

void enable()

Server-side method to enable future invocations of this task


setInterval

void setInterval(int interval)

Server-side method to change the interval for this task

Parameters:
interval - Number of seconds between runs of this task