Search in sources :

Example 1 with ConfigDefinition

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")));
}
Also used : ConfigDefinition(com.yahoo.vespa.config.buildergen.ConfigDefinition)

Example 2 with ConfigDefinition

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();
    }
}
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 3 with ConfigDefinition

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());
    }
}
Also used : ConfigDefinition(com.yahoo.vespa.config.buildergen.ConfigDefinition) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) DefContent(com.yahoo.vespa.config.protocol.DefContent)

Example 4 with ConfigDefinition

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);
}
Also used : ConfigDefinition(com.yahoo.vespa.config.buildergen.ConfigDefinition) ConfigDefinition(com.yahoo.vespa.config.buildergen.ConfigDefinition) Before(org.junit.Before)

Example 5 with ConfigDefinition

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;
}
Also used : ConfigurationRuntimeException(com.yahoo.config.ConfigurationRuntimeException) ConfigCacheKey(com.yahoo.vespa.config.ConfigCacheKey) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) ConfigDefinition(com.yahoo.vespa.config.buildergen.ConfigDefinition) UnknownConfigDefinitionException(com.yahoo.vespa.config.server.UnknownConfigDefinitionException) ConfigResponse(com.yahoo.vespa.config.protocol.ConfigResponse)

Aggregations

ConfigDefinition (com.yahoo.vespa.config.buildergen.ConfigDefinition)6 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)3 ConfigurationRuntimeException (com.yahoo.config.ConfigurationRuntimeException)1 DefParser (com.yahoo.config.codegen.DefParser)1 ConfigCacheKey (com.yahoo.vespa.config.ConfigCacheKey)1 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)1 ConfigResponse (com.yahoo.vespa.config.protocol.ConfigResponse)1 DefContent (com.yahoo.vespa.config.protocol.DefContent)1 UnknownConfigDefinitionException (com.yahoo.vespa.config.server.UnknownConfigDefinitionException)1 StringReader (java.io.StringReader)1 Before (org.junit.Before)1