org.mbari.siam.core
Class Scheduler

java.lang.Object
  extended by org.mbari.siam.core.Scheduler

public class Scheduler
extends java.lang.Object

- Scheduler: provides application global view of schedules, supporting operations like showSchedule and getNextScheduledJob - ScheduleTaskImpl: an implementation of ScheduleTask, which encapsulates scheduling timing and control - ScheduleSpecifier: cron-like representation of schedules - Scheduler.ScheduleKey: an inner class of Scheduler, a unique ScheduleOwnerID used in some contexts to resolve ownership of ScheduleTasks (e.g., to differentiate between two ScheduleTasks with the same name, owned by objects of the same class). - ScheduleOwner: an interface that must be fulfilled by things that use schedules To use a schedule, a class must: - implement ScheduleOwner (an interface with 3 methods) - obtain a ScheduleKey object - create one or more ScheduleTasks - register the ScheduleTasks with the Scheduler - start the schedules running (or have them started by something other class) - optionally provide any accessor methods required by the application Scheduler is a cron-like class that schedules periodic events like sampling, using an event/listener model. // HashMap is not inherently synchronized; synchronization must // be manually provided when performing structural mods to the HashMap. // Failure to do this synchronization may result in // undeterministic behavior Set s = _schedules.keySet(); synchronized(_schedules) { // Synchronizing on _schedules, not s! Iterator i = s.iterator(); // Must be in synchronized block while (i.hasNext()){ } } NewScheduler differs from Scheduler as follows: - Objects that wish to receive notification of various events must implement the Schedulable interface, which requires an implementation of SchedulerListener, which extends EventListener.


Nested Class Summary
 class Scheduler.ScheduleKey
          Scheduler.ScheduleKey: an inner class of Scheduler, a unique ScheduleOwnerID used in some contexts to resolve ownership of ScheduleTasks (e.g., to differentiate between two ScheduleTasks with the same name, owned by objects of the same class).
 
Field Summary
protected static boolean _defaultsLoaded
          True if defaults have been loaded
static long _nextKey
           
static Scheduler _theScheduler
          the scheduler instance
static int ALREADY_EXISTS
           
static int INVALID_SCHEDULE
           
static long MAX_LOOKAHEAD_SEC
          Max seconds to look ahead for next absolute event
static int NOT_FOUND
           
static int OK
           
static boolean OVERWRITE
           
static boolean PRESERVE
           
static int UNDEFINED
           
 
Constructor Summary
Scheduler()
           
 
Method Summary
 int addSchedule(ScheduleTask schedule, boolean overwrite)
          Add schedule with optional overwrite
 java.lang.String getDefaultSampleScheduleName()
          Get Default Sample Schedule name
 java.lang.String getDefaultSystemScheduleName()
          Get Default System Schedule name
static Scheduler getInstance()
          Get Scheduler instance
 long getNextScheduledJob()
          Get next Scheduled job
 long getNextScheduledJob(long lookAheadSeconds)
          Get next Scheduled job
static java.lang.String getScheduleDirectory()
          Get Schedule Directory
static Scheduler.ScheduleKey getScheduleKey(ScheduleOwner owner)
           
static java.lang.String getSchedulePath()
          Get Full Schedule Path ($SIAM_HOME/scheduleDirectory)
static java.util.Properties getSchedulerProperties()
          Get SchedulerProperties
 java.util.Map getSchedules()
          Get Collection of Schedules
static java.lang.String getSiamHome()
          Get SiamHome Directory
static java.lang.String getStatusString(int status)
          Print error message
static void loadDefaults()
          Load default schedules (System, Sampling)
static void main(java.lang.String[] args)
           
 int removeSchedule(ScheduleTask schedule)
          Remove schedule file (scheduleFile is name only; no path)
 int removeSchedules(java.util.Collection schedules)
          Remove multiple schedules
 int setSchedule(ScheduleTask schedule)
          Add schedule with overwrite
 int setSchedules(java.util.Collection schedules)
          Add schedules with overwrite
 java.lang.String showSchedule()
          Show schedule file
 java.lang.String showSchedule(long lookAheadSeconds)
          Show all schedules
 java.lang.String showSchedule(Scheduler.ScheduleKey key, long lookAheadSeconds)
          Show all schedules
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OVERWRITE

public static boolean OVERWRITE

PRESERVE

public static boolean PRESERVE

OK

public static final int OK
See Also:
Constant Field Values

ALREADY_EXISTS

public static final int ALREADY_EXISTS
See Also:
Constant Field Values

NOT_FOUND

public static final int NOT_FOUND
See Also:
Constant Field Values

UNDEFINED

public static final int UNDEFINED
See Also:
Constant Field Values

INVALID_SCHEDULE

public static final int INVALID_SCHEDULE
See Also:
Constant Field Values

MAX_LOOKAHEAD_SEC

public static final long MAX_LOOKAHEAD_SEC
Max seconds to look ahead for next absolute event

See Also:
Constant Field Values

_nextKey

public static long _nextKey

_defaultsLoaded

protected static boolean _defaultsLoaded
True if defaults have been loaded


_theScheduler

public static Scheduler _theScheduler
the scheduler instance

Constructor Detail

Scheduler

public Scheduler()
Method Detail

getSchedules

public java.util.Map getSchedules()
Get Collection of Schedules


getInstance

public static Scheduler getInstance()
Get Scheduler instance


getStatusString

public static java.lang.String getStatusString(int status)
Print error message


setSchedules

public int setSchedules(java.util.Collection schedules)
Add schedules with overwrite


removeSchedules

public int removeSchedules(java.util.Collection schedules)
Remove multiple schedules


setSchedule

public int setSchedule(ScheduleTask schedule)
Add schedule with overwrite


addSchedule

public int addSchedule(ScheduleTask schedule,
                       boolean overwrite)
Add schedule with optional overwrite


removeSchedule

public int removeSchedule(ScheduleTask schedule)
Remove schedule file (scheduleFile is name only; no path)


showSchedule

public java.lang.String showSchedule()
Show schedule file


showSchedule

public java.lang.String showSchedule(long lookAheadSeconds)
Show all schedules


showSchedule

public java.lang.String showSchedule(Scheduler.ScheduleKey key,
                                     long lookAheadSeconds)
Show all schedules


getNextScheduledJob

public long getNextScheduledJob()
Get next Scheduled job


getNextScheduledJob

public long getNextScheduledJob(long lookAheadSeconds)
Get next Scheduled job


getSchedulerProperties

public static java.util.Properties getSchedulerProperties()
Get SchedulerProperties


getSiamHome

public static java.lang.String getSiamHome()
Get SiamHome Directory


getScheduleDirectory

public static java.lang.String getScheduleDirectory()
Get Schedule Directory


getDefaultSystemScheduleName

public java.lang.String getDefaultSystemScheduleName()
Get Default System Schedule name


getDefaultSampleScheduleName

public java.lang.String getDefaultSampleScheduleName()
Get Default Sample Schedule name


getSchedulePath

public static java.lang.String getSchedulePath()
Get Full Schedule Path ($SIAM_HOME/scheduleDirectory)


loadDefaults

public static void loadDefaults()
Load default schedules (System, Sampling)


getScheduleKey

public static final Scheduler.ScheduleKey getScheduleKey(ScheduleOwner owner)

main

public static void main(java.lang.String[] args)


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.