diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-06-18 15:23:54 +0200 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-06-24 14:34:21 +0200 |
commit | a3f2f42774fc6f83b8bb743743a092ffc7b9bb50 (patch) | |
tree | 035aa4f53d80412c126f2de5f0df0647e4e70283 /sonar-home/src/main/java | |
parent | 62bded91ea52f42a71ad7d7624d5447b1a101420 (diff) | |
download | sonarqube-a3f2f42774fc6f83b8bb743743a092ffc7b9bb50.tar.gz sonarqube-a3f2f42774fc6f83b8bb743743a092ffc7b9bb50.zip |
SONAR-6649 Move initialization of persistit cache to global context
Diffstat (limited to 'sonar-home/src/main/java')
-rw-r--r-- | sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java | 8 | ||||
-rw-r--r-- | sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java | 8 |
2 files changed, 11 insertions, 5 deletions
diff --git a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java index a5d88ffcbe9..3ceeaa47f3d 100644 --- a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java +++ b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java @@ -52,15 +52,19 @@ public class PersistentCache { // eviction strategy is to expire entries after modification once a time duration has elapsed private final long defaultDurationToExpireMs; private final Log log; - private final boolean forceUpdate; + private boolean forceUpdate; public PersistentCache(Path baseDir, long defaultDurationToExpireMs, Log log, boolean forceUpdate) { this.baseDir = baseDir; this.defaultDurationToExpireMs = defaultDurationToExpireMs; this.log = log; - this.forceUpdate = forceUpdate; + reconfigure(forceUpdate); log.info("cache: " + baseDir + ", default expiration time (ms): " + defaultDurationToExpireMs); + } + + public void reconfigure(boolean forceUpdate) { + this.forceUpdate = forceUpdate; if (forceUpdate) { log.debug("cache: forcing update"); diff --git a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java index c8fcf06d4d0..c58dc53bbd6 100644 --- a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java +++ b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCacheBuilder.java @@ -30,17 +30,19 @@ import java.nio.file.Paths; import java.util.concurrent.TimeUnit; public class PersistentCacheBuilder { + private static final long DEFAULT_EXPIRE_DURATION = TimeUnit.MILLISECONDS.convert(1L, TimeUnit.DAYS); + private static final String DIR_NAME = "ws_cache"; + private boolean forceUpdate = false; private Path cachePath = null; private Log log = new StandardLog(); - private String name = "ws_cache"; public PersistentCache build() { if (cachePath == null) { setSonarHome(findHome()); } - return new PersistentCache(cachePath, TimeUnit.MILLISECONDS.convert(1L, TimeUnit.DAYS), log, forceUpdate); + return new PersistentCache(cachePath, DEFAULT_EXPIRE_DURATION, log, forceUpdate); } public PersistentCacheBuilder setLog(Log log) { @@ -50,7 +52,7 @@ public class PersistentCacheBuilder { public PersistentCacheBuilder setSonarHome(@Nullable Path p) { if (p != null) { - this.cachePath = p.resolve(name); + this.cachePath = p.resolve(DIR_NAME); } return this; } |