use of com.yahoo.config.ConfigurationRuntimeException in project vespa by vespa-engine.
the class ChainsConfigurer method instantiateChains.
private static <COMPONENT extends ChainedComponent> void instantiateChains(ComponentRegistry<Chain<COMPONENT>> chainRegistry, ChainsModel model, ComponentRegistry<COMPONENT> allComponents) {
for (ChainSpecification chain : model.allChainsFlattened()) {
try {
Chain<COMPONENT> componentChain = new Chain<>(chain.componentId, resolveComponents(chain.componentReferences, allComponents), chain.phases());
chainRegistry.register(chain.componentId, componentChain);
} catch (Exception e) {
throw new ConfigurationRuntimeException("Invalid chain '" + chain.componentId + "'", e);
}
}
}
use of com.yahoo.config.ConfigurationRuntimeException 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;
}
use of com.yahoo.config.ConfigurationRuntimeException in project vespa by vespa-engine.
the class JRTConfigRequester method doRequest.
private <T extends ConfigInstance> void doRequest(JRTConfigSubscription<T> sub, JRTClientConfigRequest req, long timeout) {
com.yahoo.vespa.config.Connection connection = connectionPool.getCurrent();
req.getRequest().setContext(new RequestContext(sub, req, connection));
boolean reqOK = req.validateParameters();
if (!reqOK)
throw new ConfigurationRuntimeException("Error in parameters for config request: " + req);
// Add some time to the timeout, we never want it to time out in JRT during normal operation
double jrtClientTimeout = getClientTimeout(timeout);
if (log.isLoggable(LogLevel.DEBUG)) {
log.log(LogLevel.DEBUG, "Requesting config for " + sub + " on connection " + connection + " with RPC timeout " + jrtClientTimeout + ",defcontent=" + req.getDefContent().asString());
}
connection.invokeAsync(req.getRequest(), jrtClientTimeout, this);
}
use of com.yahoo.config.ConfigurationRuntimeException in project vespa by vespa-engine.
the class DomConfigPayloadBuilderTest method testFailWrongTagName.
// Verifies that an exception is thrown when the root element is not 'config'.
@Test
public void testFailWrongTagName() throws FileNotFoundException, ParserConfigurationException {
Element configRoot = getDocument(new StringReader("<configs name=\"foo\"/>"));
try {
new DomConfigPayloadBuilder(null).build(configRoot);
fail("Expected exception for wrong tag name.");
} catch (ConfigurationRuntimeException e) {
assertThat(e.getMessage(), is("The root element must be 'config', but was 'configs'."));
}
}
use of com.yahoo.config.ConfigurationRuntimeException in project vespa by vespa-engine.
the class ConfigInstanceUtil method setValues.
/**
* Copies all values that have been explicitly set on the source to the destination.
* Values that have not been explicitly set in the source builder, will be left unchanged
* in the destination.
*
* @param destination The builder to copy values into.
* @param source The builder to copy values from. Unset values are not copied.
* @param <BUILDER> The builder class.
*/
public static <BUILDER extends ConfigBuilder> void setValues(BUILDER destination, BUILDER source) {
try {
Method setter = destination.getClass().getDeclaredMethod("override", destination.getClass());
setter.setAccessible(true);
setter.invoke(destination, source);
setter.setAccessible(false);
} catch (Exception e) {
throw new ConfigurationRuntimeException("Could not set values on config builder." + destination.getClass().getName(), e);
}
}
Aggregations