use of com.yahoo.vespa.config.buildergen.ConfigDefinition in project vespa by vespa-engine.
the class StaticConfigDefinitionRepo method addConfigDefinition.
private void addConfigDefinition(ConfigDefinitionKey key, File defFile) throws IOException {
String payload = IOUtils.readFile(defFile);
configDefinitions.put(key, new ConfigDefinition(key.getName(), StringUtils.split(payload, "\n")));
}
use of com.yahoo.vespa.config.buildergen.ConfigDefinition 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();
}
}
use of com.yahoo.vespa.config.buildergen.ConfigDefinition 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());
}
}
use of com.yahoo.vespa.config.buildergen.ConfigDefinition in project vespa by vespa-engine.
the class ServerCacheTest method setup.
@Before
public void setup() {
cache = new ServerCache();
cache.addDef(fooBarDefKey, payload);
cache.addDef(fooBazDefKey, new com.yahoo.vespa.config.buildergen.ConfigDefinition("baz", new String[0]));
cache.addDef(fooBimDefKey, new ConfigDefinition("mynode", new String[0]));
cache.put(fooBarCacheKey, SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), payload.getCNode(), 2, configMd5), configMd5);
cache.put(bazQuuxCacheKey, SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), payload.getCNode(), 2, configMd5), configMd5);
cache.put(fooBarCacheKeyDifferentMd5, SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), payload_2.getCNode(), 2, configMd5_2), configMd5_2);
}
use of com.yahoo.vespa.config.buildergen.ConfigDefinition in project vespa by vespa-engine.
the class Application method resolveConfig.
/**
* Gets a config from ZK. Returns null if not found.
*/
public ConfigResponse resolveConfig(GetConfigRequest req, ConfigResponseFactory responseFactory) {
long start = System.currentTimeMillis();
metricUpdater.incrementRequests();
ConfigKey<?> configKey = req.getConfigKey();
String defMd5 = configKey.getMd5();
if (defMd5 == null || defMd5.isEmpty()) {
defMd5 = ConfigUtils.getDefMd5(req.getDefContent().asList());
}
ConfigCacheKey cacheKey = new ConfigCacheKey(configKey, defMd5);
if (logDebug()) {
debug("Resolving config " + cacheKey);
}
if (!req.noCache()) {
ConfigResponse config = cache.get(cacheKey);
if (config != null) {
if (logDebug()) {
debug("Found config " + cacheKey + " in cache");
}
metricUpdater.incrementProcTime(System.currentTimeMillis() - start);
return config;
}
}
ConfigDefinition def = getTargetDef(req);
if (def == null) {
metricUpdater.incrementFailedRequests();
throw new UnknownConfigDefinitionException("Unable to find config definition for '" + configKey.getNamespace() + "." + configKey.getName());
}
if (logDebug()) {
debug("Resolving " + configKey + " with config definition " + def);
}
ConfigPayload payload = model.getConfig(configKey, def);
if (payload == null) {
metricUpdater.incrementFailedRequests();
throw new ConfigurationRuntimeException("Unable to resolve config " + configKey);
}
ConfigResponse configResponse = responseFactory.createResponse(payload, def.getCNode(), appGeneration);
metricUpdater.incrementProcTime(System.currentTimeMillis() - start);
if (!req.noCache()) {
cache.put(cacheKey, configResponse, configResponse.getConfigMd5());
metricUpdater.setCacheConfigElems(cache.configElems());
metricUpdater.setCacheChecksumElems(cache.checkSumElems());
}
return configResponse;
}
Aggregations