summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigTester.java6
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java8
-rwxr-xr-xconfig/src/main/java/com/yahoo/vespa/config/RawConfig.java2
-rw-r--r--config/src/vespa/config/frt/frtconfigrequestv3.cpp4
-rw-r--r--config/src/vespa/config/frt/frtconfigrequestv3.h2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ServerCache.java33
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java30
7 files changed, 44 insertions, 41 deletions
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigTester.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigTester.java
index 45f52479cbd..82c6099b45b 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigTester.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigTester.java
@@ -47,13 +47,13 @@ public class ConfigTester {
long generation = 1;
String defMd5 = ConfigUtils.getDefMd5(defContent);
- PayloadChecksums configMd5 = PayloadChecksums.from(new PayloadChecksum(ConfigUtils.getMd5(fooConfigPayload), MD5),
+ PayloadChecksums payloadChecksums = PayloadChecksums.from(new PayloadChecksum(ConfigUtils.getMd5(fooConfigPayload), MD5),
PayloadChecksum.empty(XXHASH64));
- fooConfig = new RawConfig(configKey, defMd5, fooPayload, configMd5,
+ fooConfig = new RawConfig(configKey, defMd5, fooPayload, payloadChecksums,
generation, false, defContent, Optional.empty());
String defName2 = "bar";
- barConfig = new RawConfig(new ConfigKey<>(defName2, configId, namespace), defMd5, fooPayload, configMd5,
+ barConfig = new RawConfig(new ConfigKey<>(defName2, configId, namespace), defMd5, fooPayload, payloadChecksums,
generation, false, defContent, Optional.empty());
}
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
index b47c0bcc5ce..953b67b3ea5 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
@@ -34,7 +34,7 @@ public class MemoryCacheTest {
private final String configId2 = "clients/gateways/gateway/component/com.yahoo.feedhandler.VespaFeedHandlerRemoveLocation";
private static final String defMd52 = "a2";
private static final String differentDefMd5 = "09ef";
- private static final PayloadChecksums configMd5 = PayloadChecksums.from("b", "");
+ private static final PayloadChecksums checksums = PayloadChecksums.from("b", "");
private final ConfigKey<?> configKey = new ConfigKey<>(defName, configId, namespace);
private final ConfigKey<?> configKey2 = new ConfigKey<>(defName2, configId2, namespace2);
private ConfigCacheKey cacheKey;
@@ -64,9 +64,9 @@ public class MemoryCacheTest {
slime.setString("bar \"value2\"");
payloadDifferentMd5 = Payload.from(new ConfigPayload(slime));
- config = new RawConfig(configKey, defMd5, payload, configMd5, generation, false, defContent, Optional.empty());
- config2 = new RawConfig(configKey2, defMd52, payload2, configMd5, generation, false, defContent, Optional.empty());
- configDifferentMd5 = new RawConfig(configKey, differentDefMd5, payloadDifferentMd5, configMd5, generation, false, defContent, Optional.empty());
+ config = new RawConfig(configKey, defMd5, payload, checksums, generation, false, defContent, Optional.empty());
+ config2 = new RawConfig(configKey2, defMd52, payload2, checksums, generation, false, defContent, Optional.empty());
+ configDifferentMd5 = new RawConfig(configKey, differentDefMd5, payloadDifferentMd5, checksums, generation, false, defContent, Optional.empty());
cacheKey = new ConfigCacheKey(configKey, config.getDefMd5());
cacheKey2 = new ConfigCacheKey(configKey2, config2.getDefMd5());
diff --git a/config/src/main/java/com/yahoo/vespa/config/RawConfig.java b/config/src/main/java/com/yahoo/vespa/config/RawConfig.java
index 71abaa9dc48..e2b2c9a1926 100755
--- a/config/src/main/java/com/yahoo/vespa/config/RawConfig.java
+++ b/config/src/main/java/com/yahoo/vespa/config/RawConfig.java
@@ -194,7 +194,7 @@ public class RawConfig extends ConfigInstance {
}
hash = 31 * hash + errorCode;
if (! isError()) {
- // configMd5 and generation only matter when the RawConfig is not an error.
+ // checksum and generation only matter when the RawConfig is not an error.
hash = 31 * hash + (int)(generation ^(generation >>>32));
hash = 31 * hash + payloadChecksums.hashCode();
}
diff --git a/config/src/vespa/config/frt/frtconfigrequestv3.cpp b/config/src/vespa/config/frt/frtconfigrequestv3.cpp
index 6dde698c438..bcea529c802 100644
--- a/config/src/vespa/config/frt/frtconfigrequestv3.cpp
+++ b/config/src/vespa/config/frt/frtconfigrequestv3.cpp
@@ -11,14 +11,14 @@ namespace config {
FRTConfigRequestV3::FRTConfigRequestV3(Connection * connection,
const ConfigKey & key,
- const vespalib::string & configMd5,
+ const vespalib::string & configXxhash64,
int64_t currentGeneration,
const vespalib::string & hostName,
int64_t serverTimeout,
const Trace & trace,
const VespaVersion & vespaVersion,
const CompressionType & compressionType)
- : SlimeConfigRequest(connection, key, configMd5, currentGeneration, hostName, serverTimeout, trace, vespaVersion, 3, compressionType, "config.v3.getConfig")
+ : SlimeConfigRequest(connection, key, configXxhash64, currentGeneration, hostName, serverTimeout, trace, vespaVersion, 3, compressionType, "config.v3.getConfig")
{
}
diff --git a/config/src/vespa/config/frt/frtconfigrequestv3.h b/config/src/vespa/config/frt/frtconfigrequestv3.h
index 28fa84b7584..32f8b7203c3 100644
--- a/config/src/vespa/config/frt/frtconfigrequestv3.h
+++ b/config/src/vespa/config/frt/frtconfigrequestv3.h
@@ -17,7 +17,7 @@ class FRTConfigRequestV3 : public SlimeConfigRequest {
public:
FRTConfigRequestV3(Connection * connection,
const ConfigKey & key,
- const vespalib::string & configMd5,
+ const vespalib::string & configXxhash64,
int64_t currentGeneration,
const vespalib::string & hostName,
int64_t serverTimeout,
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ServerCache.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ServerCache.java
index 3b765a3d8a7..6d6b93dad46 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ServerCache.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ServerCache.java
@@ -4,6 +4,7 @@ package com.yahoo.vespa.config.server;
import com.yahoo.config.model.api.ConfigDefinitionRepo;
import com.yahoo.vespa.config.ConfigCacheKey;
import com.yahoo.vespa.config.ConfigDefinitionKey;
+import com.yahoo.vespa.config.PayloadChecksum;
import com.yahoo.vespa.config.buildergen.ConfigDefinition;
import com.yahoo.vespa.config.protocol.ConfigResponse;
@@ -11,6 +12,8 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
+import static com.yahoo.vespa.config.PayloadChecksum.Type.XXHASH64;
+
/**
* Cache that holds configs and config definitions (builtin and user config definitions).
*
@@ -22,8 +25,8 @@ public class ServerCache {
private final ConfigDefinitionRepo userConfigDefinitions;
// NOTE: The reason we do a double mapping here is to de-dupe configs that have the same md5.
- private final Map<ConfigCacheKey, String> md5Sums = new ConcurrentHashMap<>();
- private final Map<String, ConfigResponse> md5ToConfig = new ConcurrentHashMap<>();
+ private final Map<ConfigCacheKey, PayloadChecksum> checksums = new ConcurrentHashMap<>();
+ private final Map<PayloadChecksum, ConfigResponse> checksumToConfig = new ConcurrentHashMap<>();
private final Object [] stripedLocks = new Object[113];
public ServerCache(ConfigDefinitionRepo builtinConfigDefinitions, ConfigDefinitionRepo userConfigDefinitions) {
@@ -40,15 +43,15 @@ public class ServerCache {
}
private void put(ConfigCacheKey key, ConfigResponse config) {
- String configMd5 = config.getConfigMd5();
- md5Sums.put(key, configMd5);
- md5ToConfig.put(configMd5, config);
+ PayloadChecksum xxhash64 = config.getPayloadChecksums().getForType(XXHASH64);
+ checksums.put(key, xxhash64);
+ checksumToConfig.put(xxhash64, config);
}
ConfigResponse get(ConfigCacheKey key) {
- String md5 = md5Sums.get(key);
- if (md5 == null) return null;
- return md5ToConfig.get(md5);
+ PayloadChecksum xxhash64 = checksums.get(key);
+ if (xxhash64 == null) return null;
+ return checksumToConfig.get(xxhash64);
}
public ConfigResponse computeIfAbsent(ConfigCacheKey key, Function<ConfigCacheKey, ConfigResponse> mappingFunction) {
@@ -57,13 +60,13 @@ public class ServerCache {
return config;
}
synchronized (stripedLocks[Math.abs(key.hashCode()%stripedLocks.length)]) {
- String md5 = md5Sums.get(key);
- if (md5 == null) {
+ PayloadChecksum xxhash64 = checksums.get(key);
+ if (xxhash64 == null) {
config = mappingFunction.apply(key);
put(key, config);
return config;
}
- return md5ToConfig.get(md5);
+ return checksumToConfig.get(xxhash64);
}
}
@@ -73,8 +76,8 @@ public class ServerCache {
sb.append("Cache\n");
sb.append("builtin defs: ").append(builtinConfigDefinitions.getConfigDefinitions().size()).append("\n");
sb.append("user defs: ").append(userConfigDefinitions.getConfigDefinitions().size()).append("\n");
- sb.append("md5sums: ").append(md5Sums.size()).append("\n");
- sb.append("md5ToConfig: ").append(md5ToConfig.size()).append("\n");
+ sb.append("md5sums: ").append(checksums.size()).append("\n");
+ sb.append("md5ToConfig: ").append(checksumToConfig.size()).append("\n");
return sb.toString();
}
@@ -89,7 +92,7 @@ public class ServerCache {
* @return elems
*/
public int configElems() {
- return md5ToConfig.size();
+ return checksumToConfig.size();
}
/**
@@ -97,7 +100,7 @@ public class ServerCache {
* @return elems
*/
public int checkSumElems() {
- return md5Sums.size();
+ return checksums.size();
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java
index 4d64e90a617..068a03d810c 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java
@@ -11,10 +11,10 @@ import com.yahoo.vespa.config.protocol.SlimeConfigResponse;
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
+import static com.yahoo.vespa.config.PayloadChecksum.Type.XXHASH64;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertSame;
/**
* @author Ulf Lilleengen
@@ -24,8 +24,8 @@ public class ServerCacheTest {
private static final String defMd5 = "595f44fec1e92a71d3e9e77456ba80d1";
private static final String defMd5_2 = "a2f8edfc965802bf6d44826f9da7e2b0";
- private static final String configMd5 = "mymd5";
- private static final String configMd5_2 = "mymd5_2";
+ private static final String xxhash64 = "595f44fec1e92a71d";
+ private static final String xxhash64_2 = "a2f8edfc965802bf6";
private static final ConfigDefinition def = new ConfigDefinition("mypayload", new String[0]);
private static final ConfigDefinitionKey fooBarDefKey = new ConfigDefinitionKey("foo", "bar");
@@ -48,31 +48,31 @@ public class ServerCacheTest {
cache = new ServerCache(new TestConfigDefinitionRepo(), userConfigDefinitionRepo);
- cache.computeIfAbsent(fooBarCacheKey, (ConfigCacheKey key) -> SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), 2, false, configMd5));
- cache.computeIfAbsent(bazQuuxCacheKey, (ConfigCacheKey key) -> SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), 2, false, configMd5));
- cache.computeIfAbsent(fooBarCacheKeyDifferentMd5, (ConfigCacheKey key) -> SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), 2, false, configMd5_2));
+ cache.computeIfAbsent(fooBarCacheKey, (ConfigCacheKey key) -> SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), 2, false, xxhash64));
+ cache.computeIfAbsent(bazQuuxCacheKey, (ConfigCacheKey key) -> SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), 2, false, xxhash64));
+ cache.computeIfAbsent(fooBarCacheKeyDifferentMd5, (ConfigCacheKey key) -> SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), 2, false, xxhash64_2));
}
@Test
public void testThatCacheWorks() {
assertNotNull(cache.getDef(fooBazDefKey));
- assertThat(cache.getDef(fooBarDefKey), is(def));
- assertThat(cache.getDef(fooBimDefKey).getCNode().getName(), is("mynode"));
+ assertEquals(def, cache.getDef(fooBarDefKey));
+ assertEquals("mynode", cache.getDef(fooBimDefKey).getCNode().getName());
ConfigResponse raw = cache.get(fooBarCacheKey);
- assertThat(raw.getConfigMd5(), is(configMd5));
+ assertEquals(xxhash64, raw.getPayloadChecksums().getForType(XXHASH64).asString());
}
@Test
public void testThatCacheWorksWithSameKeyDifferentMd5() {
- assertThat(cache.getDef(fooBarDefKey), is(def));
+ assertEquals(def, cache.getDef(fooBarDefKey));
ConfigResponse raw = cache.get(fooBarCacheKey);
- assertThat(raw.getConfigMd5(), is(configMd5));
+ assertEquals(xxhash64, raw.getPayloadChecksums().getForType(XXHASH64).asString());
raw = cache.get(fooBarCacheKeyDifferentMd5);
- assertThat(raw.getConfigMd5(), is(configMd5_2));
+ assertEquals(xxhash64_2, raw.getPayloadChecksums().getForType(XXHASH64).asString());
}
@Test
public void testThatCacheWorksWithDifferentKeySameMd5() {
- assertTrue(cache.get(fooBarCacheKey) == cache.get(bazQuuxCacheKey));
+ assertSame(cache.get(fooBarCacheKey), cache.get(bazQuuxCacheKey));
}
}