Search in sources :

Example 1 with ConfigResponse

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

the class HttpGetConfigHandler method resolveConfig.

private ConfigResponse resolveConfig(HttpConfigRequest request, RequestHandler requestHandler) {
    log.log(LogLevel.DEBUG, "nocache=" + request.noCache());
    ConfigResponse config = requestHandler.resolveConfig(request.getApplicationId(), request, Optional.empty());
    if (config == null)
        HttpConfigRequest.throwModelNotReady();
    return config;
}
Also used : ConfigResponse(com.yahoo.vespa.config.protocol.ConfigResponse) HttpConfigResponse(com.yahoo.vespa.config.server.http.HttpConfigResponse)

Example 2 with ConfigResponse

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

the class HttpGetConfigHandler method resolveConfig.

private ConfigResponse resolveConfig(HttpConfigRequest request) {
    log.log(LogLevel.DEBUG, "nocache=" + request.noCache());
    ConfigResponse config = requestHandler.resolveConfig(ApplicationId.defaultId(), request, Optional.empty());
    if (config == null)
        HttpConfigRequest.throwModelNotReady();
    return config;
}
Also used : ConfigResponse(com.yahoo.vespa.config.protocol.ConfigResponse)

Example 3 with ConfigResponse

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

the class ServerCacheTest method testThatCacheWorks.

@Test
public void testThatCacheWorks() {
    assertNotNull(cache.getDef(fooBazDefKey));
    assertThat(cache.getDef(fooBarDefKey), is(payload));
    assertThat(cache.getDef(fooBimDefKey).getCNode().getName(), is("mynode"));
    ConfigResponse raw = cache.get(fooBarCacheKey);
    assertThat(raw.getConfigMd5(), is(configMd5));
}
Also used : SlimeConfigResponse(com.yahoo.vespa.config.protocol.SlimeConfigResponse) ConfigResponse(com.yahoo.vespa.config.protocol.ConfigResponse) Test(org.junit.Test)

Example 4 with ConfigResponse

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

the class ConfigResponseFactoryTest method testLZ4CompressedFacory.

@Test
public void testLZ4CompressedFacory() {
    LZ4ConfigResponseFactory responseFactory = new LZ4ConfigResponseFactory();
    ConfigResponse response = responseFactory.createResponse(ConfigPayload.empty(), def, 3);
    assertThat(response.getCompressionInfo().getCompressionType(), is(CompressionType.LZ4));
    assertThat(response.getGeneration(), is(3l));
    assertThat(response.getPayload().getByteLength(), is(3));
}
Also used : ConfigResponse(com.yahoo.vespa.config.protocol.ConfigResponse) Test(org.junit.Test)

Example 5 with ConfigResponse

use of com.yahoo.vespa.config.protocol.ConfigResponse 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

ConfigResponse (com.yahoo.vespa.config.protocol.ConfigResponse)10 Test (org.junit.Test)6 SlimeConfigResponse (com.yahoo.vespa.config.protocol.SlimeConfigResponse)3 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)2 ConfigurationRuntimeException (com.yahoo.config.ConfigurationRuntimeException)1 SimpletypesConfig (com.yahoo.config.SimpletypesConfig)1 DefParser (com.yahoo.config.codegen.DefParser)1 InnerCNode (com.yahoo.config.codegen.InnerCNode)1 ConfigCacheKey (com.yahoo.vespa.config.ConfigCacheKey)1 ConfigDefinition (com.yahoo.vespa.config.buildergen.ConfigDefinition)1 UnknownConfigDefinitionException (com.yahoo.vespa.config.server.UnknownConfigDefinitionException)1 HttpConfigResponse (com.yahoo.vespa.config.server.http.HttpConfigResponse)1 StringReader (java.io.StringReader)1