Search in sources :

Example 6 with HostInfo

use of com.yahoo.config.model.api.HostInfo in project vespa by vespa-engine.

the class VespaModelTestCase method testNoAdmin.

@Test
public void testNoAdmin() {
    VespaModel model = CommonVespaModelSetup.createVespaModelWithMusic(simpleHosts, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<services version=\"1.0\">" + "</services>");
    Admin admin = model.getAdmin();
    assertThat(admin.getSlobroks().size(), is(1));
    assertThat(admin.getConfigservers().size(), is(1));
    Set<HostInfo> hosts = model.getHosts();
    assertThat(hosts.size(), is(1));
    // logd, config proxy, sentinel, config server, slobrok, log server
    HostInfo host = hosts.iterator().next();
    assertThat(host.getServices().size(), is(6));
    new LogdConfig((LogdConfig.Builder) model.getConfig(new LogdConfig.Builder(), "admin/model"));
}
Also used : LogdConfig(com.yahoo.cloud.config.log.LogdConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Admin(com.yahoo.vespa.model.admin.Admin) HostInfo(com.yahoo.config.model.api.HostInfo) Test(org.junit.Test)

Example 7 with HostInfo

use of com.yahoo.config.model.api.HostInfo in project vespa by vespa-engine.

the class MockModel method createClusterController.

static MockModel createClusterController(String hostname, int statePort) {
    ServiceInfo container = createServiceInfo(hostname, // name
    "foo", // type
    "container-clustercontroller", ClusterSpec.Type.container, statePort, "state http external query");
    ServiceInfo serviceNoStatePort = createServiceInfo(hostname, "storagenode", "storagenode", ClusterSpec.Type.content, 1234, "rpc");
    HostInfo hostInfo = new HostInfo(hostname, Arrays.asList(container, serviceNoStatePort));
    return new MockModel(Collections.singleton(hostInfo));
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HostInfo(com.yahoo.config.model.api.HostInfo)

Example 8 with HostInfo

use of com.yahoo.config.model.api.HostInfo in project vespa by vespa-engine.

the class MockModel method createConfigProxies.

static MockModel createConfigProxies(List<String> hostnames, int rpcPort) {
    Set<HostInfo> hostInfos = new HashSet<>();
    hostnames.forEach(hostname -> {
        ServiceInfo configProxy = createServiceInfo(hostname, "configproxy", "configproxy", ClusterSpec.Type.admin, rpcPort, "rpc");
        hostInfos.add(new HostInfo(hostname, Collections.singletonList(configProxy)));
    });
    return new MockModel(hostInfos);
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HostInfo(com.yahoo.config.model.api.HostInfo) HashSet(java.util.HashSet)

Example 9 with HostInfo

use of com.yahoo.config.model.api.HostInfo in project vespa by vespa-engine.

the class ModelGenerator method toApplicationInstance.

ApplicationInstance toApplicationInstance(ApplicationInfo applicationInfo, Zone zone, ServiceStatusProvider serviceStatusProvider) {
    Map<ServiceClusterKey, Set<ServiceInstance>> groupedServiceInstances = new HashMap<>();
    for (HostInfo host : applicationInfo.getModel().getHosts()) {
        HostName hostName = new HostName(host.getHostname());
        for (ServiceInfo serviceInfo : host.getServices()) {
            ServiceClusterKey serviceClusterKey = toServiceClusterKey(serviceInfo);
            ServiceInstance serviceInstance = toServiceInstance(applicationInfo.getApplicationId(), serviceClusterKey.clusterId(), serviceInfo, hostName, serviceStatusProvider);
            if (!groupedServiceInstances.containsKey(serviceClusterKey)) {
                groupedServiceInstances.put(serviceClusterKey, new HashSet<>());
            }
            groupedServiceInstances.get(serviceClusterKey).add(serviceInstance);
        }
    }
    Set<ServiceCluster> serviceClusters = groupedServiceInstances.entrySet().stream().map(entry -> new ServiceCluster(entry.getKey().clusterId(), entry.getKey().serviceType(), entry.getValue())).collect(Collectors.toSet());
    ApplicationInstance applicationInstance = new ApplicationInstance(new TenantId(applicationInfo.getApplicationId().tenant().toString()), toApplicationInstanceId(applicationInfo, zone), serviceClusters);
    // Fill back-references
    for (ServiceCluster serviceCluster : applicationInstance.serviceClusters()) {
        serviceCluster.setApplicationInstance(applicationInstance);
        for (ServiceInstance serviceInstance : serviceCluster.serviceInstances()) {
            serviceInstance.setServiceCluster(serviceCluster);
        }
    }
    return applicationInstance;
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId) HostInfo(com.yahoo.config.model.api.HostInfo) HashMap(java.util.HashMap) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) HashSet(java.util.HashSet) HostName(com.yahoo.vespa.applicationmodel.HostName) Map(java.util.Map) SuperModel(com.yahoo.config.model.api.SuperModel) ServiceStatusProvider(com.yahoo.vespa.service.monitor.ServiceStatusProvider) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) Set(java.util.Set) TenantId(com.yahoo.vespa.applicationmodel.TenantId) Collectors(java.util.stream.Collectors) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) ServiceClusterKey(com.yahoo.vespa.applicationmodel.ServiceClusterKey) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) List(java.util.List) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) Zone(com.yahoo.config.provision.Zone) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HashSet(java.util.HashSet) Set(java.util.Set) ServiceClusterKey(com.yahoo.vespa.applicationmodel.ServiceClusterKey) HashMap(java.util.HashMap) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) TenantId(com.yahoo.vespa.applicationmodel.TenantId) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) HostInfo(com.yahoo.config.model.api.HostInfo) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 10 with HostInfo

use of com.yahoo.config.model.api.HostInfo in project vespa by vespa-engine.

the class SlobrokMonitor method getSlobrokSpecs.

List<String> getSlobrokSpecs(ApplicationInfo applicationInfo) {
    List<String> slobrokSpecs = new ArrayList<>();
    for (HostInfo host : applicationInfo.getModel().getHosts()) {
        for (ServiceInfo service : host.getServices()) {
            if (!Objects.equals(service.getServiceType(), SLOBROK_SERVICE_TYPE)) {
                continue;
            }
            for (PortInfo port : service.getPorts()) {
                if (port.getTags().contains(SLOBROK_RPC_PORT_TAG)) {
                    Spec spec = new Spec(host.getHostname(), port.getPort());
                    slobrokSpecs.add(spec.toString());
                }
            }
        }
    }
    return slobrokSpecs;
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) PortInfo(com.yahoo.config.model.api.PortInfo) ArrayList(java.util.ArrayList) Spec(com.yahoo.jrt.Spec) HostInfo(com.yahoo.config.model.api.HostInfo)

Aggregations

HostInfo (com.yahoo.config.model.api.HostInfo)10 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)9 Test (org.junit.Test)4 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)3 ApplicationId (com.yahoo.config.provision.ApplicationId)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Model (com.yahoo.config.model.api.Model)2 PortInfo (com.yahoo.config.model.api.PortInfo)2 SuperModel (com.yahoo.config.model.api.SuperModel)2 Zone (com.yahoo.config.provision.Zone)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 LogdConfig (com.yahoo.cloud.config.log.LogdConfig)1