|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.mbari.siam.core.Scheduler
public class Scheduler
- 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 |
|---|
public static boolean OVERWRITE
public static boolean PRESERVE
public static final int OK
public static final int ALREADY_EXISTS
public static final int NOT_FOUND
public static final int UNDEFINED
public static final int INVALID_SCHEDULE
public static final long MAX_LOOKAHEAD_SEC
public static long _nextKey
protected static boolean _defaultsLoaded
public static Scheduler _theScheduler
| Constructor Detail |
|---|
public Scheduler()
| Method Detail |
|---|
public java.util.Map getSchedules()
public static Scheduler getInstance()
public static java.lang.String getStatusString(int status)
public int setSchedules(java.util.Collection schedules)
public int removeSchedules(java.util.Collection schedules)
public int setSchedule(ScheduleTask schedule)
public int addSchedule(ScheduleTask schedule,
boolean overwrite)
public int removeSchedule(ScheduleTask schedule)
public java.lang.String showSchedule()
public java.lang.String showSchedule(long lookAheadSeconds)
public java.lang.String showSchedule(Scheduler.ScheduleKey key,
long lookAheadSeconds)
public long getNextScheduledJob()
public long getNextScheduledJob(long lookAheadSeconds)
public static java.util.Properties getSchedulerProperties()
public static java.lang.String getSiamHome()
public static java.lang.String getScheduleDirectory()
public java.lang.String getDefaultSystemScheduleName()
public java.lang.String getDefaultSampleScheduleName()
public static java.lang.String getSchedulePath()
public static void loadDefaults()
public static final Scheduler.ScheduleKey getScheduleKey(ScheduleOwner owner)
public static void main(java.lang.String[] args)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||