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);
}
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());
}
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;
}
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());
}
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;
}
Aggregations