Merge branch 'stable-3.5' into stable-3.6
* stable-3.5:
Fix eviction logic tests during prune phase
getIfPresent: fallback to fetching from store if isn't in memory
Fix failing test expectations on H2 analysis
Change-Id: Ib978a6ce91e4a8b1dd4bcc9aea5b3d7848cdb22b
diff --git a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheConfig.java b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheConfig.java
index e2c5afe..37d2845 100644
--- a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheConfig.java
+++ b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheConfig.java
@@ -264,7 +264,6 @@
static final ImmutableMap<String, DefaultConfig> defaultMap =
new ImmutableMap.Builder<String, DefaultConfig>()
.put("accounts", DefaultConfig.create(30, 256, 1000, 1))
- .put("approvals", DefaultConfig.create(103, 365, 1000, 3))
.put("change_kind", DefaultConfig.create(59, 26, 1000, 1))
.put("change_notes", DefaultConfig.create(36, 10240, 1000, 3))
.put("comment_context", DefaultConfig.create(80, 662, 2000, 3))
diff --git a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheFactory.java b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheFactory.java
index e4474b0..27be43f 100644
--- a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheFactory.java
+++ b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheFactory.java
@@ -21,7 +21,6 @@
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.metrics.MetricMaker;
-import com.google.gerrit.server.cache.CacheBackend;
import com.google.gerrit.server.cache.MemoryCacheFactory;
import com.google.gerrit.server.cache.PersistentCacheBaseFactory;
import com.google.gerrit.server.cache.PersistentCacheDef;
@@ -89,24 +88,20 @@
}
@Override
- public <K, V> Cache<K, V> buildImpl(
- PersistentCacheDef<K, V> in, long limit, CacheBackend backend) {
+ public <K, V> Cache<K, V> buildImpl(PersistentCacheDef<K, V> in, long limit) {
ChronicleMapCacheConfig config =
configFactory.create(
in.configKey(),
fileName(cacheDir, in.name(), in.version()),
in.expireAfterWrite(),
in.refreshAfterWrite());
- return build(in, backend, config, metricMaker);
+ return build(in, config, metricMaker);
}
@SuppressWarnings("unchecked")
@VisibleForTesting
<K, V> Cache<K, V> build(
- PersistentCacheDef<K, V> in,
- CacheBackend backend,
- ChronicleMapCacheConfig config,
- MetricMaker metricMaker) {
+ PersistentCacheDef<K, V> in, ChronicleMapCacheConfig config, MetricMaker metricMaker) {
ChronicleMapCacheDefProxy<K, V> def = new ChronicleMapCacheDefProxy<>(in);
ChronicleMapCacheImpl<K, V> cache;
@@ -120,7 +115,7 @@
LoadingCache<K, TimedValue<V>> mem =
(LoadingCache<K, TimedValue<V>>)
- memCacheFactory.build(def, (CacheLoader<K, V>) memLoader, backend);
+ memCacheFactory.build(def, (CacheLoader<K, V>) memLoader);
cache =
new ChronicleMapCacheImpl<>(
@@ -142,14 +137,14 @@
@Override
public <K, V> LoadingCache<K, V> buildImpl(
- PersistentCacheDef<K, V> in, CacheLoader<K, V> loader, long limit, CacheBackend backend) {
+ PersistentCacheDef<K, V> in, CacheLoader<K, V> loader, long limit) {
ChronicleMapCacheConfig config =
configFactory.create(
in.configKey(),
fileName(cacheDir, in.name(), in.version()),
in.expireAfterWrite(),
in.refreshAfterWrite());
- return build(in, loader, backend, config, metricMaker);
+ return build(in, loader, config, metricMaker);
}
@SuppressWarnings("unchecked")
@@ -157,7 +152,6 @@
public <K, V> LoadingCache<K, V> build(
PersistentCacheDef<K, V> in,
CacheLoader<K, V> loader,
- CacheBackend backend,
ChronicleMapCacheConfig config,
MetricMaker metricMaker) {
ChronicleMapCacheImpl<K, V> cache;
@@ -173,7 +167,7 @@
LoadingCache<K, TimedValue<V>> mem =
(LoadingCache<K, TimedValue<V>>)
- memCacheFactory.build(def, (CacheLoader<K, V>) memLoader, backend);
+ memCacheFactory.build(def, (CacheLoader<K, V>) memLoader);
cache =
new ChronicleMapCacheImpl<>(
diff --git a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheIT.java b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheIT.java
index 389fbb1..9367727 100644
--- a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheIT.java
+++ b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheIT.java
@@ -21,7 +21,6 @@
import com.google.gerrit.acceptance.UseLocalDisk;
import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.api.accounts.AccountInput;
-import com.google.gerrit.server.cache.CacheBackend;
import com.google.gerrit.server.cache.PersistentCacheFactory;
import com.google.inject.Inject;
import org.junit.Test;
@@ -46,8 +45,7 @@
public void shouldBuildInMemoryCacheWhenDiskLimitIsNegative() {
final int negativeDiskLimit = -1;
final Cache<String, String> cache =
- persistentCacheFactory.build(
- new TestPersistentCacheDef("foo", null, negativeDiskLimit, 0), CacheBackend.CAFFEINE);
+ persistentCacheFactory.build(new TestPersistentCacheDef("foo", null, negativeDiskLimit, 0));
assertThat(cache.getClass().getSimpleName()).isEqualTo("CaffeinatedGuavaCache");
}
@@ -57,8 +55,7 @@
final int positiveDiskLimit = 1024;
assertThat(
persistentCacheFactory.build(
- new TestPersistentCacheDef("foo", null, positiveDiskLimit, ZERO_INMEMORY_CACHE),
- CacheBackend.CAFFEINE))
+ new TestPersistentCacheDef("foo", null, positiveDiskLimit, ZERO_INMEMORY_CACHE)))
.isInstanceOf(ChronicleMapCacheImpl.class);
}
diff --git a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheTest.java b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheTest.java
index 4fe1614..58cc4ec 100644
--- a/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheTest.java
+++ b/src/test/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapCacheTest.java
@@ -28,7 +28,6 @@
import com.google.gerrit.common.Nullable;
import com.google.gerrit.metrics.DisabledMetricMaker;
import com.google.gerrit.metrics.MetricMaker;
-import com.google.gerrit.server.cache.CacheBackend;
import com.google.gerrit.server.cache.MemoryCacheFactory;
import com.google.gerrit.server.cache.serialize.CacheSerializer;
import com.google.gerrit.server.cache.serialize.StringCacheSerializer;
@@ -701,11 +700,10 @@
if (withLoader) {
return (ChronicleMapCacheImpl<String, String>)
- cacheFactory.build(
- cacheDef, cacheDef.loader(), CacheBackend.CAFFEINE, config, metricMaker);
+ cacheFactory.build(cacheDef, cacheDef.loader(), config, metricMaker);
}
return (ChronicleMapCacheImpl<String, String>)
- cacheFactory.build(cacheDef, CacheBackend.CAFFEINE, config, metricMaker);
+ cacheFactory.build(cacheDef, config, metricMaker);
}
private ChronicleMapCacheImpl<String, String> newCacheWithLoader(@Nullable String loadedValue) {