Search in sources :

Example 6 with ConfigDefinitionKey

use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.

the class UserConfigBuilderTest method assertArraysOfStructs.

private void assertArraysOfStructs(Element configRoot) {
    UserConfigRepo map = UserConfigBuilder.build(configRoot, configDefinitionStore, new BaseDeployLogger());
    assertFalse(map.isEmpty());
    ConfigDefinitionKey key = new ConfigDefinitionKey(SpecialtokensConfig.CONFIG_DEF_NAME, SpecialtokensConfig.CONFIG_DEF_NAMESPACE);
    assertNotNull(map.get(key));
    SpecialtokensConfig config = createConfig(SpecialtokensConfig.class, map.get(key));
    assertThat(config.tokenlist().size(), is(1));
    assertThat(config.tokenlist().get(0).name(), is("default"));
    assertThat(config.tokenlist().get(0).tokens().size(), is(1));
    assertThat(config.tokenlist().get(0).tokens().get(0).token(), is("dvd+-r"));
}
Also used : UserConfigRepo(com.yahoo.config.model.producer.UserConfigRepo) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) SpecialtokensConfig(com.yahoo.vespa.configdefinition.SpecialtokensConfig)

Example 7 with ConfigDefinitionKey

use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.

the class UserConfigBuilderTest method no_exception_when_config_class_does_not_exist.

@Test
public void no_exception_when_config_class_does_not_exist() throws ParserConfigurationException, IOException, SAXException {
    Element configRoot = getDocument("<config name=\"unknown\">" + "    <foo>1</foo>" + "</config>");
    UserConfigRepo repo = UserConfigBuilder.build(configRoot, configDefinitionStore, new BaseDeployLogger());
    ConfigPayloadBuilder builder = repo.get(new ConfigDefinitionKey("unknown", "config"));
    assertNotNull(builder);
}
Also used : UserConfigRepo(com.yahoo.config.model.producer.UserConfigRepo) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Element(org.w3c.dom.Element) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) ConfigPayloadBuilder(com.yahoo.vespa.config.ConfigPayloadBuilder) Test(org.junit.Test)

Example 8 with ConfigDefinitionKey

use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.

the class SuperModelController method getConfigDefinition.

private InnerCNode getConfigDefinition(ConfigKey<?> configKey, DefContent defContent) {
    if (defContent.isEmpty()) {
        ConfigDefinitionKey configDefinitionKey = new ConfigDefinitionKey(configKey.getName(), configKey.getNamespace());
        ConfigDefinition configDefinition = configDefinitionRepo.getConfigDefinitions().get(configDefinitionKey);
        if (configDefinition == null) {
            throw new UnknownConfigDefinitionException("Unable to find config definition for '" + configKey.getNamespace() + "." + configKey.getName());
        }
        return configDefinition.getCNode();
    } else {
        DefParser dParser = new DefParser(configKey.getName(), new StringReader(defContent.asString()));
        return dParser.getTree();
    }
}
Also used : ConfigDefinition(com.yahoo.vespa.config.buildergen.ConfigDefinition) StringReader(java.io.StringReader) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) DefParser(com.yahoo.config.codegen.DefParser)

Example 9 with ConfigDefinitionKey

use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.

the class Application method getTargetDef.

private ConfigDefinition getTargetDef(GetConfigRequest req) {
    ConfigKey<?> configKey = req.getConfigKey();
    DefContent def = req.getDefContent();
    ConfigDefinitionKey configDefinitionKey = new ConfigDefinitionKey(configKey.getName(), configKey.getNamespace());
    if (def.isEmpty()) {
        if (logDebug()) {
            debug("No config schema in request for " + configKey);
        }
        return cache.getDef(configDefinitionKey);
    } else {
        if (logDebug()) {
            debug("Got config schema from request, length:" + def.asList().size() + " : " + configKey);
        }
        return new ConfigDefinition(configKey.getName(), def.asStringArray());
    }
}
Also used : ConfigDefinition(com.yahoo.vespa.config.buildergen.ConfigDefinition) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) DefContent(com.yahoo.vespa.config.protocol.DefContent)

Example 10 with ConfigDefinitionKey

use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.

the class ConfigUtilsTest method testCreateConfigDefinitionKeyFromZKString.

@Test
public void testCreateConfigDefinitionKeyFromZKString() {
    String input = "bar.foo,1";
    ConfigDefinitionKey def = ConfigUtils.createConfigDefinitionKeyFromZKString(input);
    assertThat(def.getName(), is("foo"));
    assertThat(def.getNamespace(), is("bar"));
}
Also used : ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) Test(org.junit.Test)

Aggregations

ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)28 Test (org.junit.Test)15 File (java.io.File)7 UnparsedConfigDefinition (com.yahoo.config.application.api.UnparsedConfigDefinition)6 UserConfigRepo (com.yahoo.config.model.producer.UserConfigRepo)5 ConfigDefinition (com.yahoo.vespa.config.ConfigDefinition)5 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)4 JarFile (java.util.jar.JarFile)4 Element (org.w3c.dom.Element)4 DefParser (com.yahoo.config.codegen.DefParser)3 ConfigPayloadBuilder (com.yahoo.vespa.config.ConfigPayloadBuilder)3 ConfigDefinition (com.yahoo.vespa.config.buildergen.ConfigDefinition)3 LinkedHashMap (java.util.LinkedHashMap)3 ConfigInstance (com.yahoo.config.ConfigInstance)2 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)2 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)2 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)2 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)2 GenericConfig (com.yahoo.vespa.config.GenericConfig)2 VespaModel (com.yahoo.vespa.model.VespaModel)2