aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2021-09-08 09:25:48 +0200
committerHarald Musum <musum@yahooinc.com>2021-09-08 09:25:48 +0200
commit2e281a0e35a2a0bf96c34642fbe169d32fda19d6 (patch)
tree333f1ce87e1956dfa845ecb4a112139282d22904 /config
parentb4e87c7a777d62026080fd0ee45e34c69c1ea71c (diff)
Remove def md5 from ConfigKey
Diffstat (limited to 'config')
-rwxr-xr-xconfig/src/main/java/com/yahoo/vespa/config/ConfigKey.java20
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/GetConfigRequest.java9
-rwxr-xr-xconfig/src/main/java/com/yahoo/vespa/config/RawConfig.java4
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java4
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/protocol/JRTClientConfigRequestV3.java5
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequest.java31
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequest.java7
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequestV3.java8
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/protocol/RequestValidation.java2
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/protocol/SlimeRequestData.java16
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java9
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java48
12 files changed, 91 insertions, 72 deletions
diff --git a/config/src/main/java/com/yahoo/vespa/config/ConfigKey.java b/config/src/main/java/com/yahoo/vespa/config/ConfigKey.java
index 6fcdc19cf97..9a7ac58e339 100755
--- a/config/src/main/java/com/yahoo/vespa/config/ConfigKey.java
+++ b/config/src/main/java/com/yahoo/vespa/config/ConfigKey.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;
import com.yahoo.config.ConfigInstance;
@@ -17,7 +17,6 @@ public class ConfigKey<CONFIGCLASS extends ConfigInstance> implements Comparable
// The two fields below are only set when ConfigKey is constructed from a config class. Can be null
private final Class<CONFIGCLASS> configClass;
- private final String md5; // config definition md5
/**
* Constructs new key
@@ -27,7 +26,7 @@ public class ConfigKey<CONFIGCLASS extends ConfigInstance> implements Comparable
* @param namespace namespace for this config definition
*/
public ConfigKey(String name, String configIdString, String namespace) {
- this(name, configIdString, namespace, null, null);
+ this(name, configIdString, namespace, null);
}
/**
@@ -38,10 +37,12 @@ public class ConfigKey<CONFIGCLASS extends ConfigInstance> implements Comparable
*/
public ConfigKey(Class<CONFIGCLASS> clazz, String configIdString) {
this(getFieldFromClass(clazz, "CONFIG_DEF_NAME"),
- configIdString, getFieldFromClass(clazz, "CONFIG_DEF_NAMESPACE"), getFieldFromClass(clazz, "CONFIG_DEF_MD5"), clazz);
+ configIdString,
+ getFieldFromClass(clazz, "CONFIG_DEF_NAMESPACE"),
+ clazz);
}
- public ConfigKey(String name, String configIdString, String namespace, String defMd5, Class<CONFIGCLASS> clazz) {
+ public ConfigKey(String name, String configIdString, String namespace, Class<CONFIGCLASS> clazz) {
if (name == null || name.isEmpty())
throw new ConfigurationRuntimeException("Config name cannot be null or empty!");
if (namespace == null || namespace.isEmpty())
@@ -49,7 +50,6 @@ public class ConfigKey<CONFIGCLASS extends ConfigInstance> implements Comparable
this.name = name;
this.configId = (configIdString == null) ? "" : configIdString;
this.namespace = namespace;
- this.md5 = (defMd5 == null) ? "" : defMd5;
this.configClass = clazz;
}
@@ -108,10 +108,6 @@ public class ConfigKey<CONFIGCLASS extends ConfigInstance> implements Comparable
return configClass;
}
- public String getMd5() {
- return md5;
- }
-
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("name=");
@@ -123,8 +119,8 @@ public class ConfigKey<CONFIGCLASS extends ConfigInstance> implements Comparable
return sb.toString();
}
- public static ConfigKey<?> createFull(String name, String configId, String namespace, String md5) {
- return new ConfigKey<>(name, configId, namespace, md5, null);
+ public static ConfigKey<?> createFull(String name, String configId, String namespace) {
+ return new ConfigKey<>(name, configId, namespace, null);
}
}
diff --git a/config/src/main/java/com/yahoo/vespa/config/GetConfigRequest.java b/config/src/main/java/com/yahoo/vespa/config/GetConfigRequest.java
index c5eeab74157..4e90ce532e4 100644
--- a/config/src/main/java/com/yahoo/vespa/config/GetConfigRequest.java
+++ b/config/src/main/java/com/yahoo/vespa/config/GetConfigRequest.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;
import com.yahoo.vespa.config.protocol.DefContent;
@@ -37,4 +37,11 @@ public interface GetConfigRequest {
*/
boolean noCache();
+ /**
+ * Returns the md5 of the config definition in the request.
+ *
+ * @return an md5 of config definition in request.
+ */
+ String getRequestDefMd5();
+
}
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 366387f46af..028e84e4c29 100755
--- a/config/src/main/java/com/yahoo/vespa/config/RawConfig.java
+++ b/config/src/main/java/com/yahoo/vespa/config/RawConfig.java
@@ -77,7 +77,7 @@ public class RawConfig extends ConfigInstance {
*/
public static RawConfig createFromResponseParameters(JRTClientConfigRequest req) {
return new RawConfig(req.getConfigKey(),
- req.getConfigKey().getMd5(),
+ ConfigUtils.getDefMd5(req.getDefContent().asList()),
req.getNewPayload(),
req.getNewConfigMd5(),
req.getNewGeneration(),
@@ -94,7 +94,7 @@ public class RawConfig extends ConfigInstance {
*/
public static RawConfig createFromServerRequest(JRTServerConfigRequest req) {
return new RawConfig(req.getConfigKey(),
- req.getConfigKey().getMd5() ,
+ ConfigUtils.getDefMd5(req.getDefContent().asList()),
Payload.from(new Utf8String(""), CompressionInfo.uncompressed()),
req.getRequestConfigMd5(),
req.getRequestGeneration(),
diff --git a/config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java b/config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java
index 26c5889c579..adb27f37413 100644
--- a/config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java
+++ b/config/src/main/java/com/yahoo/vespa/config/benchmark/LoadTester.java
@@ -1,4 +1,4 @@
-// Copyright Verizon Media. 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.benchmark;
import com.yahoo.collections.Tuple2;
@@ -252,7 +252,7 @@ public class LoadTester {
private JRTClientConfigRequest createRequest(ConfigKey<?> reqKey) {
ConfigDefinitionKey dKey = new ConfigDefinitionKey(reqKey);
Tuple2<String, String[]> defContent = defs.get(dKey);
- ConfigKey<?> fullKey = createFull(reqKey.getName(), reqKey.getConfigId(), reqKey.getNamespace(), defContent.first);
+ ConfigKey<?> fullKey = createFull(reqKey.getName(), reqKey.getConfigId(), reqKey.getNamespace());
final long serverTimeout = 1000;
return JRTClientConfigRequestV3.createWithParams(fullKey, DefContent.fromList(List.of(defContent.second)),
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 23e3259ff8b..f5b558550e4 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
@@ -260,6 +260,11 @@ public class JRTClientConfigRequestV3 implements JRTClientConfigRequest {
}
@Override
+ public String getRequestDefMd5() {
+ return requestData.getRequestDefMd5();
+ }
+
+ @Override
public boolean validateResponse() {
if (request.isError()) {
return false;
diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequest.java b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequest.java
index 0e88eeb4e98..5b8f040b8e3 100644
--- a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequest.java
+++ b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequest.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.protocol;
import com.yahoo.jrt.Request;
@@ -14,14 +14,14 @@ import java.util.Optional;
public interface JRTConfigRequest {
/**
- * Get the config key of the config request.
+ * Returns the config key of the config request.
*
* @return a {@link ConfigKey}.
*/
ConfigKey<?> getConfigKey();
/**
- * Perform request parameter validation of this config request. This method should be called before fetching
+ * Performs request parameter validation of this config request. This method should be called before fetching
* any kind of config protocol-specific parameter.
*
* @return true if valid, false if not.
@@ -29,21 +29,28 @@ public interface JRTConfigRequest {
boolean validateParameters();
/**
- * Get the config md5 of the config request. Return an empty string if no response has been returned.
+ * Returns the config md5 of the config request. Return an empty string if no response has been returned.
*
* @return a config md5.
*/
String getRequestConfigMd5();
/**
- * Get the generation of the requested config. If none has been given, 0 should be returned.
+ * Returns the md5 of the config definition in the request.
+ *
+ * @return an md5 of config definition in request.
+ */
+ String getRequestDefMd5();
+
+ /**
+ * Returns the generation of the requested config. If none has been given, 0 should be returned.
*
* @return the generation in the request.
*/
long getRequestGeneration();
/**
- * Get the JRT request object for this config request.
+ * Returns the JRT request object for this config request.
* TODO: This method leaks the internal jrt stuff :(
*
* @return a {@link Request} object.
@@ -51,14 +58,14 @@ public interface JRTConfigRequest {
Request getRequest();
/**
- * Get a short hand description of this request.
+ * Returns a short hand description of this request.
*
* @return a short description
*/
String getShortDescription();
/**
- * Get the error code of this request
+ * Returns the error code of this request
*
* @return the error code as defined in {@link com.yahoo.vespa.config.ErrorCode}.
*/
@@ -72,27 +79,27 @@ public interface JRTConfigRequest {
String errorMessage();
/**
- * Get the server timeout of this request.
+ * Returns the server timeout of this request.
*
* @return the timeout given to the server
*/
long getTimeout();
/**
- * Get the config protocol version
+ * Returns the config protocol version
*
* @return a protocol version number.
*/
long getProtocolVersion();
/**
- * Get the host name of the client that is requesting config.
+ * Returns the host name of the client that is requesting config.
* @return hostname of the client.
*/
String getClientHostName();
/**
- * Get the Vespa version of the client that initiated the request
+ * Returns the Vespa version of the client that initiated the request
*
* @return Vespa version of the client
*/
diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequest.java b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequest.java
index c085be5924c..abc2b0b4473 100644
--- a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequest.java
+++ b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequest.java
@@ -46,6 +46,13 @@ public interface JRTServerConfigRequest extends JRTConfigRequest, GetConfigReque
String getRequestConfigMd5();
/**
+ * Returns the md5 of the config definition in the request.
+ *
+ * @return an md5 of config definition in request.
+ */
+ String getRequestDefMd5();
+
+ /**
* Get the current config generation of the client config.
*
* @return the current config generation.
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 4575368cc6a..e0a5b23a6d4 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
@@ -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.protocol;
import com.fasterxml.jackson.core.JsonFactory;
@@ -15,7 +15,6 @@ import com.yahoo.vespa.config.util.ConfigUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
-import java.util.Arrays;
import java.util.Optional;
import java.util.logging.Logger;
@@ -192,6 +191,9 @@ public class JRTServerConfigRequestV3 implements JRTServerConfigRequest {
return requestData.getRequestConfigMd5();
}
+ @Override
+ public String getRequestDefMd5() { return requestData.getRequestDefMd5(); }
+
private void addErrorResponse(int errorCode) {
addErrorResponse(errorCode, ErrorCode.getName(errorCode));
}
@@ -222,7 +224,7 @@ public class JRTServerConfigRequestV3 implements JRTServerConfigRequest {
setResponseField(jsonGenerator, SlimeResponseData.RESPONSE_VERSION, getProtocolVersion());
setResponseField(jsonGenerator, SlimeResponseData.RESPONSE_DEF_NAME, key.getName());
setResponseField(jsonGenerator, SlimeResponseData.RESPONSE_DEF_NAMESPACE, key.getNamespace());
- setResponseField(jsonGenerator, SlimeResponseData.RESPONSE_DEF_MD5, key.getMd5());
+ setResponseField(jsonGenerator, SlimeResponseData.RESPONSE_DEF_MD5, requestData.getRequestDefMd5());
setResponseField(jsonGenerator, SlimeResponseData.RESPONSE_CONFIGID, key.getConfigId());
setResponseField(jsonGenerator, SlimeResponseData.RESPONSE_CLIENT_HOSTNAME, requestData.getClientHostName());
jsonGenerator.writeFieldName(SlimeResponseData.RESPONSE_TRACE);
diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/RequestValidation.java b/config/src/main/java/com/yahoo/vespa/config/protocol/RequestValidation.java
index 81ea99e38b4..7db15844e8b 100644
--- a/config/src/main/java/com/yahoo/vespa/config/protocol/RequestValidation.java
+++ b/config/src/main/java/com/yahoo/vespa/config/protocol/RequestValidation.java
@@ -29,7 +29,7 @@ public class RequestValidation {
log.log(INFO, "Illegal name space '" + key.getNamespace() + "'");
return ErrorCode.ILLEGAL_NAME_SPACE;
}
- if (!(new PayloadChecksum(key.getMd5()).valid())) {
+ if (!(new PayloadChecksum(request.getRequestDefMd5()).valid())) {
log.log(INFO, "Illegal checksum '" + key.getNamespace() + "'");
return ErrorCode.ILLEGAL_DEF_MD5; // TODO: Use ILLEGAL_DEF_CHECKSUM
}
diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/SlimeRequestData.java b/config/src/main/java/com/yahoo/vespa/config/protocol/SlimeRequestData.java
index 447bc63eeb6..b885623a78b 100644
--- a/config/src/main/java/com/yahoo/vespa/config/protocol/SlimeRequestData.java
+++ b/config/src/main/java/com/yahoo/vespa/config/protocol/SlimeRequestData.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.protocol;
import com.yahoo.jrt.Request;
@@ -7,6 +7,7 @@ import com.yahoo.slime.Inspector;
import com.yahoo.slime.Slime;
import com.yahoo.slime.SlimeUtils;
import com.yahoo.vespa.config.ConfigKey;
+import com.yahoo.vespa.config.util.ConfigUtils;
import java.util.Optional;
@@ -57,9 +58,8 @@ class SlimeRequestData {
ConfigKey<?> getConfigKey() {
return ConfigKey.createFull(getRequestField(REQUEST_DEF_NAME).asString(),
- getRequestField(REQUEST_CLIENT_CONFIGID).asString(),
- getRequestField(REQUEST_DEF_NAMESPACE).asString(),
- getRequestField(REQUEST_DEF_MD5).asString());
+ getRequestField(REQUEST_CLIENT_CONFIGID).asString(),
+ getRequestField(REQUEST_DEF_NAMESPACE).asString());
}
DefContent getSchema() {
@@ -75,9 +75,9 @@ class SlimeRequestData {
return getRequestField(REQUEST_TIMEOUT).asLong();
}
- String getRequestConfigMd5() {
- return getRequestField(REQUEST_CONFIG_MD5).asString();
- }
+ String getRequestConfigMd5() { return getRequestField(REQUEST_CONFIG_MD5).asString(); }
+
+ String getRequestDefMd5() { return getRequestField(REQUEST_DEF_MD5).asString(); }
long getRequestGeneration() {
return getRequestField(REQUEST_CURRENT_GENERATION).asLong();
@@ -98,7 +98,7 @@ class SlimeRequestData {
request.setLong(REQUEST_VERSION, protocolVersion);
request.setString(REQUEST_DEF_NAME, key.getName());
request.setString(REQUEST_DEF_NAMESPACE, key.getNamespace());
- request.setString(REQUEST_DEF_MD5, key.getMd5());
+ request.setString(REQUEST_DEF_MD5, ConfigUtils.getDefMd5(defSchema.asList()));
request.setString(REQUEST_CLIENT_CONFIGID, key.getConfigId());
request.setString(REQUEST_CLIENT_HOSTNAME, hostname);
defSchema.serialize(request.setArray(REQUEST_DEF_CONTENT));
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java
index 452d0d78897..e6bc13248fd 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigKeyTest.java
@@ -1,14 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config;
+import com.yahoo.config.ConfigurationRuntimeException;
+import com.yahoo.foo.AppConfig;
+import org.junit.Test;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import com.yahoo.foo.AppConfig;
-import com.yahoo.config.ConfigurationRuntimeException;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -52,7 +52,6 @@ public class ConfigKeyTest {
assertEquals("Name is set correctly from class", name, classKey.getName());
assertEquals("Namespace is set correctly from class", namespace, classKey.getNamespace());
assertEquals(configId, classKey.getConfigId());
- assertEquals("Md5 is set correctly from class", md5, classKey.getMd5());
ConfigKey<?> stringKey = new ConfigKey<>(name, configId, namespace);
assertEquals("Key created from class equals key created from strings", stringKey, classKey);
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 b67a9ef0fb8..d6ce246aa1f 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
@@ -23,8 +23,8 @@ import com.yahoo.vespa.config.util.ConfigUtils;
import org.junit.Before;
import org.junit.Test;
-import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
import java.util.Optional;
import static org.hamcrest.CoreMatchers.is;
@@ -39,12 +39,17 @@ import static org.junit.Assert.assertTrue;
*/
public class JRTConfigRequestV3Test {
+ private static final String [] configDefinition = new String[]{
+ "namespace=my.name.space",
+ "myfield string"
+ };
+
private final Optional<VespaVersion> vespaVersion = Optional.of(VespaVersion.fromString("5.38.24"));
private final String defName = "mydef";
private final String defNamespace = "my.name.space";
private final String hostname = "myhost";
private final String configId = "config/id";
- private final String defMd5 = "595f44fec1e92a71d3e9e77456ba80d1";
+ private final String defMd5 = ConfigUtils.getDefMd5(List.of(configDefinition));
private final long currentGeneration = 3;
private final long timeout = 5000;
private Trace trace ;
@@ -220,13 +225,12 @@ public class JRTConfigRequestV3Test {
@Test
public void parameters_are_validated() {
assertTrue(serverReq.validateParameters());
- assertValidationFail(createReq("35#$#!$@#", defNamespace, defMd5, hostname, configId, configMd5, currentGeneration, timeout, trace));
- assertValidationFail(createReq(defName, "abcd.o#$*(!&$", defMd5, hostname, configId, configMd5, currentGeneration, timeout, trace));
- assertValidationFail(createReq(defName, defNamespace, "34", hostname, configId, "34", currentGeneration, timeout, trace));
- assertValidationFail(createReq(defName, defNamespace, defMd5, hostname, configId, "34", currentGeneration, timeout, trace));
- assertValidationFail(createReq(defName, defNamespace, defMd5, hostname, configId, configMd5, -34, timeout, trace));
- assertValidationFail(createReq(defName, defNamespace, defMd5, hostname, configId, configMd5, currentGeneration, -23, trace));
- assertValidationFail(createReq(defName, defNamespace, defMd5, "", configId, configMd5, currentGeneration, timeout, trace));
+ assertValidationFail(createReq("35#$#!$@#", defNamespace, hostname, configId, configMd5, currentGeneration, timeout, trace));
+ assertValidationFail(createReq(defName, "abcd.o#$*(!&$", hostname, configId, configMd5, currentGeneration, timeout, trace));
+ assertValidationFail(createReq(defName, defNamespace, hostname, configId, "34", currentGeneration, timeout, trace));
+ assertValidationFail(createReq(defName, defNamespace, hostname, configId, configMd5, -34, timeout, trace));
+ assertValidationFail(createReq(defName, defNamespace, hostname, configId, configMd5, currentGeneration, -23, trace));
+ assertValidationFail(createReq(defName, defNamespace, "", configId, configMd5, currentGeneration, timeout, trace));
}
private void assertValidationFail(JRTClientConfigRequest req) {
@@ -243,11 +247,11 @@ public class JRTConfigRequestV3Test {
return Payload.from(new ConfigPayload(slime));
}
- private JRTClientConfigRequest createReq(String defName, String defNamespace, String defMd5,
+ private JRTClientConfigRequest createReq(String defName, String defNamespace,
String hostname, String configId, String configMd5,
long currentGeneration, long timeout, Trace trace) {
- return JRTClientConfigRequestV3.createWithParams(ConfigKey.createFull(defName, configId, defNamespace, defMd5),
- DefContent.fromList(Arrays.asList("namespace=my.name.space", "myfield string")),
+ return JRTClientConfigRequestV3.createWithParams(ConfigKey.createFull(defName, configId, defNamespace),
+ DefContent.fromList(List.of(configDefinition)),
hostname,
configMd5,
currentGeneration,
@@ -272,26 +276,22 @@ public class JRTConfigRequestV3Test {
private JRTClientConfigRequest createReq() {
trace = Trace.createNew(3, new ManualClock());
trace.trace(1, "hei");
- return createReq(defName, defNamespace, defMd5, hostname, configId, configMd5, currentGeneration, timeout, trace);
+ return createReq(defName, defNamespace, hostname, configId, configMd5, currentGeneration, timeout, trace);
}
private JRTClientConfigRequest createReq(Payload payload) {
trace = Trace.createNew(3, new ManualClock());
trace.trace(1, "hei");
- return createReq(defName, defNamespace, defMd5, hostname, configId, ConfigUtils.getMd5(payload.getData()), currentGeneration, timeout, trace);
+ return createReq(defName, defNamespace, hostname, configId, ConfigUtils.getMd5(payload.getData()), currentGeneration, timeout, trace);
}
private void request_is_parsed_base() {
- String [] expectedContent = new String[]{
- "namespace=my.name.space",
- "myfield string"
- };
System.out.println(serverReq.toString());
assertThat(serverReq.getConfigKey().getName(), is(defName));
assertThat(serverReq.getConfigKey().getNamespace(), is(defNamespace));
- assertThat(serverReq.getConfigKey().getMd5(), is(defMd5));
+ assertThat(serverReq.getRequestDefMd5(), is(defMd5));
assertThat(serverReq.getConfigKey().getConfigId(), is(configId));
- assertThat(serverReq.getDefContent().asStringArray(), is(expectedContent));
+ assertThat(serverReq.getDefContent().asStringArray(), is(configDefinition));
assertFalse(serverReq.noCache());
assertTrue(serverReq.getRequestTrace().toString().contains("hi"));
assertThat(serverReq.getRequestConfigMd5(), is(configMd5));
@@ -299,16 +299,12 @@ public class JRTConfigRequestV3Test {
}
private JRTServerConfigRequest next_request_is_correct_base() {
- String [] expectedContent = new String[]{
- "namespace=my.name.space",
- "myfield string"
- };
JRTServerConfigRequest next = createReq(clientReq.nextRequest(6).getRequest());
assertThat(next.getConfigKey().getName(), is(defName));
assertThat(next.getConfigKey().getNamespace(), is(defNamespace));
- assertThat(next.getConfigKey().getMd5(), is(defMd5));
+ assertThat(next.getRequestDefMd5(), is(defMd5));
assertThat(next.getConfigKey().getConfigId(), is(configId));
- assertThat(next.getDefContent().asStringArray(), is(expectedContent));
+ assertThat(next.getDefContent().asStringArray(), is(configDefinition));
assertFalse(next.noCache());
assertThat(next.getTimeout(), is(6L));
assertThat(next.getTimeout(), is(6L));