Search in sources :

Example 11 with ConfigurationRuntimeException

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);
        }
    }
}
Also used : ConfigurationRuntimeException(com.yahoo.config.ConfigurationRuntimeException) ChainSpecification(com.yahoo.component.chain.model.ChainSpecification) ConfigurationRuntimeException(com.yahoo.config.ConfigurationRuntimeException)

Example 12 with ConfigurationRuntimeException

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

Example 13 with ConfigurationRuntimeException

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

Example 14 with ConfigurationRuntimeException

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'."));
    }
}
Also used : ConfigurationRuntimeException(com.yahoo.config.ConfigurationRuntimeException) Element(org.w3c.dom.Element) Test(org.junit.Test)

Example 15 with ConfigurationRuntimeException

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);
    }
}
Also used : ConfigurationRuntimeException(com.yahoo.config.ConfigurationRuntimeException) Method(java.lang.reflect.Method) ConfigurationRuntimeException(com.yahoo.config.ConfigurationRuntimeException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ConfigurationRuntimeException (com.yahoo.config.ConfigurationRuntimeException)15 Element (org.w3c.dom.Element)3 ConfigInstance (com.yahoo.config.ConfigInstance)2 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)2 ConfigPayloadBuilder (com.yahoo.vespa.config.ConfigPayloadBuilder)2 Test (org.junit.Test)2 LbServicesConfig (com.yahoo.cloud.config.LbServicesConfig)1 RoutingConfig (com.yahoo.cloud.config.RoutingConfig)1 ChainSpecification (com.yahoo.component.chain.model.ChainSpecification)1 ConfigBuilder (com.yahoo.config.ConfigBuilder)1 Builder (com.yahoo.config.ConfigInstance.Builder)1 CfgConfigPayloadBuilder (com.yahoo.config.subscription.CfgConfigPayloadBuilder)1 ConfigInterruptedException (com.yahoo.config.subscription.ConfigInterruptedException)1 com.yahoo.vespa.config (com.yahoo.vespa.config)1 ConfigCacheKey (com.yahoo.vespa.config.ConfigCacheKey)1 ConfigKey (com.yahoo.vespa.config.ConfigKey)1 GenericConfig (com.yahoo.vespa.config.GenericConfig)1 ConfigDefinition (com.yahoo.vespa.config.buildergen.ConfigDefinition)1 ConfigResponse (com.yahoo.vespa.config.protocol.ConfigResponse)1 UnknownConfigDefinitionException (com.yahoo.vespa.config.server.UnknownConfigDefinitionException)1