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