diff options
author | gjoranv <gjoranv@gmail.com> | 2019-03-05 09:57:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-05 09:57:47 +0100 |
commit | 88ddf6bab8dc094e9099ffb41c4b4b568a716c1d (patch) | |
tree | cfbabcf73cedd7ed81a0673ec07b4aae75dec0e4 /configserver | |
parent | b7264e3244c183bb9c266d5d6ad243ab594b93fd (diff) | |
parent | e6954e24bde7517e9f0b0f6bee94b79648903db9 (diff) |
Merge pull request #8670 from vespa-engine/gjoranv/use-container-service-type_2
Gjoranv/use container service type 2
Diffstat (limited to 'configserver')
10 files changed, 34 insertions, 18 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index ea7b6a88a9c..a31e0bf2fa4 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -12,6 +12,7 @@ import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.model.api.ServiceInfo; +import com.yahoo.config.model.api.container.ContainerServiceType; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostFilter; @@ -74,6 +75,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER; import static java.nio.file.Files.readAttributes; /** @@ -335,7 +337,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye // TODO: It would be nice to have a simple check to verify pathSuffix doesn't contain /../ components. String relativePath = "clustercontroller-status/" + pathSuffix; - return httpProxy.get(getApplication(applicationId), hostName, "container-clustercontroller", relativePath); + return httpProxy.get(getApplication(applicationId), hostName, + CLUSTERCONTROLLER_CONTAINER.serviceName, relativePath); } public Long getApplicationGeneration(ApplicationId applicationId) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java index 771a279e0ab..877b2acb86f 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ConfigConvergenceChecker.java @@ -31,6 +31,9 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import static com.yahoo.config.model.api.container.ContainerServiceType.CONTAINER; +import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER; + /** * Checks for convergence of config generation for a given application. * @@ -44,8 +47,8 @@ public class ConfigConvergenceChecker extends AbstractComponent { private static final String statePath = "/state/v1/"; private static final String configSubPath = "config"; private final static Set<String> serviceTypesToCheck = new HashSet<>(Arrays.asList( - "container", - "qrserver", + CONTAINER.serviceName, + QRSERVER.serviceName, "searchnode", "storagenode", "distributor" diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/model/LbServicesProducer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/model/LbServicesProducer.java index 7835ab2cf03..ceeea197440 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/model/LbServicesProducer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/model/LbServicesProducer.java @@ -19,6 +19,9 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.yahoo.config.model.api.container.ContainerServiceType.CONTAINER; +import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER; + /** * Produces lb-services cfg * @@ -68,8 +71,8 @@ public class LbServicesProducer implements LbServicesConfig.Producer { boolean activeRotation = false; for (HostInfo hostInfo : app.getModel().getHosts()) { Optional<ServiceInfo> container = hostInfo.getServices().stream().filter( - serviceInfo -> serviceInfo.getServiceType().equals("container") || - serviceInfo.getServiceType().equals("qrserver")). + serviceInfo -> serviceInfo.getServiceType().equals(CONTAINER.serviceName) || + serviceInfo.getServiceType().equals(QRSERVER.serviceName)). findAny(); if (container.isPresent()) { activeRotation |= Boolean.valueOf(container.get().getProperty("activeRotation").orElse("false")); diff --git a/configserver/src/main/java/com/yahoo/vespa/serviceview/ServiceModel.java b/configserver/src/main/java/com/yahoo/vespa/serviceview/ServiceModel.java index 3c6a20ff58f..c9574ffaa7e 100644 --- a/configserver/src/main/java/com/yahoo/vespa/serviceview/ServiceModel.java +++ b/configserver/src/main/java/com/yahoo/vespa/serviceview/ServiceModel.java @@ -21,6 +21,8 @@ import com.yahoo.vespa.serviceview.bindings.ServiceView; import edu.umd.cs.findbugs.annotations.NonNull; +import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER; + /** * A transposed view for cloud.config.model. * @@ -28,8 +30,6 @@ import edu.umd.cs.findbugs.annotations.NonNull; */ public final class ServiceModel { - private static final String CLUSTERCONTROLLER_TYPENAME = "container-clustercontroller"; - private static final String CONTENT_CLUSTER_TYPENAME = "content"; private final Map<String, Service> servicesMap; @@ -169,7 +169,7 @@ public final class ServiceModel { private Service getFirstClusterController() { // This is used assuming all cluster controllers know of all fleet controllers in an application - return getFirstServiceInstanceByType(CLUSTERCONTROLLER_TYPENAME); + return getFirstServiceInstanceByType(CLUSTERCONTROLLER_CONTAINER.serviceName); } private StringBuilder getLinkBuilder(String uriBase) { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java index bfbf717bb1c..97496bd4177 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java @@ -34,6 +34,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; +import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -146,7 +147,7 @@ public class SuperModelControllerTest { assertThat(hosts.hostname(), is(host)); for (Map.Entry<String, Applications.Hosts.Services> e : app.hosts(host).services().entrySet()) { System.out.println(e.getKey()); - if ("qrserver".equals(e.getKey())) { + if (QRSERVER.serviceName.equals(e.getKey())) { Applications.Hosts.Services s = e.getValue(); System.out.println(s); assertThat(s.type(), is("qrserver")); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java index 88920895014..32fe6ab82b5 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java @@ -12,6 +12,7 @@ import org.mockito.ArgumentCaptor; import java.net.URL; +import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; @@ -39,8 +40,8 @@ public class HttpProxyTest { HttpResponse response = new StaticResponse(200, "application/json", "body"); when(fetcher.get(actualParams.capture(), actualUrl.capture())).thenReturn(response); - HttpResponse actualResponse = proxy.get( - applicationMock, hostname, "container-clustercontroller", "clustercontroller-status/v1/clusterName"); + HttpResponse actualResponse = proxy.get(applicationMock, hostname, CLUSTERCONTROLLER_CONTAINER.serviceName, + "clustercontroller-status/v1/clusterName"); assertEquals(1, actualParams.getAllValues().size()); assertEquals(2000, actualParams.getValue().readTimeoutMs); @@ -58,7 +59,7 @@ public class HttpProxyTest { public void testFetchException() { when(fetcher.get(any(), any())).thenThrow(new RequestTimeoutException("timed out")); - HttpResponse actualResponse = proxy.get( - applicationMock, hostname, "container-clustercontroller", "clustercontroller-status/v1/clusterName"); + HttpResponse actualResponse = proxy.get(applicationMock, hostname, CLUSTERCONTROLLER_CONTAINER.serviceName, + "clustercontroller-status/v1/clusterName"); } } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/MockModel.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/MockModel.java index dcc60de0a3a..433a63f4ad2 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/MockModel.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/MockModel.java @@ -23,6 +23,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER; + /** * Model with two services, one that does not have a state port * @@ -47,7 +49,7 @@ public class MockModel implements Model { ServiceInfo container = createServiceInfo( hostname, "foo", // name - "container-clustercontroller", // type + CLUSTERCONTROLLER_CONTAINER.serviceName, ClusterSpec.Type.container, statePort, "state http external query"); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java index 2c84e2d8ad4..d3dcbcc2252 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java @@ -40,6 +40,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; @@ -167,7 +168,7 @@ public class ApplicationHandlerTest { new ConfigserverConfig(new ConfigserverConfig.Builder()), new OrchestratorMock()); ApplicationHandler mockHandler = createApplicationHandler(applicationRepository); - when(mockHttpProxy.get(any(), eq(host), eq("container-clustercontroller"), eq("clustercontroller-status/v1/clusterName1"))) + when(mockHttpProxy.get(any(), eq(host), eq(CLUSTERCONTROLLER_CONTAINER.serviceName),eq("clustercontroller-status/v1/clusterName1"))) .thenReturn(new StaticResponse(200, "text/html", "<html>...</html>")); HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET)); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java index a7c4131d620..352245757ca 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Random; import java.util.Set; +import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; @@ -62,7 +63,7 @@ public class LbServicesProducerTest { public void testConfigAliases() throws IOException, SAXException { Map<TenantName, Set<ApplicationInfo>> testModel = createTestModel(new DeployState.Builder()); LbServicesConfig conf = getLbServicesConfig(Zone.defaultZone(), testModel); - final LbServicesConfig.Tenants.Applications.Hosts.Services services = conf.tenants("foo").applications("foo:prod:default:default").hosts("foo.foo.yahoo.com").services("qrserver"); + final LbServicesConfig.Tenants.Applications.Hosts.Services services = conf.tenants("foo").applications("foo:prod:default:default").hosts("foo.foo.yahoo.com").services(QRSERVER.serviceName); assertThat(services.servicealiases().size(), is(1)); assertThat(services.endpointaliases().size(), is(2)); @@ -106,7 +107,7 @@ public class LbServicesProducerTest { Map<TenantName, Set<ApplicationInfo>> testModel = createTestModel(new DeployState.Builder().rotations(rotations)); RegionName regionName = RegionName.from("us-east-1"); LbServicesConfig conf = getLbServicesConfig(new Zone(Environment.prod, regionName), testModel); - final LbServicesConfig.Tenants.Applications.Hosts.Services services = conf.tenants("foo").applications("foo:prod:" + regionName.value() + ":default").hosts("foo.foo.yahoo.com").services("qrserver"); + final LbServicesConfig.Tenants.Applications.Hosts.Services services = conf.tenants("foo").applications("foo:prod:" + regionName.value() + ":default").hosts("foo.foo.yahoo.com").services(QRSERVER.serviceName); assertThat(services.servicealiases().size(), is(1)); assertThat(services.endpointaliases().size(), is(4)); diff --git a/configserver/src/test/java/com/yahoo/vespa/serviceview/ServiceModelTest.java b/configserver/src/test/java/com/yahoo/vespa/serviceview/ServiceModelTest.java index c7b08c08387..93fe424710e 100644 --- a/configserver/src/test/java/com/yahoo/vespa/serviceview/ServiceModelTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/serviceview/ServiceModelTest.java @@ -14,6 +14,7 @@ import org.junit.Test; import java.util.Arrays; import java.util.Collections; +import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -54,7 +55,7 @@ public class ServiceModelTest { service1.clustername = "examplecluster"; service1.clustertype = "somethingservers"; service1.index = 2L; - service1.type = "container-clustercontroller"; + service1.type = CLUSTERCONTROLLER_CONTAINER.serviceName; service1.name = "clustercontroller"; service1.configid = "clustercontroller/lbl.0"; ServicePort port = new ServicePort(); |