Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A jobTimer in the Clowder calls JobsScheduler.runScheduledJobs() every minute. This is done from Akka.system().scheduler.schedule in app/Global.
This time is then split into minute, hour, day_of_week, day_of_month variables in the JobsScheduler (app/models/JobsScheduler.scala) for further use in the code and for jobs’ maintenance.

The variables are stored as integers in the MongoDB Collection named jobs and any new time is compared against these values as a set of new integer values. In other words the time comparison is done by integer equality. A job gets fired hourly when minute1=minute2 if no other values of hour, day_of_week, day_of_month are defined. Similarly, the job gets executed with minutes and hours set (daily) when  minute1=minute2 and hour1=hour2 (no other values of day_of_week, day_of_month are defined) etc. Note that there is no verification of time inserted in the system, nor there is time/date object comparison.

A job model in Clowder is called TimerJob (app/models/TimerJob.scala). A programmer can create different job schema but the TimerJob is sufficient for the most repetitive tasks.
A full time, or only subset of it is set in the TimerJob with minute (0-59), hour (0-23), day_of_week (1-7 for Monday-Sunday) and day_of_month (1-31) precision. An option frequency is meant to be ‘hourly’, ‘daily’, ‘weekly’, ‘monthly’ but can be any descriptive string. The lastJobTime field is useful for  getting the time interval since the last job call (set by scheduler.updateLastRun(‘jobName’)). Additionally, parameters can be used for any object id, function is a string describing action (e.g. EmailDigest).

...