Class CronJobSchedule

java.lang.Object
org.graylog.scheduler.schedule.CronJobSchedule
All Implemented Interfaces:
JobSchedule

public abstract class CronJobSchedule extends Object implements JobSchedule
  • Field Details

  • Constructor Details

    • CronJobSchedule

      public CronJobSchedule()
  • Method Details

    • cronExpression

      public abstract String cronExpression()
    • calculateNextTime

      public Optional<org.joda.time.DateTime> calculateNextTime(org.joda.time.DateTime previousExecutionTime, org.joda.time.DateTime lastNextTime, JobSchedulerClock clock)
      Description copied from interface: JobSchedule
      Calculates the next time a job should be executed based on the schedule implementation. If this returns an empty Optional, there will be no next execution time. (e.g. for one-off jobs)

      The lastExecutionTime parameter is the last execution time of the trigger. This can be used to detect if the trigger has been executed way later than the lastNextTime.

      The lastNextTime parameter is the last nextTime of the job trigger. This can be used to calculate the new next time. Using the previous nextTime as base for the new one is more accurate than using the current time. (e.g. because of delayed execution and job duration)

      Specified by:
      calculateNextTime in interface JobSchedule
      Parameters:
      previousExecutionTime - the last execution time of a trigger
      lastNextTime - the base time, chosen by the caller (mostly last nextTime)
      Returns:
      filled optional with the next execution time, empty optional if there is no next execution time
    • toDBUpdate

      public Optional<Map<String,Object>> toDBUpdate(String fieldPrefix)
      Description copied from interface: JobSchedule
      Returns a map with the schedule data. This can be used to update a MongoDB document with schedule data. (see JacksonDBCollection#update())
      Specified by:
      toDBUpdate in interface JobSchedule
      Parameters:
      fieldPrefix - the field prefix to use for the map key
      Returns:
      filled optional with a map, empty optional if there is no update data
    • builder

      public static CronJobSchedule.Builder builder()
    • toBuilder

      public abstract CronJobSchedule.Builder toBuilder()