Search in sources :

Example 11 with ServiceCluster

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;
}
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 12 with ServiceCluster

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());
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance)

Example 13 with ServiceCluster

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

Example 14 with ServiceCluster

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);
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Example 15 with ServiceCluster

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));
}
Also used : ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) Test(org.junit.Test)

Aggregations

ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)16 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)11 Test (org.junit.Test)11 HostName (com.yahoo.vespa.applicationmodel.HostName)8 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)7 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)5 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)5 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)5 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)5 TenantId (com.yahoo.vespa.applicationmodel.TenantId)5 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)4 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)1