Search in sources :

Example 1 with RequestHandler

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

the class HttpGetConfigHandler method handleGET.

@Override
public HttpResponse handleGET(HttpRequest req) {
    HttpConfigRequest request = HttpConfigRequest.createFromRequestV2(req);
    RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenants, request);
    HttpConfigRequest.validateRequestKey(request.getConfigKey(), requestHandler, request.getApplicationId());
    return HttpConfigResponse.createFromConfig(resolveConfig(request, requestHandler));
}
Also used : RequestHandler(com.yahoo.vespa.config.server.RequestHandler) HttpConfigRequest(com.yahoo.vespa.config.server.http.HttpConfigRequest)

Example 2 with RequestHandler

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

the class HttpListConfigsHandler method handleGET.

@Override
public HttpResponse handleGET(HttpRequest req) {
    HttpListConfigsRequest listReq = HttpListConfigsRequest.createFromListRequest(req);
    RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenants, listReq);
    ApplicationId appId = listReq.getApplicationId();
    Set<ConfigKey<?>> configs = requestHandler.listConfigs(appId, Optional.empty(), listReq.isRecursive());
    String urlBase = getUrlBase(req, listReq, appId, zone);
    Set<ConfigKey<?>> allConfigs = requestHandler.allConfigsProduced(appId, Optional.empty());
    return new ListConfigsResponse(configs, allConfigs, urlBase, listReq.isRecursive());
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) RequestHandler(com.yahoo.vespa.config.server.RequestHandler) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 3 with RequestHandler

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

the class RpcServer method createGetConfigContext.

/**
 * Returns the context for this request, or null if the server is not properly set up with handlers
 */
public GetConfigContext createGetConfigContext(Optional<TenantName> optionalTenant, JRTServerConfigRequest request, Trace trace) {
    if ("*".equals(request.getConfigKey().getConfigId())) {
        return GetConfigContext.create(ApplicationId.global(), superModelRequestHandler, trace);
    }
    // perhaps needed for non-hosted?
    TenantName tenant = optionalTenant.orElse(TenantName.defaultName());
    if (!hasRequestHandler(tenant)) {
        String msg = Tenants.logPre(tenant) + "Unable to find request handler for tenant. Requested from host '" + request.getClientHostName() + "'";
        metrics.incUnknownHostRequests();
        trace.trace(TRACELEVEL, msg);
        log.log(LogLevel.WARNING, msg);
        return null;
    }
    RequestHandler handler = getRequestHandler(tenant);
    ApplicationId applicationId = handler.resolveApplicationId(request.getClientHostName());
    if (trace.shouldTrace(TRACELEVEL_DEBUG)) {
        trace.trace(TRACELEVEL_DEBUG, "Host '" + request.getClientHostName() + "' should have config from application '" + applicationId + "'");
    }
    return GetConfigContext.create(applicationId, handler, trace);
}
Also used : RequestHandler(com.yahoo.vespa.config.server.RequestHandler) SuperModelRequestHandler(com.yahoo.vespa.config.server.SuperModelRequestHandler) TenantName(com.yahoo.config.provision.TenantName) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 4 with RequestHandler

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

the class HttpListNamedConfigsHandler method handleGET.

@Override
public HttpResponse handleGET(HttpRequest req) {
    HttpListConfigsRequest listReq = HttpListConfigsRequest.createFromNamedListRequest(req);
    RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenants, listReq);
    ApplicationId appId = listReq.getApplicationId();
    HttpConfigRequest.validateRequestKey(listReq.getKey(), requestHandler, appId);
    Set<ConfigKey<?>> configs = requestHandler.listNamedConfigs(appId, Optional.empty(), listReq.getKey(), listReq.isRecursive());
    String urlBase = HttpListConfigsHandler.getUrlBase(req, listReq, appId, zone);
    Set<ConfigKey<?>> allConfigs = requestHandler.allConfigsProduced(appId, Optional.empty());
    return new HttpListConfigsHandler.ListConfigsResponse(configs, allConfigs, urlBase, listReq.isRecursive());
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) RequestHandler(com.yahoo.vespa.config.server.RequestHandler) ApplicationId(com.yahoo.config.provision.ApplicationId)

Aggregations

RequestHandler (com.yahoo.vespa.config.server.RequestHandler)4 ApplicationId (com.yahoo.config.provision.ApplicationId)3 ConfigKey (com.yahoo.vespa.config.ConfigKey)2 TenantName (com.yahoo.config.provision.TenantName)1 SuperModelRequestHandler (com.yahoo.vespa.config.server.SuperModelRequestHandler)1 HttpConfigRequest (com.yahoo.vespa.config.server.http.HttpConfigRequest)1