use of com.yahoo.config.model.api.PortInfo in project vespa by vespa-engine.
the class AbstractService method getServiceInfo.
@Override
public ServiceInfo getServiceInfo() {
Set<PortInfo> portInfos = new LinkedHashSet<>();
for (int i = 0; i < portsMeta.getNumPorts(); i++) {
portInfos.add(new PortInfo(ports.get(i), new LinkedHashSet<>(portsMeta.getTagsAt(i))));
}
Map<String, String> properties = new LinkedHashMap<>();
for (Map.Entry<String, Object> prop : serviceProperties.entrySet()) {
properties.put(prop.getKey(), prop.getValue().toString());
}
return new ServiceInfo(getServiceName(), getServiceType(), portInfos, properties, getConfigId(), getHostName());
}
use of com.yahoo.config.model.api.PortInfo in project vespa by vespa-engine.
the class HttpProxy method get.
public HttpResponse get(Application application, String hostName, String serviceType, String relativePath) {
HostInfo host = application.getModel().getHosts().stream().filter(hostInfo -> hostInfo.getHostname().equals(hostName)).findFirst().orElseThrow(() -> new NotFoundException("Failed to find host " + hostName));
ServiceInfo service = host.getServices().stream().filter(serviceInfo -> serviceType.equals(serviceInfo.getServiceType())).findFirst().orElseThrow(() -> new NotFoundException("Failed to find any service of type " + serviceType + " on host " + hostName));
// "http" and "state" seems to uniquely identify an interesting HTTP port on each service
PortInfo port = service.getPorts().stream().filter(portInfo -> portInfo.getTags().stream().collect(Collectors.toSet()).containsAll(Stream.of("http", "state").collect(Collectors.toSet()))).findFirst().orElseThrow(() -> new NotFoundException("Failed to find HTTP state port"));
return internalGet(host.getHostname(), port.getPort(), relativePath);
}
use of com.yahoo.config.model.api.PortInfo in project vespa by vespa-engine.
the class MockModel method createServiceInfo.
private static ServiceInfo createServiceInfo(String hostname, String name, String type, ClusterSpec.Type clusterType, int port, String portTags) {
PortInfo portInfo = new PortInfo(port, Arrays.stream(portTags.split(" ")).collect(Collectors.toSet()));
Map<String, String> properties = new HashMap<>();
properties.put("clustername", "default");
properties.put("clustertype", clusterType.name());
return new ServiceInfo(name, type, Collections.singleton(portInfo), properties, "", hostname);
}
use of com.yahoo.config.model.api.PortInfo 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