use of com.yahoo.vespa.applicationmodel.ServiceCluster 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.ServiceCluster in project vespa by vespa-engine.
the class ModelGeneratorTest method verifyOtherApplication.
private void verifyOtherApplication(ApplicationInstance applicationInstance) {
assertEquals(String.format("%s:%s:%s:%s:%s", ExampleModel.TENANT, ExampleModel.APPLICATION_NAME, ENVIRONMENT, REGION, ExampleModel.INSTANCE_NAME), applicationInstance.reference().toString());
assertEquals(ExampleModel.TENANT, applicationInstance.tenantId().toString());
Set<ServiceCluster> serviceClusters = applicationInstance.serviceClusters();
assertEquals(1, serviceClusters.size());
ServiceCluster serviceCluster = serviceClusters.iterator().next();
assertEquals(ExampleModel.CLUSTER_ID, serviceCluster.clusterId().toString());
assertEquals(ExampleModel.SERVICE_TYPE, serviceCluster.serviceType().toString());
Set<ServiceInstance> serviceInstances = serviceCluster.serviceInstances();
assertEquals(1, serviceClusters.size());
ServiceInstance serviceInstance = serviceInstances.iterator().next();
assertEquals(HOSTNAME, serviceInstance.hostName().toString());
assertEquals(ExampleModel.CONFIG_ID, serviceInstance.configId().toString());
assertEquals(ServiceStatus.UP, serviceInstance.serviceStatus());
}
use of com.yahoo.vespa.applicationmodel.ServiceCluster 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;
}
use of com.yahoo.vespa.applicationmodel.ServiceCluster in project vespa by vespa-engine.
the class ClusterApiImplTest method testNoServices.
@Test
public void testNoServices() {
HostName hostName1 = modelUtils.createNode("host1", HostStatus.NO_REMARKS);
HostName hostName2 = modelUtils.createNode("host2", HostStatus.NO_REMARKS);
HostName hostName3 = modelUtils.createNode("host3", HostStatus.ALLOWED_TO_BE_DOWN);
HostName hostName4 = modelUtils.createNode("host4", HostStatus.ALLOWED_TO_BE_DOWN);
HostName hostName5 = modelUtils.createNode("host5", HostStatus.NO_REMARKS);
ServiceCluster serviceCluster = modelUtils.createServiceCluster("cluster", new ServiceType("service-type"), Arrays.asList(modelUtils.createServiceInstance("service-1", hostName1, ServiceStatus.UP), modelUtils.createServiceInstance("service-2", hostName2, ServiceStatus.DOWN), modelUtils.createServiceInstance("service-3", hostName3, ServiceStatus.UP), modelUtils.createServiceInstance("service-4", hostName4, ServiceStatus.DOWN), modelUtils.createServiceInstance("service-5", hostName5, ServiceStatus.UP)));
verifyNoServices(serviceCluster, false, false, hostName1);
verifyNoServices(serviceCluster, true, false, hostName2);
verifyNoServices(serviceCluster, true, false, hostName3);
verifyNoServices(serviceCluster, true, false, hostName4);
verifyNoServices(serviceCluster, false, false, hostName5);
verifyNoServices(serviceCluster, false, false, hostName1, hostName2);
verifyNoServices(serviceCluster, true, false, hostName2, hostName3);
verifyNoServices(serviceCluster, true, true, hostName2, hostName3, hostName4);
verifyNoServices(serviceCluster, false, true, hostName1, hostName2, hostName3, hostName4);
}
use of com.yahoo.vespa.applicationmodel.ServiceCluster in project vespa by vespa-engine.
the class VespaModelUtilTest method verifyControllerClusterIsRecognized.
@Test
public void verifyControllerClusterIsRecognized() {
ServiceCluster cluster = createServiceCluster(VespaModelUtil.CLUSTER_CONTROLLER_SERVICE_TYPE);
assertTrue(VespaModelUtil.isClusterController(cluster));
}
Aggregations