Search in sources :

Example 1 with ConfigDefinitionKey

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

the class InstanceResolver method resolveToBuilder.

/**
 * Resolves this config key into a correctly typed ConfigBuilder using the given config model.
 * FIXME: Make private once config overrides are deprecated.?
 *
 * @return the config builder or null if no producer for this found in model
 */
static ConfigBuilder resolveToBuilder(ConfigKey<?> key, VespaModel model, ConfigDefinition targetDef) {
    if (model == null)
        return null;
    ConfigDefinitionKey defKey = new ConfigDefinitionKey(key);
    ConfigInstance.Builder builder = model.createBuilder(defKey, targetDef);
    model.getConfig(builder, key.getConfigId());
    return builder;
}
Also used : ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) ConfigInstance(com.yahoo.config.ConfigInstance)

Example 2 with ConfigDefinitionKey

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

the class VespaModel method configsProduced.

private static Set<ConfigKey<?>> configsProduced(ConfigProducer cp) {
    Set<ConfigKey<?>> ret = ReflectionUtil.configsProducedByInterface(cp.getClass(), cp.getConfigId());
    UserConfigRepo userConfigs = cp.getUserConfigs();
    for (ConfigDefinitionKey userKey : userConfigs.configsProduced()) {
        ret.add(new ConfigKey<>(userKey.getName(), cp.getConfigId(), userKey.getNamespace()));
    }
    return ret;
}
Also used : UserConfigRepo(com.yahoo.config.model.producer.UserConfigRepo) ConfigKey(com.yahoo.vespa.config.ConfigKey) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey)

Example 3 with ConfigDefinitionKey

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

the class VespaDomBuilderTest method testUserConfigsWithNamespace.

@Test
public void testUserConfigsWithNamespace() throws Exception {
    VespaModel model = createModel(hosts, servicesWithNamespace);
    GenericConfig.GenericConfigBuilder builder = new GenericConfig.GenericConfigBuilder(new ConfigDefinitionKey("testnamespace", "foo"), new ConfigPayloadBuilder());
    model.getConfig(builder, "admin");
    assertEquals(builder.getPayload().toString(), "{\n" + " \"basicStruct\": {\n" + "  \"stringVal\": \"default\"\n" + " }\n" + "}\n");
    model = createModel(hosts, servicesWithNamespace2);
    builder = new GenericConfig.GenericConfigBuilder(new ConfigDefinitionKey("testnamespace", "foo"), new ConfigPayloadBuilder());
    model.getConfig(builder, "admin");
    assertEquals(builder.getPayload().toString(), "{\n" + " \"basicStruct\": {\n" + "  \"stringVal\": \"default\"\n" + " }\n" + "}\n");
}
Also used : GenericConfig(com.yahoo.vespa.config.GenericConfig) VespaModel(com.yahoo.vespa.model.VespaModel) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) ConfigPayloadBuilder(com.yahoo.vespa.config.ConfigPayloadBuilder) Test(org.junit.Test)

Example 4 with ConfigDefinitionKey

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

the class UserConfigBuilderTest method require_that_arrays_config_is_resolved.

@Test
public void require_that_arrays_config_is_resolved() throws ParserConfigurationException, IOException, SAXException {
    Element configRoot = getDocument("<config name=\"arraytypes\">" + "    <intarr operation=\"append\">13</intarr>" + "    <intarr operation=\"append\">10</intarr>" + "    <intarr operation=\"append\">1337</intarr>" + "</config>");
    UserConfigRepo map = UserConfigBuilder.build(configRoot, configDefinitionStore, new BaseDeployLogger());
    assertFalse(map.isEmpty());
    ConfigDefinitionKey key = new ConfigDefinitionKey("arraytypes", "config");
    assertNotNull(map.get(key));
    ArraytypesConfig config = createConfig(ArraytypesConfig.class, map.get(key));
    assertThat(config.intarr().size(), is(3));
    assertThat(config.intarr(0), is(13));
    assertThat(config.intarr(1), is(10));
    assertThat(config.intarr(2), is(1337));
}
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) ArraytypesConfig(com.yahoo.test.ArraytypesConfig) Test(org.junit.Test)

Example 5 with ConfigDefinitionKey

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

the class UserConfigBuilderTest method require_that_simple_config_is_resolved.

@Test
public void require_that_simple_config_is_resolved() throws ParserConfigurationException, IOException, SAXException {
    Element configRoot = getDocument("<config name=\"simpletypes\">" + "    <intval>13</intval>" + "</config>" + "<config name=\"simpletypes\" version=\"1\">" + "    <stringval>foolio</stringval>" + "</config>");
    UserConfigRepo map = UserConfigBuilder.build(configRoot, configDefinitionStore, new BaseDeployLogger());
    assertFalse(map.isEmpty());
    ConfigDefinitionKey key = new ConfigDefinitionKey("simpletypes", "config");
    assertNotNull(map.get(key));
    SimpletypesConfig config = createConfig(SimpletypesConfig.class, map.get(key));
    assertThat(config.intval(), is(13));
    assertThat(config.stringval(), is("foolio"));
}
Also used : UserConfigRepo(com.yahoo.config.model.producer.UserConfigRepo) SimpletypesConfig(com.yahoo.test.SimpletypesConfig) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Element(org.w3c.dom.Element) 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