Class QuartzTimeWindowChecker
- java.lang.Object
-
- org.ikasan.job.orchestration.context.util.QuartzTimeWindowChecker
-
public class QuartzTimeWindowChecker extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static longTWENTY_FOUR_HOURS_MILLISECONDS
-
Constructor Summary
Constructors Constructor Description QuartzTimeWindowChecker()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanfallsWithinCronBlackoutWindows(java.util.List<java.lang.String> blackoutWindowCronExpressions, java.lang.String timezone, java.util.Date referenceDateTime)If any of the cronExpressions in the blackoutWindowCronExpressions are satisfied by the referenceDate return true The net effect is any cron expression in the list that matches 'now' will cause a blackout.static booleanfallsWithinDateTimeBlackoutRanges(java.util.Map<java.lang.Long,java.lang.Long> blackoutDateTimeRanges, java.util.Date referenceDateTime)The supplied blackoutDateTimeRanges represents a series of blackout windows i.e.protected static java.time.ZonedDateTimegetNextExecution(java.lang.String cronExpression, java.time.ZonedDateTime referenceZonedDateTime)Given the cron expression and a time zone reference date/time, provide the most recent matching next date time to the referenceZonedDateTimeprotected static java.time.ZonedDateTimegetPreviousExecution(java.lang.String cronExpression, java.time.ZonedDateTime referenceZonedDateTime)Given the cron expression and a time zone reference date/time, provide the most recent matching previous date time to the referenceZonedDateTimeprotected static booleanisOnFireTime(java.time.ZoneId zoneId, java.lang.String startTimeCronExpression, java.lang.String endTimeCronExpression, java.util.Date referenceDateTime)Determine if the supplied reference date time is on the fire time (exactly) of either the cron start or end expressionsstatic booleanwithinOperatingWindow(java.lang.String timezone, java.lang.String startTimeCronExpression, long contextTtl, java.util.Date referenceDateTime)Determine if the reference dateTime is within the start and end cron expressions.static booleanwithinOperatingWindowOnRecovery(long startTime, long endTime, long currentTime)Use when recovery context instance after a restart to the dashboard.
-
-
-
Field Detail
-
TWENTY_FOUR_HOURS_MILLISECONDS
public static final long TWENTY_FOUR_HOURS_MILLISECONDS
- See Also:
- Constant Field Values
-
-
Method Detail
-
withinOperatingWindow
public static boolean withinOperatingWindow(java.lang.String timezone, java.lang.String startTimeCronExpression, long contextTtl, java.util.Date referenceDateTime)Determine if the reference dateTime is within the start and end cron expressions.- Parameters:
timezone- to use to adjust referenceDateTimestartTimeCronExpression- to checkcontextTtl- to checkreferenceDateTime- to which we are comparing, note that date is not always UTC, just depends on how it is created. This method does not require the date/time to be UTC, it will be adjusted according to timezone- Returns:
- true if the reference date / time is within the range, false otherwise
-
withinOperatingWindowOnRecovery
public static boolean withinOperatingWindowOnRecovery(long startTime, long endTime, long currentTime)Use when recovery context instance after a restart to the dashboard. Takes in the start and end time stamped on the context instance and if the dashboard start time sit inside this, then it will be a candidate for this instance to be registered to the ContextMachine cache.- Parameters:
startTime- millisecond of when the context was startedendTime- millisecond of the projected end time for the contextcurrentTime- the current time of when this was called- Returns:
- true if current time is within the start time and end time false when outside
-
fallsWithinCronBlackoutWindows
public static boolean fallsWithinCronBlackoutWindows(java.util.List<java.lang.String> blackoutWindowCronExpressions, java.lang.String timezone, java.util.Date referenceDateTime)If any of the cronExpressions in the blackoutWindowCronExpressions are satisfied by the referenceDate return true The net effect is any cron expression in the list that matches 'now' will cause a blackout.- Parameters:
blackoutWindowCronExpressions- list to testtimezone- to usereferenceDateTime- to use- Returns:
- true if any cronExpression is satisfied by the reference date time, false otherwise
-
fallsWithinDateTimeBlackoutRanges
public static boolean fallsWithinDateTimeBlackoutRanges(java.util.Map<java.lang.Long,java.lang.Long> blackoutDateTimeRanges, java.util.Date referenceDateTime)The supplied blackoutDateTimeRanges represents a series of blackout windows i.e. BlackoutStart(UTC) -> BlackoutEnd(UTC) BlackoutStart2(UTC) -> BlackoutEnd2(UTC) If the supplied reference date time is within any of the windows, we are in blackout so return true. Note that we don't need the timezone because the Blackout start/end are saved in UTC relative to the timezone they relate to.- Parameters:
blackoutDateTimeRanges- map to testreferenceDateTime- to test, this will be converted to UTC, assumed to be in TZ relating to ranges.- Returns:
- true if the reference date time is within any of the supplied blackout windows.
-
isOnFireTime
protected static boolean isOnFireTime(java.time.ZoneId zoneId, java.lang.String startTimeCronExpression, java.lang.String endTimeCronExpression, java.util.Date referenceDateTime)Determine if the supplied reference date time is on the fire time (exactly) of either the cron start or end expressions- Parameters:
zoneId- used to adjust reference date time to mate the time zone associated with the cron expressionsstartTimeCronExpression- to checkendTimeCronExpression- to checkreferenceDateTime- to which we are comparing, note that date is not always UTC, just depends on how it is created. This method does not require the date/time to be UTC, it will be adjusted according to timezone- Returns:
- true if the supplied date/time is on the start or end cron expressions, false otherwise.
-
getPreviousExecution
protected static java.time.ZonedDateTime getPreviousExecution(java.lang.String cronExpression, java.time.ZonedDateTime referenceZonedDateTime)Given the cron expression and a time zone reference date/time, provide the most recent matching previous date time to the referenceZonedDateTime- Parameters:
cronExpression- to evaluatereferenceZonedDateTime- to use- Returns:
- a ZonedDateTime or null
-
getNextExecution
protected static java.time.ZonedDateTime getNextExecution(java.lang.String cronExpression, java.time.ZonedDateTime referenceZonedDateTime)Given the cron expression and a time zone reference date/time, provide the most recent matching next date time to the referenceZonedDateTime- Parameters:
cronExpression-referenceZonedDateTime-- Returns:
-
-