Search in sources :

Example 1 with NotFoundException

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

the class HttpProxy method get.

public HttpResponse get(Application application, String hostName, String serviceType, String relativePath) {
    HostInfo host = application.getModel().getHosts().stream().filter(hostInfo -> hostInfo.getHostname().equals(hostName)).findFirst().orElseThrow(() -> new NotFoundException("Failed to find host " + hostName));
    ServiceInfo service = host.getServices().stream().filter(serviceInfo -> serviceType.equals(serviceInfo.getServiceType())).findFirst().orElseThrow(() -> new NotFoundException("Failed to find any service of type " + serviceType + " on host " + hostName));
    // "http" and "state" seems to uniquely identify an interesting HTTP port on each service
    PortInfo port = service.getPorts().stream().filter(portInfo -> portInfo.getTags().stream().collect(Collectors.toSet()).containsAll(Stream.of("http", "state").collect(Collectors.toSet()))).findFirst().orElseThrow(() -> new NotFoundException("Failed to find HTTP state port"));
    return internalGet(host.getHostname(), port.getPort(), relativePath);
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) PortInfo(com.yahoo.config.model.api.PortInfo) NotFoundException(com.yahoo.vespa.config.server.http.NotFoundException) HostInfo(com.yahoo.config.model.api.HostInfo)

Example 2 with NotFoundException

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

the class ApplicationHandler method handlePOST.

@Override
public HttpResponse handlePOST(HttpRequest request) {
    ApplicationId applicationId = getApplicationIdFromRequest(request);
    Tenant tenant = verifyTenantAndApplication(applicationId);
    if (request.getUri().getPath().endsWith("restart"))
        return restart(request, applicationId);
    if (request.getUri().getPath().endsWith("log"))
        return grabLog(request, applicationId, tenant);
    throw new NotFoundException("Illegal POST request '" + request.getUri() + "': Must end by /restart or /log");
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) NotFoundException(com.yahoo.vespa.config.server.http.NotFoundException) ApplicationId(com.yahoo.config.provision.ApplicationId)

Aggregations

NotFoundException (com.yahoo.vespa.config.server.http.NotFoundException)2 HostInfo (com.yahoo.config.model.api.HostInfo)1 PortInfo (com.yahoo.config.model.api.PortInfo)1 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)1