diff options
author | Harald Musum <musum@yahooinc.com> | 2021-09-15 22:23:03 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2021-09-15 22:23:03 +0200 |
commit | d720d98e1c6b9ce70d9a2b516c01da0d59857477 (patch) | |
tree | f5e1c5541c25dad068c5cde978b96bcd646c590e | |
parent | b998d5f0db4d88db85e055e8985d70af3d3453a0 (diff) |
More cleanup of md5 usage
7 files changed, 13 insertions, 28 deletions
diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServer.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServer.java index d277ec66166..c7f6530f81c 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServer.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServer.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.proxy; import com.yahoo.jrt.Acceptor; @@ -270,7 +270,7 @@ public class ConfigProxyRpcServer implements Runnable, TargetWatcher, RpcServer */ private void getConfigImpl(JRTServerConfigRequest request) { request.getRequestTrace().trace(TRACELEVEL, "Config proxy getConfig()"); - log.log(Level.FINE, () ->"getConfig: " + request.getShortDescription() + ",configmd5=" + request.getRequestConfigMd5()); + log.log(Level.FINE, () ->"getConfig: " + request.getShortDescription() + ",config checksums=" + request.getRequestConfigChecksums()); if (!request.validateParameters()) { // Error code is set in verifyParameters if parameters are not OK. log.log(Level.WARNING, "Parameters for request " + request + " did not validate: " + request.errorCode() + " : " + request.errorMessage()); diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigSubscription.java b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigSubscription.java index bb1a154d5d0..e83fc7aefc5 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigSubscription.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigSubscription.java @@ -18,6 +18,7 @@ import java.time.Instant; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; +import static com.yahoo.vespa.config.PayloadChecksum.Type.MD5; import static java.util.logging.Level.FINE; import static java.util.logging.Level.INFO; @@ -129,7 +130,7 @@ public class JRTConfigSubscription<T extends ConfigInstance> extends ConfigSubsc Payload payload = jrtRequest.getNewPayload(); ConfigPayload configPayload = ConfigPayload.fromUtf8Array(payload.withCompression(CompressionType.UNCOMPRESSED).getData()); T configInstance = configPayload.toInstance(configClass, jrtRequest.getConfigKey().getConfigId()); - configInstance.setConfigMd5(jrtRequest.getNewConfigMd5()); // Note: Sets configmd5 in ConfigInstance + configInstance.setConfigMd5(jrtRequest.getNewChecksums().getForType(MD5).asString()); // Note: Sets configmd5 in ConfigInstance return configInstance; } diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTClientConfigRequest.java b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTClientConfigRequest.java index 9d3b87574f3..f47192c916c 100644 --- a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTClientConfigRequest.java +++ b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTClientConfigRequest.java @@ -59,13 +59,6 @@ public interface JRTClientConfigRequest extends JRTConfigRequest { boolean responseIsApplyOnRestart(); /** - * Gets the config md5 of the config returned by the server. Returns an empty string if no response has been returned. - * - * @return a config md5. - */ - String getNewConfigMd5(); - - /** * Gets the config checksums of the config returned by the server. Returns an empty string if no response has been returned. * * @return a config checksum. diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTClientConfigRequestV3.java b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTClientConfigRequestV3.java index bd69c77921d..68a9601cb02 100644 --- a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTClientConfigRequestV3.java +++ b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTClientConfigRequestV3.java @@ -178,7 +178,7 @@ public class JRTClientConfigRequestV3 implements JRTClientConfigRequest { StringBuilder sb = new StringBuilder(); sb.append("request='").append(getConfigKey()) .append(",").append(getClientHostName()) - .append(",").append(getRequestConfigMd5()) + .append(",").append(getRequestConfigChecksums()) .append(",").append(getRequestGeneration()) .append(",").append(getTimeout()) .append(",").append(getVespaVersion().map(VespaVersion::toString).orElse("")) @@ -233,12 +233,6 @@ public class JRTClientConfigRequestV3 implements JRTClientConfigRequest { return newChecksum; } - protected String newConfMd5() { - String newMd5 = getNewConfigMd5(); - if ("".equals(newMd5)) return getRequestConfigMd5(); - return newMd5; - } - protected long newGen() { long newGen = getNewGeneration(); if (newGen == 0) return getRequestGeneration(); @@ -312,11 +306,6 @@ public class JRTClientConfigRequestV3 implements JRTClientConfigRequest { } @Override - public String getNewConfigMd5() { - return responseData.getResponseConfigMd5().asString(); - } - - @Override public PayloadChecksums getNewChecksums() { return responseData.getResponseConfigChecksums(); } diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java index d342e42ec03..446ddf0560b 100644 --- a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java +++ b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java @@ -152,7 +152,7 @@ public class JRTServerConfigRequestV3 implements JRTServerConfigRequest { StringBuilder sb = new StringBuilder(); sb.append("request='").append(getConfigKey()) .append(",").append(getClientHostName()) - .append(",").append(getRequestConfigMd5()) + .append(",").append(getRequestConfigChecksums()) .append(",").append(getRequestGeneration()) .append(",").append(getTimeout()).append("'\n"); return sb.toString(); diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java index b1ed3a089ae..f7216058cf5 100644 --- a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java +++ b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java @@ -108,9 +108,9 @@ public class JRTConfigRequestV3Test { serverReq.addOkResponse(payload, 999999, false, PayloadChecksums.fromPayload(payload)); serverReq.addErrorResponse(ErrorCode.OUTDATED_CONFIG, "error message"); JRTClientConfigRequest next = clientReq.nextRequest(6); - // Should use config md5 and generation from the request, not the response - // when there are errors - assertThat(next.getRequestConfigMd5(), is(clientReq.getRequestConfigMd5())); + // Should use config checksums and generation from the request (not the response) when there are errors + assertThat(next.getRequestConfigChecksums().getForType(MD5), is(clientReq.getRequestConfigChecksums().getForType(MD5))); + assertThat(next.getRequestConfigChecksums().getForType(XXHASH64), is(clientReq.getRequestConfigChecksums().getForType(XXHASH64))); assertThat(next.getRequestGeneration(), is(clientReq.getRequestGeneration())); } @@ -118,12 +118,14 @@ public class JRTConfigRequestV3Test { public void ok_response_is_added() { Payload payload = createPayload("vale"); String md5 = ConfigUtils.getMd5(payload.getData()); + String xxhash64 = ConfigUtils.getXxhash64(payload.getData()); long generation = 4L; serverReq.addOkResponse(payload, generation, false, PayloadChecksums.fromPayload(payload)); assertTrue(clientReq.validateResponse()); assertThat(clientReq.getNewPayload().withCompression(CompressionType.UNCOMPRESSED).getData().toString(), is(payload.getData().toString())); assertThat(clientReq.getNewGeneration(), is(4L)); - assertThat(clientReq.getNewConfigMd5(), is(md5)); + assertThat(clientReq.getNewChecksums().getForType(MD5).asString(), is(md5)); + assertThat(clientReq.getNewChecksums().getForType(XXHASH64).asString(), is(xxhash64)); assertTrue(clientReq.hasUpdatedConfig()); assertTrue(clientReq.hasUpdatedGeneration()); } diff --git a/config/src/test/java/com/yahoo/vespa/config/util/ConfigUtilsTest.java b/config/src/test/java/com/yahoo/vespa/config/util/ConfigUtilsTest.java index 0276f3c4f1c..68f7e2b48fd 100644 --- a/config/src/test/java/com/yahoo/vespa/config/util/ConfigUtilsTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/util/ConfigUtilsTest.java @@ -76,7 +76,7 @@ public class ConfigUtilsTest { String md5 = getMd5(lines); assertThat(md5, is(not(expectedMd5))); - // Check that added characters aft comment character in string leads to a different md5 than above + // Check that added characters after comment character in string leads to a different md5 than above lines.add("foo=\"1#hello and some more and even more\""); assertThat(getMd5(lines), is(not(md5))); } |