Package org.graylog.scheduler
Interface JobSchedule
- All Known Implementing Classes:
CronJobSchedule
,IntervalJobSchedule
,JobSchedule.FallbackSchedule
,OnceJobSchedule
public interface JobSchedule
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
static class
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionOptional<org.joda.time.DateTime>
calculateNextTime
(org.joda.time.DateTime lastExecutionTime, org.joda.time.DateTime lastNextTime, JobSchedulerClock clock) Calculates the next time a job should be executed based on the schedule implementation.toDBUpdate
(String fieldPrefix) Returns a map with the schedule data.type()
-
Field Details
-
TYPE_FIELD
- See Also:
-
-
Method Details
-
type
String type() -
calculateNextTime
Optional<org.joda.time.DateTime> calculateNextTime(org.joda.time.DateTime lastExecutionTime, org.joda.time.DateTime lastNextTime, JobSchedulerClock clock) Calculates the next time a job should be executed based on the schedule implementation. If this returns an emptyOptional
, 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 thelastNextTime
.The
lastNextTime
parameter is the lastnextTime
of the job trigger. This can be used to calculate the new next time. Using the previousnextTime
as base for the new one is more accurate than using the current time. (e.g. because of delayed execution and job duration)- Parameters:
lastExecutionTime
- the last execution time of a triggerlastNextTime
- the base time, chosen by the caller (mostly last nextTime)clock
-- Returns:
- filled optional with the next execution time, empty optional if there is no next execution time
-
toDBUpdate
Returns a map with the schedule data. This can be used to update a MongoDB document with schedule data. (seeJacksonDBCollection#update()
)- 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
-