aboutsummaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorHarald Musum <musum@yahoo-inc.com>2017-06-14 09:47:35 +0200
committerHarald Musum <musum@yahoo-inc.com>2017-06-14 09:47:35 +0200
commite2d88dc91681376e12550c869a77ef64fab2327e (patch)
tree0c152b99efd32778715a8c76eb2b292162cb1219 /config-model
parent09d16433d3b83133a3bdea0ec8785c0e60ed9082 (diff)
parent3073e29384e0b67ba7e191f0406c24869c9e0153 (diff)
Merge branch 'master' into hmusum/16-distribution-bits-only-for-prod
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java26
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java4
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java1
-rw-r--r--config-model/src/main/resources/schema/content.rnc2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java4
5 files changed, 14 insertions, 23 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java b/config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java
index e983f794e76..051f0e9e52e 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/InstanceResolver.java
@@ -59,9 +59,8 @@ class InstanceResolver {
ConfigDefinitionKey defKey = new ConfigDefinitionKey(key);
try {
if (targetDef != null) applyDef(builder, targetDef);
- ConfigInstance instance = getInstance(defKey, builder.getClass().getClassLoader());
- Class<? extends ConfigInstance> clazz = instance.getClass();
- return clazz.getConstructor(new Class<?>[]{builder.getClass()}).newInstance(builder);
+ Class<? extends ConfigInstance> clazz = getConfigClass(defKey, builder.getClass().getClassLoader());
+ return clazz.getConstructor(builder.getClass()).newInstance(builder);
} catch (Exception e) {
throw new ConfigurationRuntimeException(e);
}
@@ -158,27 +157,20 @@ class InstanceResolver {
* @param cKey a ConfigKey
* @return a {@link ConfigInstance} or null if not available in classpath
*/
- private static ConfigInstance getInstance(ConfigDefinitionKey cKey, ClassLoader instanceLoader) {
+ @SuppressWarnings("unchecked")
+ private static Class<? extends ConfigInstance> getConfigClass(ConfigDefinitionKey cKey, ClassLoader instanceLoader) {
String className = ConfigGenerator.createClassName(cKey.getName());
- Class<?> clazz;
String fullClassName = packageName(cKey) + "." + className;
+ Class<?> clazz;
try {
clazz = instanceLoader != null ? instanceLoader.loadClass(fullClassName) : Class.forName(fullClassName);
} catch (ClassNotFoundException e) {
- return null;
- }
- Object i;
- try {
- Constructor<?> configConstructor = clazz.getDeclaredConstructor();
- configConstructor.setAccessible(true);
- i = configConstructor.newInstance();
- } catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) {
- throw new ConfigurationRuntimeException(e);
+ throw new ConfigurationRuntimeException("Could not find config class for key " + cKey, e);
}
- if (!(i instanceof ConfigInstance)) {
- throw new ConfigurationRuntimeException(fullClassName + " is not a ConfigInstance, can not produce config for the name '" + cKey.getName() + "'.");
+ if (! ConfigInstance.class.isAssignableFrom(clazz)) {
+ throw new ConfigurationRuntimeException(fullClassName + " is not a ConfigInstance subclass, can not produce config for " + cKey);
}
- return (ConfigInstance) i;
+ return (Class<? extends ConfigInstance>) clazz;
}
static String packageName(ConfigDefinitionKey cKey) {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
index ff8bf61cdb6..8227be3347a 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
@@ -102,7 +102,7 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri
ModelElement documentsElement = contentElement.getChild("documents");
Map<String, NewDocumentType> documentDefinitions =
- new SearchDefinitionBuilder().build(context.getParentProducer().getRoot().getDeployState().getDocumentModel().getDocumentManager(), documentsElement);
+ new SearchDefinitionBuilder().build(context.getDeployState().getDocumentModel().getDocumentManager(), documentsElement);
String routingSelection = new DocumentSelectionBuilder().build(documentsElement);
Redundancy redundancy = new RedundancyBuilder().build(contentElement);
@@ -110,7 +110,7 @@ public class ContentCluster extends AbstractConfigProducer implements StorDistri
ContentCluster c = new ContentCluster(context.getParentProducer(), getClusterName(contentElement), documentDefinitions,
globallyDistributedDocuments, routingSelection, redundancy,
- context.getParentProducer().getRoot().getDeployState().getProperties().zone());
+ context.getDeployState().getProperties().zone());
c.clusterControllerConfig = new ClusterControllerConfig.Builder(getClusterName(contentElement), contentElement).build(c, contentElement.getXml());
c.search = new ContentSearchCluster.Builder(documentDefinitions, globallyDistributedDocuments).build(c, contentElement.getXml());
c.persistenceFactory = new EngineFactoryBuilder().build(contentElement, c);
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java b/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java
index 5e02a6a84d1..38c7e8524b4 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java
@@ -210,6 +210,7 @@ public class Tuning extends AbstractConfigProducer implements PartitionsConfig.P
public static class Compression {
public enum Type {
NONE("NONE"),
+ ZSTD("ZSTD"),
LZ4("LZ4");
public final String name;
diff --git a/config-model/src/main/resources/schema/content.rnc b/config-model/src/main/resources/schema/content.rnc
index 66e97e76aa4..88527951ccc 100644
--- a/config-model/src/main/resources/schema/content.rnc
+++ b/config-model/src/main/resources/schema/content.rnc
@@ -361,6 +361,6 @@ TuningIoOptionsLight = string "normal" | string "directio"
TuningIoOptionsFull = string "normal" | string "directio" | string "mmap" | string "mlock"
TuningCompression = element compression {
- element type { string "none" | string "lz4" }? &
+ element type { string "none" | string "lz4" | string "zstd" }? &
element level { xsd:nonNegativeInteger }?
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java
index 595013c506e..1ac892f551a 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java
@@ -2,10 +2,8 @@
package com.yahoo.vespa.model.content.utils;
import com.yahoo.config.application.api.ApplicationPackage;
-import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.model.api.HostProvisioner;
-import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.provision.InMemoryProvisioner;
import com.yahoo.config.model.provision.SingleNodeProvisioner;
@@ -53,7 +51,7 @@ public class ContentClusterUtils {
public static ContentCluster createCluster(String clusterXml, MockRoot root) throws Exception {
Document doc = XML.getDocument(clusterXml);
Admin admin = new Admin(root, new Yamas("vespa", 60), new Metrics(), Collections.emptyMap(), false);
- ConfigModelContext context = ConfigModelContext.create(null, DeployState.createTestState(), null, root, null);
+ ConfigModelContext context = ConfigModelContext.create(null, root.getDeployState(), null, root, null);
return new ContentCluster.Builder(admin).build(Collections.emptyList(), context, doc.getDocumentElement());
}