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