Search in sources :

Example 1 with ServiceInfo

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

the class InstanceValidatorTest method application_has_wrong_domain.

@Test
public void application_has_wrong_domain() {
    ServiceInfo serviceInfo = new ServiceInfo("serviceName", "type", Collections.emptyList(), Collections.singletonMap(SERVICE_PROPERTIES_DOMAIN_KEY, "not-domain"), "confId", "hostName");
    SuperModelProvider superModelProvider = mockSuperModelProvider(mockApplicationInfo(applicationId, 5, Collections.singletonList(serviceInfo)));
    InstanceValidator instanceValidator = new InstanceValidator(null, superModelProvider);
    assertFalse(instanceValidator.isSameIdentityAsInServicesXml(applicationId, domain, service));
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider) Test(org.junit.Test)

Example 2 with ServiceInfo

use of com.yahoo.config.model.api.ServiceInfo 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 3 with ServiceInfo

use of com.yahoo.config.model.api.ServiceInfo 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 4 with ServiceInfo

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

the class MockModel method createContainer.

static MockModel createContainer(String hostname, int statePort) {
    ServiceInfo container = createServiceInfo(hostname, "container", "container", ClusterSpec.Type.container, statePort, "state");
    ServiceInfo serviceNoStatePort = createServiceInfo(hostname, "logserver", "logserver", ClusterSpec.Type.admin, 1234, "logtp");
    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 5 with ServiceInfo

use of com.yahoo.config.model.api.ServiceInfo 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)

Aggregations

ServiceInfo (com.yahoo.config.model.api.ServiceInfo)16 HostInfo (com.yahoo.config.model.api.HostInfo)9 Test (org.junit.Test)7 HashMap (java.util.HashMap)5 PortInfo (com.yahoo.config.model.api.PortInfo)4 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)3 SuperModelProvider (com.yahoo.config.model.api.SuperModelProvider)3 ApplicationId (com.yahoo.config.provision.ApplicationId)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Model (com.yahoo.config.model.api.Model)2 SuperModel (com.yahoo.config.model.api.SuperModel)2 Zone (com.yahoo.config.provision.Zone)2 MockRestartAction (com.yahoo.vespa.config.server.configchange.MockRestartAction)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Assert.assertTrue (org.junit.Assert.assertTrue)2