Package org.codelibs.fess.helper
Class IntervalControlHelper
java.lang.Object
org.codelibs.fess.helper.IntervalControlHelper
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a rule for controlling crawler intervals. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag indicating whether the crawler is currently runningprotected longWait time in milliseconds when crawler is not runningprotected List<IntervalControlHelper.IntervalRule> List of interval rules for controlling crawler timing -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIntervalRule(String from, String to, String days, long delay) Adds a new interval rule to the rule list.voidChecks the crawler status and waits if the crawler is not running.voidApplies delay based on the configured interval rules.protected CalendarGets the current calendar instance set to the system time.protected longgetDelay()Calculates the delay in milliseconds based on current time and configured rules.booleanChecks if the crawler is currently running.protected static int[]Parses a time string in HH:MM format.voidsetCrawlerRunning(boolean crawlerRunning) Sets the crawler running status.voidsetCrawlerWaitMillis(long crawlerWaitMillis) Sets the wait time in milliseconds when the crawler is not running.
-
Field Details
-
crawlerRunning
protected volatile boolean crawlerRunningFlag indicating whether the crawler is currently running -
crawlerWaitMillis
protected long crawlerWaitMillisWait 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
Gets the current calendar instance set to the system time.- Returns:
- the current calendar instance
-
addIntervalRule
Adds a new interval rule to the rule list.- Parameters:
from- the start time in HH:MM formatto- the end time in HH:MM formatdays- 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
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
-