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;
}
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;
}
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");
}
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));
}
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"));
}
Aggregations