Search in sources :

Example 1 with ApplicationInstanceReference

use of com.yahoo.vespa.applicationmodel.ApplicationInstanceReference in project vespa by vespa-engine.

the class ModelGeneratorTest method toApplicationModel.

@Test
public void toApplicationModel() throws Exception {
    SuperModel superModel = ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT);
    ModelGenerator modelGenerator = new ModelGenerator();
    Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
    List<String> configServerHosts = Collections.emptyList();
    SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
    when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(ServiceStatus.UP);
    ServiceModel serviceModel = modelGenerator.toServiceModel(superModel, zone, configServerHosts, slobrokMonitorManager);
    Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = serviceModel.getAllApplicationInstances();
    assertEquals(1, applicationInstances.size());
    verifyOtherApplication(applicationInstances.values().iterator().next());
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) SuperModel(com.yahoo.config.model.api.SuperModel) Zone(com.yahoo.config.provision.Zone) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) Test(org.junit.Test)

Example 2 with ApplicationInstanceReference

use of com.yahoo.vespa.applicationmodel.ApplicationInstanceReference in project vespa by vespa-engine.

the class ModelGeneratorTest method toApplicationModelWithConfigServerApplication.

@Test
public void toApplicationModelWithConfigServerApplication() throws Exception {
    SuperModel superModel = ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT);
    ModelGenerator modelGenerator = new ModelGenerator();
    Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
    List<String> configServerHosts = Stream.of("cfg1", "cfg2", "cfg3").collect(Collectors.toList());
    SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
    when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(ServiceStatus.UP);
    ServiceModel serviceModel = modelGenerator.toServiceModel(superModel, zone, configServerHosts, slobrokMonitorManager);
    Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = serviceModel.getAllApplicationInstances();
    assertEquals(2, applicationInstances.size());
    Iterator<Map.Entry<ApplicationInstanceReference, ApplicationInstance>> iterator = applicationInstances.entrySet().iterator();
    ApplicationInstance applicationInstance1 = iterator.next().getValue();
    ApplicationInstance applicationInstance2 = iterator.next().getValue();
    if (applicationInstance1.applicationInstanceId().equals(ConfigServerApplication.APPLICATION_INSTANCE_ID)) {
        verifyConfigServerApplication(applicationInstance1);
        verifyOtherApplication(applicationInstance2);
    } else {
        verifyConfigServerApplication(applicationInstance2);
        verifyOtherApplication(applicationInstance1);
    }
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) SuperModel(com.yahoo.config.model.api.SuperModel) Zone(com.yahoo.config.provision.Zone) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) Test(org.junit.Test)

Example 3 with ApplicationInstanceReference

use of com.yahoo.vespa.applicationmodel.ApplicationInstanceReference in project vespa by vespa-engine.

the class HostResourceTest method getHost_works.

@Test
public void getHost_works() throws Exception {
    Orchestrator orchestrator = mock(Orchestrator.class);
    HostResource hostResource = new HostResource(orchestrator, uriInfo);
    HostName hostName = new HostName("hostname");
    UriBuilder baseUriBuilder = mock(UriBuilder.class);
    when(uriInfo.getBaseUriBuilder()).thenReturn(baseUriBuilder);
    when(baseUriBuilder.path(any(String.class))).thenReturn(baseUriBuilder);
    when(baseUriBuilder.path(any(Class.class))).thenReturn(baseUriBuilder);
    URI uri = new URI("https://foo.com/bar");
    when(baseUriBuilder.build()).thenReturn(uri);
    ServiceInstance serviceInstance = new ServiceInstance(new ConfigId("configId"), hostName, ServiceStatus.UP);
    ServiceCluster serviceCluster = new ServiceCluster(new ClusterId("clusterId"), new ServiceType("serviceType"), Collections.singleton(serviceInstance));
    serviceInstance.setServiceCluster(serviceCluster);
    Host host = new Host(hostName, HostStatus.ALLOWED_TO_BE_DOWN, new ApplicationInstanceReference(new TenantId("tenantId"), new ApplicationInstanceId("applicationId")), Collections.singletonList(serviceInstance));
    when(orchestrator.getHost(hostName)).thenReturn(host);
    GetHostResponse response = hostResource.getHost(hostName.s());
    assertEquals("https://foo.com/bar", response.applicationUrl());
    assertEquals("hostname", response.hostname());
    assertEquals("ALLOWED_TO_BE_DOWN", response.state());
    assertEquals(1, response.services().size());
    assertEquals("clusterId", response.services().get(0).clusterId);
    assertEquals("configId", response.services().get(0).configId);
    assertEquals("UP", response.services().get(0).serviceStatus);
    assertEquals("serviceType", response.services().get(0).serviceType);
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) Host(com.yahoo.vespa.orchestrator.Host) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) URI(java.net.URI) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) TenantId(com.yahoo.vespa.applicationmodel.TenantId) GetHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.GetHostResponse) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) UriBuilder(javax.ws.rs.core.UriBuilder) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 4 with ApplicationInstanceReference

use of com.yahoo.vespa.applicationmodel.ApplicationInstanceReference in project vespa by vespa-engine.

the class InstanceResource method getServiceStatus.

@GET
@Path("/{instanceId}/serviceStatus")
@Produces(MediaType.APPLICATION_JSON)
public ServiceStatus getServiceStatus(@PathParam("instanceId") String instanceId, @QueryParam("clusterId") String clusterIdString, @QueryParam("serviceType") String serviceTypeString, @QueryParam("configId") String configIdString) {
    ApplicationInstanceReference reference = parseInstanceId(instanceId);
    ApplicationId applicationId = OrchestratorUtil.toApplicationId(reference);
    if (clusterIdString == null) {
        throwBadRequest("Missing clusterId query parameter");
    }
    if (serviceTypeString == null) {
        throwBadRequest("Missing serviceType query parameter");
    }
    if (configIdString == null) {
        throwBadRequest("Missing configId query parameter");
    }
    ClusterId clusterId = new ClusterId(clusterIdString);
    ServiceType serviceType = new ServiceType(serviceTypeString);
    ConfigId configId = new ConfigId(configIdString);
    return slobrokApi.getStatus(applicationId, clusterId, serviceType, configId);
}
Also used : ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ApplicationId(com.yahoo.config.provision.ApplicationId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with ApplicationInstanceReference

use of com.yahoo.vespa.applicationmodel.ApplicationInstanceReference 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

ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)17 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)10 HostName (com.yahoo.vespa.applicationmodel.HostName)6 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)5 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)5 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)5 Test (org.junit.Test)5 ApplicationId (com.yahoo.config.provision.ApplicationId)4 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)4 TenantId (com.yahoo.vespa.applicationmodel.TenantId)4 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)3 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)3 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)3 HashMap (java.util.HashMap)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 SuperModel (com.yahoo.config.model.api.SuperModel)2 Zone (com.yahoo.config.provision.Zone)2 OrchestratorUtil.getHostsUsedByApplicationInstance (com.yahoo.vespa.orchestrator.OrchestratorUtil.getHostsUsedByApplicationInstance)2