Search in sources :

Example 1 with UnknownConfigIdException

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

the class GetConfigProcessor method run.

// TODO: Increment statistics (Metrics) failed counters when requests fail
public void run() {
    // Request has already been detached
    if (!request.validateParameters()) {
        // Error code is set in verifyParameters if parameters are not OK.
        log.log(LogLevel.WARNING, "Parameters for request " + request + " did not validate: " + request.errorCode() + " : " + request.errorMessage());
        respond(request);
        return;
    }
    Trace trace = request.getRequestTrace();
    if (logDebug(trace)) {
        debugLog(trace, "GetConfigProcessor.run() on " + localHostName);
    }
    Optional<TenantName> tenant = rpcServer.resolveTenant(request, trace);
    // fabricate an empty request to cause the sentinel to stop all running services
    if (rpcServer.isHostedVespa() && rpcServer.allTenantsLoaded() && !tenant.isPresent() && isSentinelConfigRequest(request)) {
        returnEmpty(request);
        return;
    }
    GetConfigContext context = rpcServer.createGetConfigContext(tenant, request, trace);
    if (context == null || !context.requestHandler().hasApplication(context.applicationId(), Optional.<Version>empty())) {
        handleError(request, ErrorCode.APPLICATION_NOT_LOADED, "No application exists");
        return;
    }
    Optional<Version> vespaVersion = rpcServer.useRequestVersion() ? request.getVespaVersion().map(VespaVersion::toString).map(Version::fromString) : Optional.empty();
    if (logDebug(trace)) {
        debugLog(trace, "Using version " + getPrintableVespaVersion(vespaVersion));
    }
    if (!context.requestHandler().hasApplication(context.applicationId(), vespaVersion)) {
        handleError(request, ErrorCode.UNKNOWN_VESPA_VERSION, "Unknown Vespa version in request: " + getPrintableVespaVersion(vespaVersion));
        return;
    }
    this.logPre = Tenants.logPre(context.applicationId());
    ConfigResponse config;
    try {
        config = rpcServer.resolveConfig(request, context, vespaVersion);
    } catch (UnknownConfigDefinitionException e) {
        handleError(request, ErrorCode.UNKNOWN_DEFINITION, "Unknown config definition " + request.getConfigKey());
        return;
    } catch (UnknownConfigIdException e) {
        handleError(request, ErrorCode.ILLEGAL_CONFIGID, "Illegal config id " + request.getConfigKey().getConfigId());
        return;
    } catch (Throwable e) {
        log.log(Level.SEVERE, "Unexpected error handling config request", e);
        handleError(request, ErrorCode.INTERNAL_ERROR, "Internal error " + e.getMessage());
        return;
    }
    // config == null is not an error, but indicates that the config will be returned later.
    if ((config != null) && (!config.hasEqualConfig(request) || config.hasNewerGeneration(request) || forceResponse)) {
        // debugLog(trace, "config response before encoding:" + config.toString());
        request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), config.getConfigMd5());
        if (logDebug(trace)) {
            debugLog(trace, "return response: " + request.getShortDescription());
        }
        respond(request);
    } else {
        if (logDebug(trace)) {
            debugLog(trace, "delaying response " + request.getShortDescription());
        }
        rpcServer.delayResponse(request, context);
    }
}
Also used : UnknownConfigIdException(com.yahoo.vespa.config.UnknownConfigIdException) Version(com.yahoo.config.provision.Version) TenantName(com.yahoo.config.provision.TenantName) UnknownConfigDefinitionException(com.yahoo.vespa.config.server.UnknownConfigDefinitionException) GetConfigContext(com.yahoo.vespa.config.server.GetConfigContext)

Aggregations

TenantName (com.yahoo.config.provision.TenantName)1 Version (com.yahoo.config.provision.Version)1 UnknownConfigIdException (com.yahoo.vespa.config.UnknownConfigIdException)1 GetConfigContext (com.yahoo.vespa.config.server.GetConfigContext)1 UnknownConfigDefinitionException (com.yahoo.vespa.config.server.UnknownConfigDefinitionException)1