Class QuartzTimeWindowChecker


  • public class QuartzTimeWindowChecker
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      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.
      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
      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
      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
      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.
      static boolean withinOperatingWindowOnRecovery​(long startTime, long endTime, long currentTime)
      Use when recovery context instance after a restart to the dashboard.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TWENTY_FOUR_HOURS_MILLISECONDS

        public static final long TWENTY_FOUR_HOURS_MILLISECONDS
        See Also:
        Constant Field Values
    • Constructor Detail

      • QuartzTimeWindowChecker

        public QuartzTimeWindowChecker()
    • 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 referenceDateTime
        startTimeCronExpression - to check
        contextTtl - to check
        referenceDateTime - 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 started
        endTime - millisecond of the projected end time for the context
        currentTime - 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 test
        timezone - to use
        referenceDateTime - 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 test
        referenceDateTime - 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 expressions
        startTimeCronExpression - to check
        endTimeCronExpression - to check
        referenceDateTime - 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 evaluate
        referenceZonedDateTime - 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: