Search in sources :

Example 1 with HostService

use of com.yahoo.vespa.orchestrator.restapi.wire.HostService in project vespa by vespa-engine.

the class HostResource method getHost.

@Override
public GetHostResponse getHost(String hostNameString) {
    HostName hostName = new HostName(hostNameString);
    try {
        Host host = orchestrator.getHost(hostName);
        URI applicationUri = uriInfo.getBaseUriBuilder().path(InstanceResource.class).path(host.getApplicationInstanceReference().asString()).build();
        List<HostService> hostServices = host.getServiceInstances().stream().map(serviceInstance -> new HostService(serviceInstance.getServiceCluster().clusterId().s(), serviceInstance.getServiceCluster().serviceType().s(), serviceInstance.configId().s(), serviceInstance.serviceStatus().name())).collect(Collectors.toList());
        return new GetHostResponse(host.getHostName().s(), host.getHostStatus().name(), applicationUri.toString(), hostServices);
    } catch (HostNameNotFoundException e) {
        log.log(LogLevel.INFO, "Host not found: " + hostName);
        throw new NotFoundException(e);
    }
}
Also used : OrchestrationException(com.yahoo.vespa.orchestrator.OrchestrationException) PatchHostRequest(com.yahoo.vespa.orchestrator.restapi.wire.PatchHostRequest) Path(javax.ws.rs.Path) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) Inject(javax.inject.Inject) GetHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.GetHostResponse) MediaType(javax.ws.rs.core.MediaType) HostName(com.yahoo.vespa.applicationmodel.HostName) HostStateChangeDeniedException(com.yahoo.vespa.orchestrator.policy.HostStateChangeDeniedException) HostStateChangeDenialReason(com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason) Component(com.yahoo.container.jaxrs.annotation.Component) LogLevel(com.yahoo.log.LogLevel) Host(com.yahoo.vespa.orchestrator.Host) BadRequestException(javax.ws.rs.BadRequestException) URI(java.net.URI) UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException) Context(javax.ws.rs.core.Context) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) List(java.util.List) Response(javax.ws.rs.core.Response) HostService(com.yahoo.vespa.orchestrator.restapi.wire.HostService) WebApplicationException(javax.ws.rs.WebApplicationException) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) UriInfo(javax.ws.rs.core.UriInfo) PatchHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.PatchHostResponse) HostApi(com.yahoo.vespa.orchestrator.restapi.HostApi) HostService(com.yahoo.vespa.orchestrator.restapi.wire.HostService) GetHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.GetHostResponse) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException) NotFoundException(javax.ws.rs.NotFoundException) Host(com.yahoo.vespa.orchestrator.Host) URI(java.net.URI) HostName(com.yahoo.vespa.applicationmodel.HostName) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException)

Aggregations

Component (com.yahoo.container.jaxrs.annotation.Component)1 LogLevel (com.yahoo.log.LogLevel)1 HostName (com.yahoo.vespa.applicationmodel.HostName)1 Host (com.yahoo.vespa.orchestrator.Host)1 HostNameNotFoundException (com.yahoo.vespa.orchestrator.HostNameNotFoundException)1 OrchestrationException (com.yahoo.vespa.orchestrator.OrchestrationException)1 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)1 HostStateChangeDeniedException (com.yahoo.vespa.orchestrator.policy.HostStateChangeDeniedException)1 HostApi (com.yahoo.vespa.orchestrator.restapi.HostApi)1 GetHostResponse (com.yahoo.vespa.orchestrator.restapi.wire.GetHostResponse)1 HostService (com.yahoo.vespa.orchestrator.restapi.wire.HostService)1 HostStateChangeDenialReason (com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason)1 PatchHostRequest (com.yahoo.vespa.orchestrator.restapi.wire.PatchHostRequest)1 PatchHostResponse (com.yahoo.vespa.orchestrator.restapi.wire.PatchHostResponse)1 UpdateHostResponse (com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse)1 HostStatus (com.yahoo.vespa.orchestrator.status.HostStatus)1 URI (java.net.URI)1 List (java.util.List)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1