Expose setting to control Lucene repository indexing frequency
| | |
| | | # 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( |
| | |
| | |
|
| | | // setup the last and netx pull dates
|
| | | results.lastPull = new Date();
|
| | | int mins = TimeUtils.convertFrequencyToMinutes(results.frequency);
|
| | | int mins = TimeUtils.convertFrequencyToMinutes(results.frequency, 5);
|
| | | results.nextPull = new Date(System.currentTimeMillis() + (mins * 60 * 1000L));
|
| | |
|
| | | // acknowledge the receipt of status
|
| | |
| | | * Convert a frequency string into minutes.
|
| | | *
|
| | | * @param frequency
|
| | | * @param minimumMins
|
| | | * @return minutes
|
| | | */
|
| | | public static int convertFrequencyToMinutes(String frequency) {
|
| | | public static int convertFrequencyToMinutes(String frequency, int minimumMins) {
|
| | | // parse the frequency
|
| | | frequency = frequency.toLowerCase();
|
| | | int mins = 60;
|
| | | int mins = minimumMins;
|
| | | if (!StringUtils.isEmpty(frequency)) {
|
| | | try {
|
| | | String str = frequency.trim();
|
| | |
| | | mins = (int) Float.parseFloat(str);
|
| | | } catch (NumberFormatException e) {
|
| | | }
|
| | | if (mins < 5) {
|
| | | mins = 5;
|
| | | }
|
| | | if (mins < minimumMins) {
|
| | | mins = minimumMins;
|
| | | }
|
| | | if (frequency.indexOf("day") > -1) {
|
| | | // convert to minutes
|
| | |
| | | // convert to minutes
|
| | | mins *= 60;
|
| | | }
|
| | | }
|
| | | return mins;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | @Test
|
| | | public void testFrequency() {
|
| | | assertEquals(5, TimeUtils.convertFrequencyToMinutes("2 mins"));
|
| | | assertEquals(10, TimeUtils.convertFrequencyToMinutes("10 mins"));
|
| | | assertEquals(600, TimeUtils.convertFrequencyToMinutes("10 hours"));
|
| | | assertEquals(14400, TimeUtils.convertFrequencyToMinutes(" 10 days "));
|
| | | assertEquals(5, TimeUtils.convertFrequencyToMinutes("2 mins", 5));
|
| | | assertEquals(10, TimeUtils.convertFrequencyToMinutes("10 mins", 5));
|
| | | assertEquals(600, TimeUtils.convertFrequencyToMinutes("10 hours", 5));
|
| | | assertEquals(14400, TimeUtils.convertFrequencyToMinutes(" 10 days ", 5));
|
| | | }
|
| | | }
|