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