Search in sources :

Example 1 with UserConfigRepo

use of com.yahoo.config.model.producer.UserConfigRepo 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 2 with UserConfigRepo

use of com.yahoo.config.model.producer.UserConfigRepo in project vespa by vespa-engine.

the class FileSender method sendUserConfiguredFiles.

/**
 * Sends all user configured files for a producer to all given services.
 */
public static <PRODUCER extends AbstractConfigProducer<?>> void sendUserConfiguredFiles(PRODUCER producer, Collection<? extends AbstractService> services, DeployLogger logger) {
    if (services.isEmpty())
        return;
    UserConfigRepo userConfigs = producer.getUserConfigs();
    Map<String, FileReference> sentFiles = new HashMap<>();
    for (ConfigDefinitionKey key : userConfigs.configsProduced()) {
        ConfigPayloadBuilder builder = userConfigs.get(key);
        try {
            sendUserConfiguredFiles(builder, sentFiles, services, key, logger);
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("Unable to send files for " + key, e);
        }
    }
}
Also used : UserConfigRepo(com.yahoo.config.model.producer.UserConfigRepo) FileReference(com.yahoo.config.FileReference)

Example 3 with UserConfigRepo

use of com.yahoo.config.model.producer.UserConfigRepo 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 4 with UserConfigRepo

use of com.yahoo.config.model.producer.UserConfigRepo 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)

Example 5 with UserConfigRepo

use of com.yahoo.config.model.producer.UserConfigRepo 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)

Aggregations

UserConfigRepo (com.yahoo.config.model.producer.UserConfigRepo)8 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)5 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)4 Element (org.w3c.dom.Element)4 Test (org.junit.Test)3 FileReference (com.yahoo.config.FileReference)1 MockRoot (com.yahoo.config.model.test.MockRoot)1 ArraytypesConfig (com.yahoo.test.ArraytypesConfig)1 SimpletypesConfig (com.yahoo.test.SimpletypesConfig)1 ConfigKey (com.yahoo.vespa.config.ConfigKey)1 ConfigPayloadBuilder (com.yahoo.vespa.config.ConfigPayloadBuilder)1 SpecialtokensConfig (com.yahoo.vespa.configdefinition.SpecialtokensConfig)1 DomConfigPayloadBuilder (com.yahoo.vespa.model.builder.xml.dom.DomConfigPayloadBuilder)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1