org.mbari.siam.core
Class ScheduleTask

java.lang.Object
  extended by org.mbari.siam.core.ScheduleTask
All Implemented Interfaces:
Schedulable
Direct Known Subclasses:
ScheduleTaskImpl

public abstract class ScheduleTask
extends java.lang.Object
implements Schedulable

The ScheduleTask is a standalone job that may be scheduled, encapsulating both the represention and execution of the job. The ScheduleTask has a - ScheduleEntry representing the schedule itself - SiamTimerTask that does timing - ScheduleTimerTask timer task that is associated (created and destroyed with) the timer task Subclasses should - implement the execute method, calling owner methods

Author:
Kent Headley

Field Summary
static int CHECK_TIME
          readyAction: CHECK_TIME
static int COUNTER_EXPIRED
          Counter Expired
static int EXECUTING
          Executing
static int READY
          Ready
static int RUN
          readyAction: RUN
static int SUSPENDED
          Suspended
static int WAITING
          Waiting
 
Constructor Summary
ScheduleTask()
           
ScheduleTask(long interval, java.lang.String name, ScheduleOwner owner)
          Constructor
ScheduleTask(ScheduleSpecifier schedule, java.lang.String name, ScheduleOwner owner)
          Constructor
ScheduleTask(java.lang.String schedule, java.lang.String name, ScheduleOwner owner)
          Constructor
 
Method Summary
 void cancelTimer()
          Cancel Timer associated with this entry
 boolean equals(ScheduleTask schedule)
          Compare two ScheduleTasks
abstract  void execute()
          Subclasses must implement.
 void fakeJob()
          Execute fake Job associated with this entry
 java.lang.String get(int field)
          Get field
 java.util.Calendar getEntryTime()
          Get calendar representing current time in time zone indicate in this ScheduleTask
 java.util.Calendar getEntryTime(long time)
          Get calendar representing time in time zone indicate in this ScheduleTask
 java.lang.Integer getKey()
           
 long getLongCycles()
          Get Long Cycles
 java.lang.String getName()
           
 ScheduleOwner getOwner()
           
 long getOwnerID()
          Get owner ID
 java.lang.String getOwnerName()
           
 long getPeriod()
          Get (ScheduleSpecifier) period
 ScheduleSpecifier getScheduleSpecifier()
          Get _scheduleSpecifier member
 int getState()
          Get _state member
 java.lang.String getStateName(int state)
          Get name of state
 SiamTimer getTimer()
          getTimer
 SiamTimerTask getTimerTask()
          Get TimerTask
 java.util.TimeZone getTZ()
          Get TimeZone Object
 boolean isAbsolute()
          Return true if schedule type is absolute
 boolean isMasked()
           
 boolean isReady()
          Returns true if time matches or exceeds a scheduled time
 boolean isReady(long time)
          Returns true if time matches or exceeds a scheduled time
 boolean isRelative()
          Return true if schedule type is relative
 boolean isSelectedTime(java.util.Calendar calendar)
          Return true is calendar matches the schedule spec
 ScheduleTask parse(java.lang.String line)
          parse a line from the schedule file.
protected  void rescheduleTimer(java.util.Date startTime)
          Reschedule Timer
protected  void rescheduleTimer(long delay)
          Reschedule Timer
 void resetAbsoluteTimer()
          Reset (absolute) task according to next scheduled execution time.
 void resetTimer()
          Restart a timer; this differs from sync in that it doesn't cause an absolute schedule to run immediately.
 int resume()
          Resume ScheduleTask operation
 void setKey(int key)
           
 void setKey(java.lang.Integer key)
           
 void setLongCycles(long cycles)
          Set Long Cycles
 void setName(java.lang.String name)
           
 void setOwnerID(long id)
          Set Long Cycles
 void setOwnerName(java.lang.String name)
           
 void setSpecifier(ScheduleSpecifier spec)
          Set _scheduleSpecifier member
protected  void setState(int state)
          Set _state member
 void setTimer(SiamTimer timer)
          setTimer
 void setTimerTask(SiamTimerTask task)
          Set TimerTask
 long sleepingUntil()
          If owner says that executing thread is for this task is sleeping, return time (msec since epoch) at which task will resume.
 int suspend()
          Suspend ScheduleTask operation
 void sync()
          "Sync"* this scheduler entry after the specified delay.
 int sync(long delayMillis)
           
 long timeRemaining()
          Calculate time remaining to next scheduled execution
 long timeRemaining(long lookAheadSeconds)
          Calculate time remaining to next scheduled execution
 java.lang.String toString()
          toString() convert schedule entry to string
 java.lang.String toString(long lookAheadSeconds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WAITING

public static final int WAITING
Waiting

See Also:
Constant Field Values

EXECUTING

public static final int EXECUTING
Executing

See Also:
Constant Field Values

SUSPENDED

public static final int SUSPENDED
Suspended

See Also:
Constant Field Values

READY

public static final int READY
Ready

See Also:
Constant Field Values

COUNTER_EXPIRED

public static final int COUNTER_EXPIRED
Counter Expired

See Also:
Constant Field Values

RUN

public static final int RUN
readyAction: RUN

See Also:
Constant Field Values

CHECK_TIME

public static final int CHECK_TIME
readyAction: CHECK_TIME

See Also:
Constant Field Values
Constructor Detail

ScheduleTask

public ScheduleTask()

ScheduleTask

public ScheduleTask(java.lang.String schedule,
                    java.lang.String name,
                    ScheduleOwner owner)
             throws ScheduleParseException
Constructor

Parameters:
schedule - cron-like schedule
name - schedule name
owner - owner of this ScheduleTask
Throws:
ScheduleParseException

ScheduleTask

public ScheduleTask(ScheduleSpecifier schedule,
                    java.lang.String name,
                    ScheduleOwner owner)
             throws ScheduleParseException
Constructor

Parameters:
schedule - ScheduleSpecifier
name - schedule name
owner - owner of this ScheduleTask
Throws:
ScheduleParseException

ScheduleTask

public ScheduleTask(long interval,
                    java.lang.String name,
                    ScheduleOwner owner)
             throws ScheduleParseException
Constructor

Parameters:
interval - sample interval
name - schedule name
owner - owner of this ScheduleTask
Throws:
ScheduleParseException
Method Detail

getOwner

public ScheduleOwner getOwner()

getStateName

public java.lang.String getStateName(int state)
Get name of state


getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getOwnerName

public java.lang.String getOwnerName()

setOwnerName

public void setOwnerName(java.lang.String name)

getKey

public java.lang.Integer getKey()

setKey

public void setKey(int key)

setKey

public void setKey(java.lang.Integer key)

getScheduleSpecifier

public ScheduleSpecifier getScheduleSpecifier()
Get _scheduleSpecifier member


setSpecifier

public void setSpecifier(ScheduleSpecifier spec)
Set _scheduleSpecifier member


getState

public int getState()
Get _state member


setState

protected void setState(int state)
Set _state member


getTimer

public SiamTimer getTimer()
getTimer


setTimer

public void setTimer(SiamTimer timer)
setTimer


setTimerTask

public void setTimerTask(SiamTimerTask task)
Set TimerTask


getTimerTask

public SiamTimerTask getTimerTask()
Get TimerTask


getPeriod

public long getPeriod()
Get (ScheduleSpecifier) period


get

public java.lang.String get(int field)
Get field


getTZ

public java.util.TimeZone getTZ()
Get TimeZone Object


getLongCycles

public long getLongCycles()
Get Long Cycles


setLongCycles

public void setLongCycles(long cycles)
Set Long Cycles


getOwnerID

public long getOwnerID()
Get owner ID


setOwnerID

public void setOwnerID(long id)
Set Long Cycles


isAbsolute

public boolean isAbsolute()
Return true if schedule type is absolute


isRelative

public boolean isRelative()
Return true if schedule type is relative


isSelectedTime

public boolean isSelectedTime(java.util.Calendar calendar)
Return true is calendar matches the schedule spec


parse

public ScheduleTask parse(java.lang.String line)
                   throws ScheduleParseException
parse a line from the schedule file. Returns parsed ScheduleTask object (itself).

Throws:
ScheduleParseException

getEntryTime

public java.util.Calendar getEntryTime()
Get calendar representing current time in time zone indicate in this ScheduleTask


getEntryTime

public java.util.Calendar getEntryTime(long time)
Get calendar representing time in time zone indicate in this ScheduleTask


isReady

public boolean isReady()
Returns true if time matches or exceeds a scheduled time


isMasked

public boolean isMasked()

isReady

public boolean isReady(long time)
Returns true if time matches or exceeds a scheduled time


execute

public abstract void execute()
Subclasses must implement. Fulfills Schedulable interface

Specified by:
execute in interface Schedulable

fakeJob

public void fakeJob()
Execute fake Job associated with this entry


toString

public java.lang.String toString()
toString() convert schedule entry to string

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(long lookAheadSeconds)

timeRemaining

public long timeRemaining()
Calculate time remaining to next scheduled execution


timeRemaining

public long timeRemaining(long lookAheadSeconds)
Calculate time remaining to next scheduled execution


sync

public void sync()
"Sync"* this scheduler entry after the specified delay. For relative schedules, waits delay ms and runs with it's original period from that point forward. For absolute schedules, waits delay ms, runs, and then returns to it's original schedule. (*) The term "sync" is a holdover from the OASIS controller, which had a "sync" command to perform this function.


sync

public int sync(long delayMillis)

resetTimer

public void resetTimer()
Restart a timer; this differs from sync in that it doesn't cause an absolute schedule to run immediately. Use this to start timer initially.


resetAbsoluteTimer

public void resetAbsoluteTimer()
Reset (absolute) task according to next scheduled execution time.


rescheduleTimer

protected void rescheduleTimer(long delay)
Reschedule Timer


rescheduleTimer

protected void rescheduleTimer(java.util.Date startTime)
Reschedule Timer


cancelTimer

public void cancelTimer()
Cancel Timer associated with this entry


suspend

public int suspend()
Suspend ScheduleTask operation


resume

public int resume()
Resume ScheduleTask operation


equals

public boolean equals(ScheduleTask schedule)
Compare two ScheduleTasks


sleepingUntil

public long sleepingUntil()
If owner says that executing thread is for this task is sleeping, return time (msec since epoch) at which task will resume. If executing thread is not sleeping, return 0.



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.