Search in sources :

Example 6 with ConfigId

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

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

the class OrchestratorImplTest method testGetHost.

@Test
public void testGetHost() throws Exception {
    ClusterControllerClientFactory clusterControllerClientFactory = mock(ClusterControllerClientFactory.class);
    StatusService statusService = mock(StatusService.class);
    InstanceLookupService lookupService = mock(InstanceLookupService.class);
    orchestrator = new OrchestratorImpl(clusterControllerClientFactory, statusService, new OrchestratorConfig(new OrchestratorConfig.Builder()), lookupService);
    HostName hostName = new HostName("host.yahoo.com");
    TenantId tenantId = new TenantId("tenant");
    ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId("applicationInstanceId");
    ApplicationInstanceReference reference = new ApplicationInstanceReference(tenantId, applicationInstanceId);
    ApplicationInstance applicationInstance = new ApplicationInstance(tenantId, applicationInstanceId, Stream.of(new ServiceCluster(new ClusterId("clusterId"), new ServiceType("serviceType"), Stream.of(new ServiceInstance(new ConfigId("configId1"), hostName, ServiceStatus.UP), new ServiceInstance(new ConfigId("configId2"), hostName, ServiceStatus.NOT_CHECKED)).collect(Collectors.toSet()))).collect(Collectors.toSet()));
    when(lookupService.findInstanceByHost(hostName)).thenReturn(Optional.of(applicationInstance));
    ReadOnlyStatusRegistry readOnlyStatusRegistry = mock(ReadOnlyStatusRegistry.class);
    when(statusService.forApplicationInstance(reference)).thenReturn(readOnlyStatusRegistry);
    when(readOnlyStatusRegistry.getHostStatus(hostName)).thenReturn(HostStatus.ALLOWED_TO_BE_DOWN);
    Host host = orchestrator.getHost(hostName);
    assertEquals(reference, host.getApplicationInstanceReference());
    assertEquals(hostName, host.getHostName());
    assertEquals(HostStatus.ALLOWED_TO_BE_DOWN, host.getHostStatus());
    assertEquals(2, host.getServiceInstances().size());
}
Also used : OrchestratorConfig(com.yahoo.vespa.orchestrator.config.OrchestratorConfig) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) StatusService(com.yahoo.vespa.orchestrator.status.StatusService) InMemoryStatusService(com.yahoo.vespa.orchestrator.status.InMemoryStatusService) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) TenantId(com.yahoo.vespa.applicationmodel.TenantId) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ReadOnlyStatusRegistry(com.yahoo.vespa.orchestrator.status.ReadOnlyStatusRegistry) ClusterControllerClientFactory(com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 8 with ConfigId

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

the class ConfigServerApplication method toApplicationInstance.

ApplicationInstance toApplicationInstance(List<String> hostnames) {
    Set<ServiceInstance> serviceInstances = hostnames.stream().map(hostname -> new ServiceInstance(new ConfigId(CONFIG_ID_PREFIX + hostname), new HostName(hostname), ServiceStatus.NOT_CHECKED)).collect(Collectors.toSet());
    ServiceCluster serviceCluster = new ServiceCluster(CLUSTER_ID, SERVICE_TYPE, serviceInstances);
    Set<ServiceCluster> serviceClusters = Stream.of(serviceCluster).collect(Collectors.toSet());
    ApplicationInstance applicationInstance = new ApplicationInstance(TENANT_ID, APPLICATION_INSTANCE_ID, serviceClusters);
    // Fill back-references
    serviceCluster.setApplicationInstance(applicationInstance);
    for (ServiceInstance serviceInstance : serviceCluster.serviceInstances()) {
        serviceInstance.setServiceCluster(serviceCluster);
    }
    return applicationInstance;
}
Also used : ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) Set(java.util.Set) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) TenantId(com.yahoo.vespa.applicationmodel.TenantId) Collectors(java.util.stream.Collectors) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) List(java.util.List) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) Stream(java.util.stream.Stream) HostName(com.yahoo.vespa.applicationmodel.HostName) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 9 with ConfigId

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

the class UnionMonitorManagerTest method testWith.

private void testWith(boolean nodeAdminInContainer, ApplicationId applicationId, ClusterId clusterId, ServiceType serviceType, int expectedSlobrokCalls, int expectedHealthCalls) {
    SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
    HealthMonitorManager healthMonitorManager = mock(HealthMonitorManager.class);
    ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder();
    builder.nodeAdminInContainer(nodeAdminInContainer);
    ConfigserverConfig config = new ConfigserverConfig(builder);
    UnionMonitorManager manager = new UnionMonitorManager(slobrokMonitorManager, healthMonitorManager, config);
    manager.getStatus(applicationId, clusterId, serviceType, new ConfigId("config-id"));
    verify(slobrokMonitorManager, times(expectedSlobrokCalls)).getStatus(any(), any(), any(), any());
    verify(healthMonitorManager, times(expectedHealthCalls)).getStatus(any(), any(), any(), any());
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId)

Example 10 with ConfigId

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

the class ServiceMonitorStub method getAllApplicationInstances.

@Override
public Map<ApplicationInstanceReference, ApplicationInstance> getAllApplicationInstances() {
    // Convert apps information to the response payload to return
    Map<ApplicationInstanceReference, ApplicationInstance> status = new HashMap<>();
    for (Map.Entry<ApplicationId, MockDeployer.ApplicationContext> app : apps.entrySet()) {
        Set<ServiceInstance> serviceInstances = new HashSet<>();
        for (Node node : nodeRepository.getNodes(app.getValue().id(), Node.State.active)) {
            serviceInstances.add(new ServiceInstance(new ConfigId("configid"), new HostName(node.hostname()), getHostStatus(node.hostname())));
        }
        Set<ServiceCluster> serviceClusters = new HashSet<>();
        serviceClusters.add(new ServiceCluster(new ClusterId(app.getValue().clusterContexts().get(0).cluster().id().value()), new ServiceType("serviceType"), serviceInstances));
        TenantId tenantId = new TenantId(app.getKey().tenant().value());
        ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId(app.getKey().application().value());
        status.put(new ApplicationInstanceReference(tenantId, applicationInstanceId), new ApplicationInstance(tenantId, applicationInstanceId, serviceClusters));
    }
    return status;
}
Also used : HashMap(java.util.HashMap) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) Node(com.yahoo.vespa.hosted.provision.Node) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) TenantId(com.yahoo.vespa.applicationmodel.TenantId) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ApplicationId(com.yahoo.config.provision.ApplicationId) HashMap(java.util.HashMap) Map(java.util.Map) HostName(com.yahoo.vespa.applicationmodel.HostName) HashSet(java.util.HashSet)

Aggregations

ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)13 Test (org.junit.Test)7 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)6 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)5 HostName (com.yahoo.vespa.applicationmodel.HostName)5 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)5 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)4 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)4 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)4 TenantId (com.yahoo.vespa.applicationmodel.TenantId)4 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)3 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)1 Node (com.yahoo.vespa.hosted.provision.Node)1 Host (com.yahoo.vespa.orchestrator.Host)1 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)1 OrchestratorConfig (com.yahoo.vespa.orchestrator.config.OrchestratorConfig)1 ClusterControllerClient (com.yahoo.vespa.orchestrator.controller.ClusterControllerClient)1 ClusterControllerClientFactory (com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory)1