# SINCE 0.9.0
web.allowLuceneIndexing = true
+# Control the frequency of Lucene repository indexing.
+# The default setting is to check for updated refs every 2 mins.
+#
+# SINCE 1.6.1
+web.luceneFrequency = 2 mins
+
# Allows an authenticated user to create forks of a repository
#
# set this to false if you want to disable all fork controls on the web site
protected void configureLuceneIndexing() {
luceneExecutor = new LuceneService(settings, this);
- int period = 2;
- scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, period, TimeUnit.MINUTES);
- logger.info("Lucene will process indexed branches every {} minutes.", period);
+ String frequency = settings.getString(Keys.web.luceneFrequency, "2 mins");
+ int mins = TimeUtils.convertFrequencyToMinutes(frequency, 2);
+ scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, mins, TimeUnit.MINUTES);
+ logger.info("Lucene will process indexed branches every {} minutes.", mins);
}
protected void configureGarbageCollector() {
protected void configureMirrorExecutor() {
mirrorExecutor = new MirrorService(settings, this);
if (mirrorExecutor.isReady()) {
- int mins = TimeUtils.convertFrequencyToMinutes(settings.getString(Keys.git.mirrorPeriod, "30 mins"));
- if (mins < 5) {
- mins = 5;
- }
+ int mins = TimeUtils.convertFrequencyToMinutes(settings.getString(Keys.git.mirrorPeriod, "30 mins"), 5);
int delay = 1;
scheduledExecutor.scheduleAtFixedRate(mirrorExecutor, delay, mins, TimeUnit.MINUTES);
logger.info("Mirror service will fetch updates every {} minutes.", mins);
@Override
public void reschedule(FederationModel registration) {
// schedule the next pull
- int mins = TimeUtils.convertFrequencyToMinutes(registration.frequency);
+ int mins = TimeUtils.convertFrequencyToMinutes(registration.frequency, 5);
registration.nextPull = new Date(System.currentTimeMillis() + (mins * 60 * 1000L));
scheduledExecutor.schedule(new FederationPuller(registration), mins, TimeUnit.MINUTES);
logger.info(MessageFormat.format(
\r
// setup the last and netx pull dates\r
results.lastPull = new Date();\r
- int mins = TimeUtils.convertFrequencyToMinutes(results.frequency);\r
+ int mins = TimeUtils.convertFrequencyToMinutes(results.frequency, 5);\r
results.nextPull = new Date(System.currentTimeMillis() + (mins * 60 * 1000L));\r
\r
// acknowledge the receipt of status\r
* Convert a frequency string into minutes.\r
*\r
* @param frequency\r
+ * @param minimumMins\r
* @return minutes\r
*/\r
- public static int convertFrequencyToMinutes(String frequency) {\r
+ public static int convertFrequencyToMinutes(String frequency, int minimumMins) {\r
// parse the frequency\r
frequency = frequency.toLowerCase();\r
- int mins = 60;\r
+ int mins = minimumMins;\r
if (!StringUtils.isEmpty(frequency)) {\r
try {\r
String str = frequency.trim();\r
mins = (int) Float.parseFloat(str);\r
} catch (NumberFormatException e) {\r
}\r
- if (mins < 5) {\r
- mins = 5;\r
+ if (mins < minimumMins) {\r
+ mins = minimumMins;\r
+ }\r
+ if (frequency.indexOf("day") > -1) {\r
+ // convert to minutes\r
+ mins *= 1440;\r
+ } else if (frequency.indexOf("hour") > -1) {\r
+ // convert to minutes\r
+ mins *= 60;\r
}\r
- }\r
- if (frequency.indexOf("day") > -1) {\r
- // convert to minutes\r
- mins *= 1440;\r
- } else if (frequency.indexOf("hour") > -1) {\r
- // convert to minutes\r
- mins *= 60;\r
}\r
return mins;\r
}\r
\r
@Test\r
public void testFrequency() {\r
- assertEquals(5, TimeUtils.convertFrequencyToMinutes("2 mins"));\r
- assertEquals(10, TimeUtils.convertFrequencyToMinutes("10 mins"));\r
- assertEquals(600, TimeUtils.convertFrequencyToMinutes("10 hours"));\r
- assertEquals(14400, TimeUtils.convertFrequencyToMinutes(" 10 days "));\r
+ assertEquals(5, TimeUtils.convertFrequencyToMinutes("2 mins", 5));\r
+ assertEquals(10, TimeUtils.convertFrequencyToMinutes("10 mins", 5));\r
+ assertEquals(600, TimeUtils.convertFrequencyToMinutes("10 hours", 5));\r
+ assertEquals(14400, TimeUtils.convertFrequencyToMinutes(" 10 days ", 5));\r
}\r
}\r