Class IntervalControlHelper

java.lang.Object
org.codelibs.fess.helper.IntervalControlHelper

public class IntervalControlHelper extends Object
Helper class for controlling crawler execution intervals and timing. This class manages crawler execution timing based on configurable rules that can specify different delays for different time periods and days.
  • Field Details

    • crawlerRunning

      protected volatile boolean crawlerRunning
      Flag indicating whether the crawler is currently running
    • crawlerWaitMillis

      protected long crawlerWaitMillis
      Wait time in milliseconds when crawler is not running
    • ruleList

      List of interval rules for controlling crawler timing
  • Constructor Details

    • IntervalControlHelper

      public IntervalControlHelper()
      Default constructor.
  • Method Details

    • checkCrawlerStatus

      public void checkCrawlerStatus()
      Checks the crawler status and waits if the crawler is not running. This method blocks until the crawler is running again.
    • delayByRules

      public void delayByRules()
      Applies delay based on the configured interval rules. This method calculates the appropriate delay for the current time and applies it by sleeping the current thread.
    • getDelay

      protected long getDelay()
      Calculates the delay in milliseconds based on current time and configured rules. The method checks each rule to see if it applies to the current time and day.
      Returns:
      the delay in milliseconds, or 0 if no rules apply
    • getCurrentCal

      protected Calendar getCurrentCal()
      Gets the current calendar instance set to the system time.
      Returns:
      the current calendar instance
    • addIntervalRule

      public void addIntervalRule(String from, String to, String days, long delay)
      Adds a new interval rule to the rule list.
      Parameters:
      from - the start time in HH:MM format
      to - the end time in HH:MM format
      days - comma-separated list of days (1=Sunday, 7=Saturday)
      delay - the delay in milliseconds to apply during this interval
    • isCrawlerRunning

      public boolean isCrawlerRunning()
      Checks if the crawler is currently running.
      Returns:
      true if the crawler is running, false otherwise
    • setCrawlerRunning

      public void setCrawlerRunning(boolean crawlerRunning)
      Sets the crawler running status.
      Parameters:
      crawlerRunning - true to indicate the crawler is running, false otherwise
    • parseTime

      protected static int[] parseTime(String time)
      Parses a time string in HH:MM format.
      Parameters:
      time - the time string to parse
      Returns:
      an array containing [hour, minute]
      Throws:
      FessSystemException - if the time format is invalid
    • setCrawlerWaitMillis

      public void setCrawlerWaitMillis(long crawlerWaitMillis)
      Sets the wait time in milliseconds when the crawler is not running.
      Parameters:
      crawlerWaitMillis - the wait time in milliseconds