Search in sources :

Example 1 with PortInfo

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());
}
Also used : PortInfo(com.yahoo.config.model.api.PortInfo) LinkedHashSet(java.util.LinkedHashSet) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with PortInfo

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);
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) PortInfo(com.yahoo.config.model.api.PortInfo) NotFoundException(com.yahoo.vespa.config.server.http.NotFoundException) HostInfo(com.yahoo.config.model.api.HostInfo)

Example 3 with PortInfo

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);
}
Also used : PortInfo(com.yahoo.config.model.api.PortInfo) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 4 with PortInfo

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

PortInfo (com.yahoo.config.model.api.PortInfo)4 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)4 HostInfo (com.yahoo.config.model.api.HostInfo)2 HashMap (java.util.HashMap)2 Spec (com.yahoo.jrt.Spec)1 NotFoundException (com.yahoo.vespa.config.server.http.NotFoundException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1