1.0 Overview

Schedules are implemented as a CCE class, and the Timer for linux is cron(8).


2.0 Schedule

The attributes of a Schedule are converted to CCE properties as follows:

	Attribute	Property
	--------------- --------------
	Name		name
	Enabled		enabled
	Start Time	start_time
	Repeat Interval interval
	Action		action

Handlers for dealing with the events that effect Schedule's are implemented
as CCE handlers.  They are:

	Event		CCE Event  Handler(s)
	--------------  ---------  -----------
	Add		CREATE     create
	Modify		*	   modify
	Delete          DESTROY    delete

The Modify event is required to first remove the Schedule from the Timer
and then add it again if necessary.  Since these are the same actions taken
by the Add and Delete events, the code that implements them will be re-used
to handle events.


2.1 Add Event

When a Schedule is created, all of the parameters are checked for validity
and defaults are applied.  The start time and enabled properties are checked
to see if the Schedule should be added to the Timer and this action is
taken if necessary.


2.2 Modify Event

When a Schedule is modified, it is first removed from the Timer and then the
new attributes are examined to see if it should be added again.


2.3 Delete Event

No Schedule-specific actions are necessary when a Schedule object is deleted.
However, see below for the discussion of Timer Delete events.


3.0 Timer

The timer is implemented using cron(8).  The events that effect the Timer
are implemented as follows:

	Event       CCE Event         CCE Handler
	----------  ---------         -----------
	Add         Schedule.CREATE   Schedule.create
	Delete      Schedule.DELETE   Schedule.delete
        Run         None              None

Run events are handled by cron directly.  The Schedule start time is converted
to crontab(5) format using the mapping specified in the requirements.  The
action is added to the file as the command to execute.  In this way, the
only storage of Timer-specific attributes necessary is the Filename, which
is added to the Schedule class as follows:

	Attribute	Property
	--------------  --------------
	Filename	filename


3.1 Add Event

During an add event, the filename property is generated automatically to
ensure uniqueness.  The action is then added to the system by creating
the file specified by the filename property /etc/cron.d with mode 0600.

The format of the data in the file is that of crontab(5).  The attribute
specified for the timer were derived from crontab and the mapping in the
requirements document may be used directly.  The command line that will
be executed is the Timer run helper script as well as the action to be
executed.


3.2 Delete Event

A Timer delete event removes the file specified in the filename property from
/etc/cron.d.  If the action associated with the schedule is currently running,
it is stopped.


3.3 Run Event

cron(8) determines when the action is to be run.  When the event is run, the
helper shell script timer_run is executed with the action and action parameters
that will be executed.  The job is started and the PID of the action is stored
in /var/run/<filename>.pid, where <filename> is the name of the timer filename
property.  If the pid file exists and the process is also still extant, then
the new action will not be started.


