Search in sources :

Example 1 with SlobrokEntryResponse

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

the class InstanceResourceTest method testGetSlobrokEntriesWith.

private void testGetSlobrokEntriesWith(String pattern, String expectedLookupPattern) throws Exception {
    when(slobrokApi.lookup(APPLICATION_ID, expectedLookupPattern)).thenReturn(ENTRIES);
    List<SlobrokEntryResponse> response = resource.getSlobrokEntries(APPLICATION_INSTANCE_REFERENCE, pattern);
    verify(slobrokApi).lookup(APPLICATION_ID, expectedLookupPattern);
    ObjectMapper mapper = new ObjectMapper();
    String actualJson = mapper.writeValueAsString(response);
    assertEquals("[{\"name\":\"name1\",\"spec\":\"spec1\"},{\"name\":\"name2\",\"spec\":\"spec2\"}]", actualJson);
}
Also used : SlobrokEntryResponse(com.yahoo.vespa.orchestrator.restapi.wire.SlobrokEntryResponse) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with SlobrokEntryResponse

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

the class InstanceResource method getSlobrokEntries.

@GET
@Path("/{instanceId}/slobrok")
@Produces(MediaType.APPLICATION_JSON)
public List<SlobrokEntryResponse> getSlobrokEntries(@PathParam("instanceId") String instanceId, @QueryParam("pattern") String pattern) {
    ApplicationInstanceReference reference = parseInstanceId(instanceId);
    ApplicationId applicationId = OrchestratorUtil.toApplicationId(reference);
    if (pattern == null) {
        pattern = DEFAULT_SLOBROK_PATTERN;
    }
    List<Mirror.Entry> entries = slobrokApi.lookup(applicationId, pattern);
    return entries.stream().map(entry -> new SlobrokEntryResponse(entry.getName(), entry.getSpec())).collect(Collectors.toList());
}
Also used : PathParam(javax.ws.rs.PathParam) Produces(javax.ws.rs.Produces) ApplicationId(com.yahoo.config.provision.ApplicationId) Mirror(com.yahoo.jrt.slobrok.api.Mirror) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) OrchestratorUtil.getHostsUsedByApplicationInstance(com.yahoo.vespa.orchestrator.OrchestratorUtil.getHostsUsedByApplicationInstance) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) Inject(javax.inject.Inject) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) HostName(com.yahoo.vespa.applicationmodel.HostName) Component(com.yahoo.container.jaxrs.annotation.Component) Map(java.util.Map) OrchestratorUtil(com.yahoo.vespa.orchestrator.OrchestratorUtil) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) OrchestratorUtil.parseAppInstanceReference(com.yahoo.vespa.orchestrator.OrchestratorUtil.parseAppInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) StatusService(com.yahoo.vespa.orchestrator.status.StatusService) OrchestratorUtil.getHostStatusMap(com.yahoo.vespa.orchestrator.OrchestratorUtil.getHostStatusMap) Set(java.util.Set) SlobrokEntryResponse(com.yahoo.vespa.orchestrator.restapi.wire.SlobrokEntryResponse) Collectors(java.util.stream.Collectors) SlobrokApi(com.yahoo.vespa.service.monitor.SlobrokApi) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) List(java.util.List) Response(javax.ws.rs.core.Response) WebApplicationException(javax.ws.rs.WebApplicationException) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) InstanceLookupService(com.yahoo.vespa.orchestrator.InstanceLookupService) SlobrokEntryResponse(com.yahoo.vespa.orchestrator.restapi.wire.SlobrokEntryResponse) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ApplicationId(com.yahoo.config.provision.ApplicationId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

SlobrokEntryResponse (com.yahoo.vespa.orchestrator.restapi.wire.SlobrokEntryResponse)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Component (com.yahoo.container.jaxrs.annotation.Component)1 Mirror (com.yahoo.jrt.slobrok.api.Mirror)1 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)1 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)1 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)1 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)1 HostName (com.yahoo.vespa.applicationmodel.HostName)1 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)1 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)1 InstanceLookupService (com.yahoo.vespa.orchestrator.InstanceLookupService)1 OrchestratorUtil (com.yahoo.vespa.orchestrator.OrchestratorUtil)1 OrchestratorUtil.getHostStatusMap (com.yahoo.vespa.orchestrator.OrchestratorUtil.getHostStatusMap)1 OrchestratorUtil.getHostsUsedByApplicationInstance (com.yahoo.vespa.orchestrator.OrchestratorUtil.getHostsUsedByApplicationInstance)1 OrchestratorUtil.parseAppInstanceReference (com.yahoo.vespa.orchestrator.OrchestratorUtil.parseAppInstanceReference)1 HostStatus (com.yahoo.vespa.orchestrator.status.HostStatus)1 StatusService (com.yahoo.vespa.orchestrator.status.StatusService)1 SlobrokApi (com.yahoo.vespa.service.monitor.SlobrokApi)1