diff options
author | Harald Musum <musum@yahoo-inc.com> | 2017-02-12 21:35:27 +0100 |
---|---|---|
committer | Harald Musum <musum@yahoo-inc.com> | 2017-02-12 21:35:27 +0100 |
commit | af0d7551f9c5d237ce7d5f239cb0d4b93217b3e6 (patch) | |
tree | c95e7c84933b8e8c7f908e75ea3cab1faf9311a4 /config | |
parent | 77026d390cb95bd203c5a594ecb869a856947751 (diff) |
Cleanup, no functional changes
* Remove unused fields and methods, changes access level, syntax
and comment fixese etc.
Diffstat (limited to 'config')
42 files changed, 75 insertions, 547 deletions
diff --git a/config/src/main/java/com/yahoo/config/subscription/ConfigGetter.java b/config/src/main/java/com/yahoo/config/subscription/ConfigGetter.java index be4ff9f1b79..0f25084c6d0 100755 --- a/config/src/main/java/com/yahoo/config/subscription/ConfigGetter.java +++ b/config/src/main/java/com/yahoo/config/subscription/ConfigGetter.java @@ -35,7 +35,6 @@ public class ConfigGetter<T extends ConfigInstance> { * @param source a {@link ConfigSource} * @param clazz a config class */ - // TODO This is the order of arguments in com.yahoo.config.ConfigGetter and kept here, I would like to switch the order public ConfigGetter(ConfigSource source, Class<T> clazz) { this.clazz = clazz; this.source = source; diff --git a/config/src/main/java/com/yahoo/config/subscription/ConfigHandle.java b/config/src/main/java/com/yahoo/config/subscription/ConfigHandle.java index 6cc10be8627..5bd09d1619a 100644 --- a/config/src/main/java/com/yahoo/config/subscription/ConfigHandle.java +++ b/config/src/main/java/com/yahoo/config/subscription/ConfigHandle.java @@ -15,7 +15,7 @@ import com.yahoo.config.subscription.impl.ConfigSubscription; */ public class ConfigHandle<T extends ConfigInstance> { - private ConfigSubscription<T> sub; + private final ConfigSubscription<T> sub; private boolean changed = false; protected ConfigHandle(ConfigSubscription<T> sub) { diff --git a/config/src/main/java/com/yahoo/config/subscription/ConfigSourceSet.java b/config/src/main/java/com/yahoo/config/subscription/ConfigSourceSet.java index 4c1757c0ba8..18b50f272c2 100755 --- a/config/src/main/java/com/yahoo/config/subscription/ConfigSourceSet.java +++ b/config/src/main/java/com/yahoo/config/subscription/ConfigSourceSet.java @@ -8,8 +8,8 @@ import java.util.logging.Logger; /** -* An immutable set of connection endpoints, where each endpoint points to either a - * remote configserver or a configproxy. + * An immutable set of connection endpoints, where each endpoint points to either a + * remote config server or a config proxy. * * Two sets are said to be equal if they contain the same sources, independent of order, * upper/lower-casing and whitespaces. @@ -19,7 +19,7 @@ import java.util.logging.Logger; public class ConfigSourceSet implements ConfigSource { private static final Logger log = Logger.getLogger(ConfigSourceSet.class.getName()); - private final Set<String> sources = new LinkedHashSet<String>(); + private final Set<String> sources = new LinkedHashSet<>(); /** * Creates an empty ConfigSourceSet, mostly used for unit testing. diff --git a/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java b/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java index 619dd333b51..f1d8135fcce 100644 --- a/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java +++ b/config/src/main/java/com/yahoo/config/subscription/ConfigSubscriber.java @@ -252,7 +252,7 @@ public class ConfigSubscriber { } reconfigDue = (anyConfigChanged || !requireChange) && allGenerationsChanged && allGenerationsTheSame; if (!reconfigDue && timeLeftMillis > 0) { - sleep(10); + sleep(); } } while (!reconfigDue && timeLeftMillis > 0); if (reconfigDue) { @@ -264,9 +264,9 @@ public class ConfigSubscriber { return reconfigDue; } - private void sleep(long i) { + private void sleep() { try { - Thread.sleep(i); + Thread.sleep(10); } catch (InterruptedException e) { throw new ConfigInterruptedException(e); } @@ -428,7 +428,7 @@ public class ConfigSubscriber { * @author vegardh */ public interface SingleSubscriber<T extends ConfigInstance> { - public void configure(T config); + void configure(T config); } /** diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/ConfigSetSubscription.java b/config/src/main/java/com/yahoo/config/subscription/impl/ConfigSetSubscription.java index 3778ee38d98..598264b62d7 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/ConfigSetSubscription.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/ConfigSetSubscription.java @@ -28,7 +28,7 @@ public class ConfigSetSubscription<T extends ConfigInstance> extends ConfigSubsc if (!set.contains(subKey)) { throw new IllegalArgumentException("The given ConfigSet "+set+" does not contain a config for "+subKey); } - setGeneration(0l); + setGeneration(0L); } @Override @@ -46,7 +46,7 @@ public class ConfigSetSubscription<T extends ConfigInstance> extends ConfigSubsc updateInstance(myInstance); return true; } - sleep(10); + sleep(); } while (System.currentTimeMillis() < end); // These shouldn't be checked anywhere since we return false now, but setting them still setGenerationChanged(false); @@ -54,9 +54,9 @@ public class ConfigSetSubscription<T extends ConfigInstance> extends ConfigSubsc return false; } - private void sleep(int milliSecondsToSleep) { + private void sleep() { try { - Thread.sleep(milliSecondsToSleep); + Thread.sleep(10); } catch (InterruptedException e) { throw new RuntimeException("nextConfig aborted", e); } diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/FileConfigSubscription.java b/config/src/main/java/com/yahoo/config/subscription/impl/FileConfigSubscription.java index c1b1e3daaff..caef45085dc 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/FileConfigSubscription.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/FileConfigSubscription.java @@ -28,7 +28,7 @@ public class FileConfigSubscription<T extends ConfigInstance> extends ConfigSubs FileConfigSubscription(ConfigKey<T> key, ConfigSubscriber subscriber, File f) { super(key, subscriber); - setGeneration(0l); + setGeneration(0L); file=f; if (!file.exists() && !file.isFile()) throw new IllegalArgumentException("Not a file: "+file); @@ -38,12 +38,11 @@ public class FileConfigSubscription<T extends ConfigInstance> extends ConfigSubs public boolean nextConfig(long timeout) { if (!file.exists() && !file.isFile()) throw new IllegalArgumentException("Not a file: "+file); if (checkReloaded()) { - // TODO: Temporary log messages for debugging. - log.log(LogLevel.INFO, "User forced config reload at " + System.currentTimeMillis()); + log.log(LogLevel.DEBUG, "User forced config reload at " + System.currentTimeMillis()); // User forced reload updateConfig(); - log.log(LogLevel.INFO, "Config updated at " + System.currentTimeMillis() + ", changed: " + isConfigChanged()); - log.log(LogLevel.INFO, "Config: " + config.toString()); + log.log(LogLevel.DEBUG, "Config updated at " + System.currentTimeMillis() + ", changed: " + isConfigChanged()); + log.log(LogLevel.DEBUG, "Config: " + config.toString()); return true; } if (file.lastModified()!=ts) { diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java index 23a66cc9e6c..0931cc8f509 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java @@ -31,7 +31,6 @@ import com.yahoo.vespa.config.protocol.Trace; * @author vegardh * @since 5.1 */ -// Note: this is similar to old JRTSource public class JRTConfigRequester implements RequestWaiter { private static final Logger log = Logger.getLogger(JRTConfigRequester.class.getName()); public static final ConfigSourceSet defaultSourceSet = ConfigSourceSet.createDefault(); @@ -120,7 +119,7 @@ public class JRTConfigRequester implements RequestWaiter { } } - protected void doHandle(JRTConfigSubscription<ConfigInstance> sub, JRTClientConfigRequest jrtReq, Connection connection) { + private void doHandle(JRTConfigSubscription<ConfigInstance> sub, JRTClientConfigRequest jrtReq, Connection connection) { if (sub.getState() == ConfigSubscription.State.CLOSED) return; // Avoid error messages etc. after closing boolean validResponse = jrtReq.validateResponse(); Trace trace = jrtReq.getResponseTrace(); @@ -246,7 +245,6 @@ public class JRTConfigRequester implements RequestWaiter { sub.setLastCallBackOKTS(System.currentTimeMillis()); if (jrtReq.hasUpdatedGeneration()) { // We only want this latest generation to be in the queue, we do not preserve history in this system - handleEmptyPayload(jrtReq, sub); sub.getReqQueue().clear(); boolean putOK = sub.getReqQueue().offer(jrtReq); if (!putOK) { @@ -267,24 +265,6 @@ public class JRTConfigRequester implements RequestWaiter { return timingValues.getPlusMinusFractionRandom(timingValues.getFixedDelay(), randomFraction); } - /** - * This works around an optimization in the protocol: the payload is not set if it is not changed (seen from the server). - * So, if the sub's queue has a still _unprocessed_ req with payload, and the current one has no payload, - * i.e. it wasn't changed, save the one in the earlier req before clearing the queue. - * - * @param jrtReq a JRT config request - * @param sub a config subscription - */ - private void handleEmptyPayload(JRTClientConfigRequest jrtReq, - JRTConfigSubscription<ConfigInstance> sub) { - if (jrtReq.containsPayload()) { - JRTClientConfigRequest reqInQueue = sub.getReqQueue().poll(); // Just take it out, we were about to clear the queue anyway - if (reqInQueue != null) { - jrtReq.updateRequestPayload(reqInQueue.getNewPayload(), reqInQueue.hasUpdatedConfig()); - } - } - } - private void scheduleNextRequest(JRTClientConfigRequest jrtReq, JRTConfigSubscription<?> sub, long delay, long timeout) { if (delay < 0) delay = 0; JRTClientConfigRequest jrtReqNew = jrtReq.nextRequest(timeout); @@ -302,8 +282,7 @@ public class JRTConfigRequester implements RequestWaiter { private final JRTClientConfigRequest jrtReq; private final JRTConfigSubscription<?> sub; - public GetConfigTask(JRTClientConfigRequest jrtReq, - JRTConfigSubscription<?> sub) { + GetConfigTask(JRTClientConfigRequest jrtReq, JRTConfigSubscription<?> sub) { this.jrtReq = jrtReq; this.sub = sub; } @@ -352,7 +331,7 @@ public class JRTConfigRequester implements RequestWaiter { return fatalFailures; } - // TODO: Should be package private + // TODO: Should be package private, used in integrationtest.rb in system tests public ConnectionPool getConnectionPool() { return connectionPool; } diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/JarConfigSubscription.java b/config/src/main/java/com/yahoo/config/subscription/impl/JarConfigSubscription.java index 434b61db918..08d8c671dcd 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/JarConfigSubscription.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/JarConfigSubscription.java @@ -61,14 +61,13 @@ public class JarConfigSubscription<T extends ConfigInstance> extends ConfigSubsc } catch (IOException e) { throw new ConfigurationRuntimeException(e); } - setGeneration(0l); + setGeneration(0L); setGenerationChanged(true); setConfigChanged(true); try { jarFile.close(); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + throw new ConfigurationRuntimeException(e); } return true; } diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/RawConfigSubscription.java b/config/src/main/java/com/yahoo/config/subscription/impl/RawConfigSubscription.java index 2c8470cf63c..f1b17066419 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/RawConfigSubscription.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/RawConfigSubscription.java @@ -35,7 +35,7 @@ public class RawConfigSubscription<T extends ConfigInstance> extends ConfigSubsc } if (payload==null) { payload = inputPayload; - setGeneration(0l); + setGeneration(0L); setGenerationChanged(true); setConfigChanged(true); diff --git a/config/src/main/java/com/yahoo/vespa/config/ConfigDefinition.java b/config/src/main/java/com/yahoo/vespa/config/ConfigDefinition.java index 8906782de9e..a0888377441 100644 --- a/config/src/main/java/com/yahoo/vespa/config/ConfigDefinition.java +++ b/config/src/main/java/com/yahoo/vespa/config/ConfigDefinition.java @@ -418,8 +418,8 @@ public class ConfigDefinition implements Comparable<ConfigDefinition> { * A Default specification where instances _may_ have a default value * @author vegardh */ - public static interface DefaultValued<T> { - public T getDefVal(); + public interface DefaultValued<T> { + T getDefVal(); } public static class EnumDef implements DefaultValued<String>{ diff --git a/config/src/main/java/com/yahoo/vespa/config/ConfigDefinitionBuilder.java b/config/src/main/java/com/yahoo/vespa/config/ConfigDefinitionBuilder.java index 934e5d6ca7f..986eaa441e2 100644 --- a/config/src/main/java/com/yahoo/vespa/config/ConfigDefinitionBuilder.java +++ b/config/src/main/java/com/yahoo/vespa/config/ConfigDefinitionBuilder.java @@ -21,21 +21,7 @@ public class ConfigDefinitionBuilder { * @return a ConfigDefinition object */ public static ConfigDefinition createConfigDefinition(CNode root) { - return createConfigDefinition(root, root.getNamespace()); - } - - // TODO This method should be removed when we have full namespace support - /** - * Creates a ConfigDefinition based on a tree generated from parsing a config - * definition file. The <code>namespace</code> argument overrides the namespace - * defined in the config definition file. - * - * @param root the root node in a tree generated from parsing a config definition file. - * @param namespace Override namespace in root with this namespace - * @return a ConfigDefinition object - */ - public static ConfigDefinition createConfigDefinition(CNode root, String namespace) { - ConfigDefinition def = new ConfigDefinition(root.getName(), root.getVersion(), namespace); + ConfigDefinition def = new ConfigDefinition(root.getName(), root.getVersion(), root.getNamespace()); for (CNode node : root.getChildren()) { addNode(def, node); diff --git a/config/src/main/java/com/yahoo/vespa/config/ConfigDefinitionKey.java b/config/src/main/java/com/yahoo/vespa/config/ConfigDefinitionKey.java index 5ebfde612d3..e55018d34aa 100644 --- a/config/src/main/java/com/yahoo/vespa/config/ConfigDefinitionKey.java +++ b/config/src/main/java/com/yahoo/vespa/config/ConfigDefinitionKey.java @@ -21,7 +21,7 @@ public class ConfigDefinitionKey { */ public ConfigDefinitionKey(String name, String namespace) { require(name, "A config name cannot be null or empty"); - require(namespace, "A config name cannot be null or empty"); + require(namespace, "A config namespace cannot be null or empty"); this.name = name; this.namespace = namespace; } diff --git a/config/src/main/java/com/yahoo/vespa/config/ConfigHelper.java b/config/src/main/java/com/yahoo/vespa/config/ConfigHelper.java index a1469b746dc..42d7cc441b7 100644 --- a/config/src/main/java/com/yahoo/vespa/config/ConfigHelper.java +++ b/config/src/main/java/com/yahoo/vespa/config/ConfigHelper.java @@ -10,7 +10,7 @@ import com.yahoo.config.subscription.ConfigSourceSet; */ public class ConfigHelper { private final JRTConnectionPool jrtConnectionPool; - private TimingValues timingValues; + private final TimingValues timingValues; /** * @param configSourceSet The set of config sources for this helper. diff --git a/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadApplier.java b/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadApplier.java index d25bf2f0b21..5324990fe0f 100644 --- a/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadApplier.java +++ b/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadApplier.java @@ -457,7 +457,7 @@ public class ConfigPayloadApplier<T extends ConfigInstance.Builder> { * A class that holds a builder and a stack of names */ private static class NamedBuilder { - private ConfigBuilder builder; + private final ConfigBuilder builder; private final Stack<String> names = new Stack<>(); // if empty, the builder is the root builder NamedBuilder(ConfigBuilder builder) { diff --git a/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadBuilder.java b/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadBuilder.java index 36e0a4e81dc..65533dc74f0 100644 --- a/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadBuilder.java +++ b/config/src/main/java/com/yahoo/vespa/config/ConfigPayloadBuilder.java @@ -26,15 +26,11 @@ public class ConfigPayloadBuilder { * Construct a payload builder that is not a leaf. */ public ConfigPayloadBuilder() { - this(null, (String)null); + this(null, null); } public ConfigPayloadBuilder(ConfigDefinition configDefinition) { - this(configDefinition, (String)null); - } - - public ConfigPayloadBuilder(ConfigDefinition configDefinition, List<String> warnings) { - this(configDefinition); + this(configDefinition, null); } /** diff --git a/config/src/main/java/com/yahoo/vespa/config/GenerationCounter.java b/config/src/main/java/com/yahoo/vespa/config/GenerationCounter.java index 904c1d29818..8c9b947f4d9 100644 --- a/config/src/main/java/com/yahoo/vespa/config/GenerationCounter.java +++ b/config/src/main/java/com/yahoo/vespa/config/GenerationCounter.java @@ -13,10 +13,10 @@ public interface GenerationCounter { * * @return incremented counter value. */ - public long increment(); + long increment(); /** * @return current counter value. */ - public long get(); + long get(); } 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 2a12a659538..bc77da4dc5e 100644 --- a/config/src/main/java/com/yahoo/vespa/config/GetConfigRequest.java +++ b/config/src/main/java/com/yahoo/vespa/config/GetConfigRequest.java @@ -18,22 +18,22 @@ public interface GetConfigRequest { * * @return the ConfigKey for this config request */ - public ConfigKey<?> getConfigKey(); + ConfigKey<?> getConfigKey(); /** * The def file contents in the request, or empty array if not sent/not supported * @return the contents (payload) of the def schema */ - public DefContent getDefContent(); + DefContent getDefContent(); /** * Get Vespa version for this GetConfigRequest */ - public Optional<com.yahoo.vespa.config.protocol.VespaVersion> getVespaVersion(); + Optional<com.yahoo.vespa.config.protocol.VespaVersion> getVespaVersion(); /** * Whether or not the config can be retrieved from or stored in a cache. * @return true if content should _not_ be cached, false if it should. */ - public boolean noCache(); + boolean noCache(); } diff --git a/config/src/main/java/com/yahoo/vespa/config/JRTMethods.java b/config/src/main/java/com/yahoo/vespa/config/JRTMethods.java index 22c57413bc1..d249aa92bc3 100644 --- a/config/src/main/java/com/yahoo/vespa/config/JRTMethods.java +++ b/config/src/main/java/com/yahoo/vespa/config/JRTMethods.java @@ -9,92 +9,6 @@ import com.yahoo.jrt.Request; */ public class JRTMethods { - static final String getConfigMethodName = "getConfig"; - private static final String getConfigRequestTypes = "sssssll"; - static final String getConfigResponseTypes = "sssssilS"; - - static final String configV1getConfigMethodName = "config.v1.getConfig"; - private static final String configV1GetConfigRequestTypes = "sssssllsSi"; - static final String configV1GetConfigResponseTypes = "sssssilSs"; - - /** - * Creates a Method object for the RPC method getConfig. - * - * @param handler the object that will handle the method call - * @param handlerMethod the method belonging to the handler that will handle the method call - * @return a Method - */ - public static Method createGetConfigMethod(Object handler, String handlerMethod) { - return new Method(getConfigMethodName, getConfigRequestTypes, getConfigResponseTypes, - handler, handlerMethod) - .methodDesc("get config") - .paramDesc(0, "defName", "config class definition name") - .paramDesc(1, "defVersion", "config class definition version") - .paramDesc(2, "defMD5", "md5sum for config class definition") - .paramDesc(3, "configid", "config id") - .paramDesc(4, "configMD5", "md5sum for last got config, empty string if unknown") - .paramDesc(5, "timestamp", - "timestamp for last got config, only relevant to the server if useTimestamp != 0") - .paramDesc(6, "timeout", "timeout (milliseconds) before answering request if config is unchanged") - .returnDesc(0, "defName", "config name") - .returnDesc(1, "defVersion", "config version") - .returnDesc(2, "defMD5", "md5sum for config class definition") - .returnDesc(3, "configid", "requested config id") - .returnDesc(4, "configMD5", "md5sum for this config") - .returnDesc(5, "changed", "changed flag (1 if config changed, 0 otherwise") - .returnDesc(6, "timestamp", "timestamp when config was last changed") - .returnDesc(7, "payload", "config payload for the requested config"); - } - - /** - * Creates a Method object for the RPC method config.v1.getConfig. Use both for - * getting config and subscribing to config - * - * @param handler the object that will handle the method call - * @param handlerMethod the method belonging to the handler that will handle the method call - * @return a Method - */ - public static Method createConfigV1GetConfigMethod(Object handler, String handlerMethod) { - return new Method(configV1getConfigMethodName, configV1GetConfigRequestTypes, configV1GetConfigResponseTypes, - handler, handlerMethod) - .methodDesc("get config v1") - .paramDesc(0, "defName", "config class definition name") - .paramDesc(1, "defVersion", "config class definition version") - .paramDesc(2, "defMD5", "md5sum for config class definition") - .paramDesc(3, "configid", "config id") - .paramDesc(4, "configMD5", "md5sum for last got config, empty string if unknown") - .paramDesc(5, "generation", - "generation for last got config, only relevant to the server if generation != 0") - .paramDesc(6, "timeout", "timeout (milliseconds) before answering request if config is unchanged") - .paramDesc(7, "namespace", "namespace for defName") - .paramDesc(8, "defContent", "config definition content") - .paramDesc(9, "subscribe", "subscribe to config (1) or not (0)") - .returnDesc(0, "defName", "config name") - .returnDesc(1, "defVersion", "config version") - .returnDesc(2, "defMD5", "md5sum for config class definition") - .returnDesc(3, "configid", "requested config id") - .returnDesc(4, "configMD5", "md5sum for this config") - .returnDesc(5, "changed", "changed flag (1 if config changed, 0 otherwise") // TODO Maybe remove? - .returnDesc(6, "generation", "generation of config") - .returnDesc(7, "payload", "config payload for the requested config") - .returnDesc(8, "namespace", "namespace for defName"); - } - - public static final String configV2getConfigMethodName = "config.v2.getConfig"; - private static final String configV2GetConfigRequestTypes = "s"; - private static final String configV2GetConfigResponseTypes = "s"; - public static Method createConfigV2GetConfigMethod(Object handler, String handlerMethod) { - return new Method(configV2getConfigMethodName, configV2GetConfigRequestTypes, configV2GetConfigResponseTypes, - handler, handlerMethod) - .methodDesc("get config v2") - .paramDesc(0, "request", "config request") - .returnDesc(0, "response", "config response"); - } - - public static boolean checkV2ReturnTypes(Request request) { - return request.checkReturnTypes(JRTMethods.configV2GetConfigResponseTypes); - } - public static final String configV3getConfigMethodName = "config.v3.getConfig"; private static final String configV3GetConfigRequestTypes = "s"; private static final String configV3GetConfigResponseTypes = "sx"; @@ -105,7 +19,6 @@ public class JRTMethods { .paramDesc(0, "request", "config request") .returnDesc(0, "response", "config response") .returnDesc(1, "payload", "config response payload"); - } public static boolean checkV3ReturnTypes(Request request) { 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 581df40f8fb..6f37efed56d 100755 --- a/config/src/main/java/com/yahoo/vespa/config/RawConfig.java +++ b/config/src/main/java/com/yahoo/vespa/config/RawConfig.java @@ -37,7 +37,7 @@ public class RawConfig { * @param defMd5 The md5 sum of the .def-file. */ public RawConfig(ConfigKey<?> key, String defMd5) { - this(key, defMd5, null, "", 0L, 0, Collections.<String>emptyList(), Optional.empty()); + this(key, defMd5, null, "", 0L, 0, Collections.emptyList(), Optional.empty()); } public RawConfig(ConfigKey<?> key, String defMd5, Payload payload, String configMd5, long generation, List<String> defContent, Optional<VespaVersion> vespaVersion) { diff --git a/config/src/main/java/com/yahoo/vespa/config/Source.java b/config/src/main/java/com/yahoo/vespa/config/Source.java deleted file mode 100644 index 3ec17038506..00000000000 --- a/config/src/main/java/com/yahoo/vespa/config/Source.java +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2016 Yahoo Inc. 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 java.util.logging.Logger; - -/** - * A general config source that retrieves config for its SourceConfig. - * - * This class and its subclasses are thread safe. - * - * Note that it is the responsibility of the user to set a source's state to OPEN and CANCELLED, and - * that the READY state can be set by the user as a mark of progress e.g. when waiting for a monitor/lock. - * All other states are set by this class or one of its subclasses. - * - * Originally designed for re-use by closing and reopening, but this caused problems related to - * synchronization between this class and ConfigInstance.subscribeLock. Currently (2008-05-08) - * a source cannot be reopened once it has been cancelled. - * - * @author <a href="gv@yahoo-inc.com">G. Voldengen</a> - */ -public abstract class Source { - - public enum State { NEW, OPEN_PENDING, READY, OPEN, CANCEL_REQUESTED, CANCELLED } - - protected volatile SourceConfig config; - protected volatile State state = State.NEW; - protected long openTimestamp = 0; - public final static Logger logger = Logger.getLogger(Source.class.getPackage().getName()); - - public Source(SourceConfig sourceConfig) { - this.config = sourceConfig; - } - - /** - * Opens this config source. - * Typically called when the first subscriber subscribes to our ConfigInstance. - */ - public final synchronized void open() { - if ((state == State.OPEN) || (state == State.OPEN_PENDING)) { - return; - } else if ((state == State.CANCELLED) || (state == State.CANCEL_REQUESTED)) { - throw new ConfigurationRuntimeException("Subscription with config ID: " + config.getConfigId() + ": Trying to reopen a cancelled source, should not happen.", null); - } - state = State.OPEN_PENDING; - openTimestamp = System.currentTimeMillis(); - myOpen(); - getConfig(); - } - - /** - * Optional subclass hook for the open() method. - */ - protected void myOpen() { } - - /** - * Gets config from this config source. - */ - public final synchronized void getConfig() { - if ((state == State.CANCELLED) || (state == State.CANCEL_REQUESTED)) { - logger.info("Trying to retrieve config from source " + this + " in state: " + state); - return; - } - myGetConfig(); - } - - /** - * Mandatory subclass hook for the getConfig() method. - */ - protected abstract void myGetConfig(); - - /** - * Cancels this config source. Typically called when our ConfigInstance has no more subscribers. - * - * Irreversible. Reopening a cancelled source would cause problems with multiple threads accessing the source - * simultaneously. With better synchronization mechanisms it _should_ be possible to close and reopen a source. - */ - public final void cancel() { - logger.fine("Closing source " + this + " from state " + state); - if ((state == State.CANCELLED) || (state == State.CANCEL_REQUESTED)) { - return; - } - state = State.CANCEL_REQUESTED; - myCancel(); - } - - /** - * Optional subclass hook for the cancel() method. - * Should typically free all the subclass' resources, i.e. requests, threads etc.. - */ - protected void myCancel() { } - - public State getState() { - return state; - } - - public void setState(State state) { - this.state = state; - } -} diff --git a/config/src/main/java/com/yahoo/vespa/config/SourceConfig.java b/config/src/main/java/com/yahoo/vespa/config/SourceConfig.java deleted file mode 100644 index 49484e16ff0..00000000000 --- a/config/src/main/java/com/yahoo/vespa/config/SourceConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.config; - -import java.util.List; - -/** - * Interface for config instances that use a {@link Source} to retrieve config values. - * - * @author <a href="gv@yahoo-inc.com">Gj\u00F8ran Voldengen</a> - */ -public interface SourceConfig { - - /** - * Notify subscribers that this config has been initialized by the {@link Source}. - */ - public void notifyInitMonitor(); - - /** - * Sets the fields in the config object from the payload in the given request and updates subscribers - * with the new config. The given request can be an error response with an error code and no payload. - * - * @param req Config request containing return values, or an error response. - */ - public void setConfig(com.yahoo.vespa.config.protocol.JRTClientConfigRequest req); - - /** - * Sets this config's generation. - * - * @param generation The new generation (usually from the source). - */ - public void setGeneration(long generation); - - public String getDefName(); - public String getDefNamespace(); - public String getDefVersion(); - public List<String> getDefContent(); - public String getDefMd5(); - - public String getConfigId(); - public ConfigKey<?> getKey(); - - public String getConfigMd5(); - - public long getGeneration(); - - public RawConfig getConfig(); - -} diff --git a/config/src/main/java/com/yahoo/vespa/config/TimingValues.java b/config/src/main/java/com/yahoo/vespa/config/TimingValues.java index 46f0854084c..6c1a89fb146 100644 --- a/config/src/main/java/com/yahoo/vespa/config/TimingValues.java +++ b/config/src/main/java/com/yahoo/vespa/config/TimingValues.java @@ -239,7 +239,7 @@ public class TimingValues { * @return a number */ public long getPlusMinusFractionRandom(long val, float fraction) { - return Math.round(val - (val * fraction) + (rand.nextFloat() * 2l * val * fraction)); + return Math.round(val - (val * fraction) + (rand.nextFloat() * 2L * val * fraction)); } Random getRandom() { diff --git a/config/src/main/java/com/yahoo/vespa/config/benchmark/Tester.java b/config/src/main/java/com/yahoo/vespa/config/benchmark/Tester.java index 68d20f7a75f..a82556b88d0 100644 --- a/config/src/main/java/com/yahoo/vespa/config/benchmark/Tester.java +++ b/config/src/main/java/com/yahoo/vespa/config/benchmark/Tester.java @@ -7,8 +7,8 @@ import java.util.Map; * Tester interface for loadable test runners. */ public interface Tester { - public void subscribe(); - public boolean fetch(); - public boolean verify(Map<String, Map<String, String>> expected, long generation); - public void close(); + void subscribe(); + boolean fetch(); + boolean verify(Map<String, Map<String, String>> expected, long generation); + void close(); } diff --git a/config/src/main/java/com/yahoo/vespa/config/buildergen/ConfigDefinitionClass.java b/config/src/main/java/com/yahoo/vespa/config/buildergen/ConfigDefinitionClass.java index 0820d77612e..0fd6b5893b5 100644 --- a/config/src/main/java/com/yahoo/vespa/config/buildergen/ConfigDefinitionClass.java +++ b/config/src/main/java/com/yahoo/vespa/config/buildergen/ConfigDefinitionClass.java @@ -21,7 +21,6 @@ public class ConfigDefinitionClass { String getSimpleName() { return name; - } String getName() { 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 8997173a479..9677c35ee7d 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 @@ -54,14 +54,6 @@ public interface JRTClientConfigRequest extends JRTConfigRequest { String getNewConfigMd5(); /** - * For protocols that perform an optimization when no new config has been given, this method will provide the - * payload and hasUpdatedConfig state of the previous request. - * @param payload a config payload of the previous request. - * @param hasUpdatedConfig the hasUpdatedConfig flag of the previous request. - */ - void updateRequestPayload(Payload payload, boolean hasUpdatedConfig); - - /** * Test whether or not the payload is contained in this response or not. Should return false for error responses as well. * @return true if empty, false if not. */ diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactory.java b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactory.java index 583e4ba39f5..f6851fa8281 100644 --- a/config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactory.java +++ b/config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactory.java @@ -7,7 +7,6 @@ import com.yahoo.vespa.config.RawConfig; import com.yahoo.vespa.config.util.ConfigUtils; import java.util.*; -import java.util.logging.Logger; /** * To hide JRT implementations. @@ -17,8 +16,7 @@ import java.util.logging.Logger; */ public class JRTConfigRequestFactory { - public static final String VESPA_CONFIG_PROTOCOL_VERSION = "VESPA_CONFIG_PROTOCOL_VERSION"; - private final static Logger log = Logger.getLogger(JRTConfigRequestFactory.class.getName()); + public static final String VESPA_CONFIG_PROTOCOL_VERSION = "VESPA_CONFIG_PROTOCOL_VERSION"; // Unused, but should be used if we add a new version private static final CompressionType compressionType = getCompressionType(); private static final String VESPA_CONFIG_PROTOCOL_COMPRESSION = "VESPA_CONFIG_PROTOCOL_COMPRESSION"; public static final String VESPA_VERSION = "VESPA_VERSION"; @@ -42,7 +40,7 @@ public class JRTConfigRequestFactory { } public static Set<Long> supportedProtocolVersions() { - return Collections.singleton(3l); + return Collections.singleton(3L); } public static CompressionType getCompressionType() { 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 d44f9190b42..101003708ee 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 @@ -77,7 +77,7 @@ public class RequestValidation { return (timeout > 0); } - public static boolean verifyGeneration(Long generation) { + private static boolean verifyGeneration(Long generation) { return (generation >= 0); } diff --git a/config/src/main/java/com/yahoo/vespa/config/protocol/SlimeClientConfigRequest.java b/config/src/main/java/com/yahoo/vespa/config/protocol/SlimeClientConfigRequest.java index 9d42b6b077c..38d4c6ecb49 100644 --- a/config/src/main/java/com/yahoo/vespa/config/protocol/SlimeClientConfigRequest.java +++ b/config/src/main/java/com/yahoo/vespa/config/protocol/SlimeClientConfigRequest.java @@ -151,11 +151,6 @@ public abstract class SlimeClientConfigRequest implements JRTClientConfigRequest } @Override - public void updateRequestPayload(Payload payload, boolean hasUpdatedConfig) { - // This protocol sends payload in all cases, so ignore this. - } - - @Override public boolean containsPayload() { return false; } 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 80c050b9b61..056473e7f28 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 @@ -54,7 +54,7 @@ class SlimeRequestData { return data; } - Inspector getRequestField(String requestField) { + private Inspector getRequestField(String requestField) { return getData().get().field(requestField); } @@ -111,12 +111,10 @@ class SlimeRequestData { defSchema.serialize(request.setArray(REQUEST_DEF_CONTENT)); request.setString(REQUEST_CONFIG_MD5, configMd5); request.setLong(REQUEST_CURRENT_GENERATION, generation); - request.setLong(REQUEST_WANTED_GENERATION, 0l); + request.setLong(REQUEST_WANTED_GENERATION, 0L); request.setLong(REQUEST_TIMEOUT, timeout); request.setString(REQUEST_COMPRESSION_TYPE, compressionType.name()); - if (vespaVersion.isPresent()) { - request.setString(REQUEST_VESPA_VERSION, vespaVersion.get().toString()); - } + vespaVersion.ifPresent(version -> request.setString(REQUEST_VESPA_VERSION, version.toString())); trace.serialize(request.setObject(REQUEST_TRACE)); return data; } @@ -132,7 +130,7 @@ class SlimeRequestData { public Optional<VespaVersion> getVespaVersion() { String versionString = getRequestField(REQUEST_VESPA_VERSION).asString(); // will be "" if not set, never null - return versionString.isEmpty() ? Optional.<VespaVersion>empty() : Optional.of(VespaVersion.fromString(versionString)); + return versionString.isEmpty() ? Optional.empty() : Optional.of(VespaVersion.fromString(versionString)); } } diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java index 342e50821f4..b329d539757 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java @@ -115,7 +115,7 @@ public class ConfigInstanceSerializerTest { builder.enumarr(ArraytypesConfig.Enumarr.Enum.VAL1); builder.enumarr(ArraytypesConfig.Enumarr.Enum.VAL2); builder.intarr(3); - builder.longarr(4l); + builder.longarr(4L); builder.stringarr("foo"); final ArraytypesConfig config = new ArraytypesConfig(builder); diff --git a/config/src/test/java/com/yahoo/config/subscription/GenericConfigSubscriberTest.java b/config/src/test/java/com/yahoo/config/subscription/GenericConfigSubscriberTest.java index 26b47f7621c..499772c60f4 100644 --- a/config/src/test/java/com/yahoo/config/subscription/GenericConfigSubscriberTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/GenericConfigSubscriberTest.java @@ -64,7 +64,7 @@ public class GenericConfigSubscriberTest { @Test(expected=UnsupportedOperationException.class) public void testOverriddenSubscribeInvalid2() { GenericConfigSubscriber sub = new GenericConfigSubscriber(); - sub.subscribe(null, null, 0l); + sub.subscribe(null, null, 0L); } @Test(expected=UnsupportedOperationException.class) diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java index 592bb7e4abf..5cad8e2890b 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java @@ -127,15 +127,7 @@ public class ConfigDefinitionBuilderTest { assertEquals(def.getStructMapDefs().get("myStructMap").getIntDefs().get("myIntDef").getDefVal(), (Integer)56); assertEquals(def.getStructMapDefs().get("myStructMap").getStringDefs().get("myStringDef").getDefVal(), "g"); + // Ranges } - @Test - public void testCreateConfigDefinitionOverrideNamespace() throws IOException, InterruptedException { - File defFile = new File(DEF_NAME); - DefParser defParser = new DefParser(defFile.getName(), new FileReader(defFile)); - CNode root = defParser.getTree(); - - ConfigDefinition def = ConfigDefinitionBuilder.createConfigDefinition(root, "foo"); - assertThat(def.getNamespace(), is("foo")); - } } diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java index de2e30d66d7..0fae9b47467 100755 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java @@ -110,7 +110,7 @@ public class ConfigDefinitionTest { def.addIntDef("myint"); def.addIntDef("myintdef", 1); def.addLongDef("mylong"); - def.addLongDef("mylongdef", 11l); + def.addLongDef("mylongdef", 11L); def.addDoubleDef("mydouble"); def.addDoubleDef("mydoubledef", 2d); EnumDef ed = new EnumDef(new ArrayList<String>(){{add("a1"); add("a2");}}, null); diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java index 35ceebe393c..8fc0b95ae97 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java @@ -9,7 +9,6 @@ import org.junit.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.ArrayList; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java index 1e7b66fac38..397093d4359 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java @@ -88,15 +88,15 @@ public class ConfigPayloadTest { @Test public void test_long_leaf() throws Exception { SimpletypesConfig config = createSimpletypesConfig("longval", "0"); - assertThat(config.longval(), is(0l)); + assertThat(config.longval(), is(0L)); config = createSimpletypesConfig("longval", String.valueOf(Long.MIN_VALUE)); assertThat(config.longval(), is(Long.MIN_VALUE)); config = createSimpletypesConfig("longval", String.valueOf(Long.MAX_VALUE)); assertThat(config.longval(), is(Long.MAX_VALUE)); config = createSimpletypesConfig("longval", String.valueOf(10)); - assertThat(config.longval(), is(10l)); + assertThat(config.longval(), is(10L)); config = createSimpletypesConfig("longval", String.valueOf(-10)); - assertThat(config.longval(), is(-10l)); + assertThat(config.longval(), is(- 10L)); } @Test(expected = RuntimeException.class) @@ -210,11 +210,11 @@ public class ConfigPayloadTest { // Normal behavior ArraytypesConfig config = createArraytypesConfig("longarr", new String[] { "2", "3", "1", "-2", "5"}); assertThat(config.longarr().size(), is(5)); - assertThat(config.longarr(0), is(2l)); - assertThat(config.longarr(1), is(3l)); - assertThat(config.longarr(2), is(1l)); - assertThat(config.longarr(3), is(-2l)); - assertThat(config.longarr(4), is(5l)); + assertThat(config.longarr(0), is(2L)); + assertThat(config.longarr(1), is(3L)); + assertThat(config.longarr(2), is(1L)); + assertThat(config.longarr(3), is(- 2L)); + assertThat(config.longarr(4), is(5L)); final int size = 100; String [] largeArray = new String[size]; diff --git a/config/src/test/java/com/yahoo/vespa/config/SourceTest.java b/config/src/test/java/com/yahoo/vespa/config/SourceTest.java deleted file mode 100644 index 989131c8256..00000000000 --- a/config/src/test/java/com/yahoo/vespa/config/SourceTest.java +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2016 Yahoo Inc. 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.SimpletypesConfig; -import com.yahoo.vespa.config.protocol.CompressionType; -import com.yahoo.vespa.config.protocol.DefContent; -import com.yahoo.vespa.config.protocol.JRTClientConfigRequest; -import com.yahoo.vespa.config.protocol.JRTClientConfigRequestV3; -import com.yahoo.vespa.config.protocol.Payload; -import com.yahoo.vespa.config.protocol.Trace; -import org.junit.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.*; - -/** - * @author lulf - * @since 5.1 - */ -public class SourceTest { - - @Test - public void testSourceInterface() { - MockSourceConfig config = new MockSourceConfig(new ConfigKey<>(SimpletypesConfig.class, "foobio")); - assertThat(config.getKey().getConfigId(), is("foobio")); - config.setConfig(JRTClientConfigRequestV3.createWithParams(config.getKey(), DefContent.fromList(config.getDefContent()), "host", config.getDefMd5(), config.getGeneration(), 1000, Trace.createNew(), CompressionType.LZ4, Optional.empty())); - MockSource src = new MockSource(config); - assertThat(src.getState(), is(Source.State.NEW)); - src.open(); - assertTrue(src.opened); - assertTrue(src.getconfigged); - assertThat(src.getState(), is(Source.State.OPEN_PENDING)); - src.open(); - assertThat(src.getState(), is(Source.State.OPEN_PENDING)); - src.getconfigged = false; - src.getConfig(); - assertTrue(src.getconfigged); - assertThat(src.getState(), is(Source.State.OPEN_PENDING)); - assertTrue(config.setConfigCalled); - assertTrue(src.openTimestamp > 0); - config.notifyInitMonitor(); - config.setGeneration(4); - src.cancel(); - assertTrue(src.canceled); - assertThat(src.getState(), is(Source.State.CANCEL_REQUESTED)); - src.setState(Source.State.CANCELLED); - try { - src.open(); - fail("Expected exception"); - } catch (ConfigurationRuntimeException e) { - } - src.getconfigged = false; - src.getConfig(); - assertFalse(src.getconfigged); - src.canceled = false; - src.cancel(); - assertFalse(src.canceled); - } - - public static class MockSource extends Source { - boolean opened, getconfigged, canceled = false; - - public MockSource(SourceConfig sourceConfig) { - super(sourceConfig); - } - - @Override - public void myOpen() { - opened = true; - } - - @Override - protected void myGetConfig() { - getconfigged = true; - } - - @Override - public void myCancel() { - canceled = true; - } - } - - private static class MockSourceConfig implements SourceConfig { - - boolean notifyCalled = false; - ConfigKey<?> key = null; - boolean setConfigCalled = false; - long generation = -1; - Payload payload; - - public MockSourceConfig(ConfigKey<?> key) { - this.key = key; - } - - @Override - public void notifyInitMonitor() { - notifyCalled = true; - } - - @Override - public void setConfig(com.yahoo.vespa.config.protocol.JRTClientConfigRequest req) { - key = req.getConfigKey(); - setConfigCalled = true; - } - - @Override - public void setGeneration(long generation) { - this.generation = generation; - } - - @Override - public String getDefName() { - return key.getName(); - } - - @Override - public String getDefNamespace() { - return key.getNamespace(); - } - - @Override - public String getDefVersion() { - return ""; - } - - @Override - public List<String> getDefContent() { - return Arrays.asList("foo"); - } - - @Override - public String getDefMd5() { - return key.getMd5(); - } - - @Override - public String getConfigId() { - return key.getConfigId(); - } - - @Override - public ConfigKey<?> getKey() { - return key; - } - - @Override - public String getConfigMd5() { - return "bar"; - } - - @Override - public long getGeneration() { - return 0; - } - - @Override - public RawConfig getConfig() { - return new RawConfig(getKey(), getDefMd5(), payload, getConfigMd5(), generation, getDefContent(), Optional.empty()); - } - } -} diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/ConfigResponseTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/ConfigResponseTest.java index e39c0a6f623..fe35a2cde91 100644 --- a/config/src/test/java/com/yahoo/vespa/config/protocol/ConfigResponseTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/protocol/ConfigResponseTest.java @@ -35,7 +35,7 @@ public class ConfigResponseTest { assertNotNull(payload); assertThat(payload.size(), is(6)); assertThat(payload.get(0), is("boolval false")); - assertThat(response.getGeneration(), is(3l)); + assertThat(response.getGeneration(), is(3L)); assertThat(response.getConfigMd5(), is("mymd5")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -56,7 +56,7 @@ public class ConfigResponseTest { assertNotNull(payload); assertThat(payload.size(), is(6)); assertThat(payload.get(0), is("boolval false")); - assertThat(response.getGeneration(), is(3l)); + assertThat(response.getGeneration(), is(3L)); assertThat(response.getConfigMd5(), is("mymd5")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestBase.java b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestBase.java index 0cf6491432d..4e2bd58e689 100644 --- a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestBase.java +++ b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestBase.java @@ -72,7 +72,9 @@ public abstract class JRTConfigRequestBase { return createReq(defName, defNamespace, defMd5, hostname, configId, ConfigUtils.getMd5(payload.getData()), currentGeneration, timeout, trace); } - protected abstract JRTClientConfigRequest createReq(String defName, String defNamespace, String defMd5, String hostname, String configId, String configMd5, long currentGeneration, long timeout, Trace trace) throws IOException; + protected abstract JRTClientConfigRequest createReq(String defName, String defNamespace, String defMd5, + String hostname, String configId, String configMd5, + long currentGeneration, long timeout, Trace trace); protected abstract JRTServerConfigRequest createReq(Request request); protected abstract JRTClientConfigRequest createReq(JRTConfigSubscription<SimpletypesConfig> sub, Trace aNew); protected abstract JRTClientConfigRequest createFromRaw(RawConfig rawConfig, long serverTimeout, Trace aNew); @@ -115,8 +117,8 @@ public abstract class JRTConfigRequestBase { assertThat(next.getConfigKey().getConfigId(), is(configId)); assertThat(next.getDefContent().asStringArray(), is(expectedContent)); assertFalse(next.noCache()); - assertThat(next.getTimeout(), is(6l)); - assertThat(next.getTimeout(), is(6l)); + assertThat(next.getTimeout(), is(6L)); + assertThat(next.getTimeout(), is(6L)); return next; } @@ -138,11 +140,11 @@ public abstract class JRTConfigRequestBase { public void ok_response_is_added() { Payload payload = createPayload("vale"); String md5 = ConfigUtils.getMd5(payload.getData()); - long generation = 4l; + long generation = 4L; serverReq.addOkResponse(payload, generation, md5); assertTrue(clientReq.validateResponse()); assertThat(clientReq.getNewPayload().withCompression(CompressionType.UNCOMPRESSED).getData().toString(), is(payload.getData().toString())); - assertThat(clientReq.getNewGeneration(), is(4l)); + assertThat(clientReq.getNewGeneration(), is(4L)); assertThat(clientReq.getNewConfigMd5(), is(md5)); assertTrue(clientReq.hasUpdatedConfig()); assertTrue(clientReq.hasUpdatedGeneration()); @@ -166,7 +168,7 @@ public abstract class JRTConfigRequestBase { @Test public void generation_only_is_updated() { Payload payload = createPayload(); - serverReq.addOkResponse(payload, 4l, ConfigUtils.getMd5(payload.getData())); + serverReq.addOkResponse(payload, 4L, ConfigUtils.getMd5(payload.getData())); boolean value = clientReq.validateResponse(); assertTrue(clientReq.errorMessage(), value); assertFalse(clientReq.hasUpdatedConfig()); diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactoryTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactoryTest.java index ec2ee479398..e88dda911d5 100644 --- a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactoryTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactoryTest.java @@ -10,8 +10,6 @@ import com.yahoo.vespa.config.RawConfig; import com.yahoo.vespa.config.TimingValues; import org.junit.Test; -import java.util.Optional; - import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; 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 bcb88b2ff5e..e7e8a67dd49 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 @@ -8,7 +8,6 @@ import com.yahoo.vespa.config.*; import com.yahoo.vespa.config.util.ConfigUtils; import org.junit.Test; -import java.io.IOException; import java.util.Arrays; import static org.hamcrest.CoreMatchers.is; @@ -22,7 +21,9 @@ import static org.junit.Assert.assertTrue; public class JRTConfigRequestV3Test extends JRTConfigRequestBase { @Override - protected JRTClientConfigRequest createReq(String defName, String defNamespace, String defMd5, String hostname, String configId, String configMd5, long currentGeneration, long timeout, Trace trace) throws IOException { + protected JRTClientConfigRequest createReq(String defName, String defNamespace, String defMd5, + 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")), hostname, diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java index c3cbfecf1f1..9deedec2d19 100644 --- a/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java @@ -12,8 +12,6 @@ import java.io.UnsupportedEncodingException; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.fail; /** diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java index 4c69fa3e395..18e4cac8c8d 100644 --- a/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java @@ -75,7 +75,7 @@ public class SlimeTraceSerializerTest { @Test public void test_long() throws IOException { - TraceNode root = new TraceNode(14l, 5); + TraceNode root = new TraceNode(14L, 5); assertThat(toJson(root), is("{\"timestamp\":5,\"payload\":14}")); assertSerialize(root); } |