diff options
author | James Moger <james.moger@gitblit.com> | 2014-09-08 13:41:28 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-09-08 13:41:28 -0400 |
commit | 14181da41a98817aef2b528f92d58613e61e495f (patch) | |
tree | 3aaf6e9ea15ad8e4c26d15c6a47a65ff2450f062 /src/main/java/com/gitblit | |
parent | 696cb684a1ba095c195cdfc750728be8e94a7add (diff) | |
parent | 936af6a24bb80fc6177ecacc44a4be79d79f3de4 (diff) | |
download | gitblit-14181da41a98817aef2b528f92d58613e61e495f.tar.gz gitblit-14181da41a98817aef2b528f92d58613e61e495f.zip |
Merge branch 'ticket/161' into develop
Diffstat (limited to 'src/main/java/com/gitblit')
4 files changed, 19 insertions, 20 deletions
diff --git a/src/main/java/com/gitblit/manager/RepositoryManager.java b/src/main/java/com/gitblit/manager/RepositoryManager.java index 6a22db59..d9939bd4 100644 --- a/src/main/java/com/gitblit/manager/RepositoryManager.java +++ b/src/main/java/com/gitblit/manager/RepositoryManager.java @@ -1829,9 +1829,10 @@ public class RepositoryManager implements IRepositoryManager { 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() { @@ -1866,10 +1867,7 @@ public class RepositoryManager implements IRepositoryManager { 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); diff --git a/src/main/java/com/gitblit/manager/ServicesManager.java b/src/main/java/com/gitblit/manager/ServicesManager.java index 2550f66f..71858545 100644 --- a/src/main/java/com/gitblit/manager/ServicesManager.java +++ b/src/main/java/com/gitblit/manager/ServicesManager.java @@ -510,7 +510,7 @@ public class ServicesManager implements IServicesManager { @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( diff --git a/src/main/java/com/gitblit/servlet/FederationServlet.java b/src/main/java/com/gitblit/servlet/FederationServlet.java index 89ff2312..78709c9c 100644 --- a/src/main/java/com/gitblit/servlet/FederationServlet.java +++ b/src/main/java/com/gitblit/servlet/FederationServlet.java @@ -170,7 +170,7 @@ public class FederationServlet extends JsonServlet { // 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
diff --git a/src/main/java/com/gitblit/utils/TimeUtils.java b/src/main/java/com/gitblit/utils/TimeUtils.java index 4b113be2..c0e98e5d 100644 --- a/src/main/java/com/gitblit/utils/TimeUtils.java +++ b/src/main/java/com/gitblit/utils/TimeUtils.java @@ -322,12 +322,13 @@ public class TimeUtils { * 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();
@@ -337,16 +338,16 @@ public class TimeUtils { 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
+ mins *= 1440;
+ } else if (frequency.indexOf("hour") > -1) {
+ // convert to minutes
+ mins *= 60;
}
- }
- if (frequency.indexOf("day") > -1) {
- // convert to minutes
- mins *= 1440;
- } else if (frequency.indexOf("hour") > -1) {
- // convert to minutes
- mins *= 60;
}
return mins;
}
|