diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2022-03-31 11:52:40 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2022-03-31 11:53:33 +0200 |
commit | 2430b74a942659d549771cb4dd8b81d77692d905 (patch) | |
tree | c79b8b48bf150bea00ab9e0c6ad594740709d4fa | |
parent | 168f767ec12253f43ace27946dc530fde9e37d5e (diff) |
Rename back to HostName, and merge the value class and utilities
52 files changed, 192 insertions, 196 deletions
diff --git a/athenz-identity-provider-service/src/main/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/IdentityDocumentGenerator.java b/athenz-identity-provider-service/src/main/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/IdentityDocumentGenerator.java index 83b9bbb37da..ba357e44e09 100644 --- a/athenz-identity-provider-service/src/main/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/IdentityDocumentGenerator.java +++ b/athenz-identity-provider-service/src/main/java/com/yahoo/vespa/hosted/athenz/instanceproviderservice/IdentityDocumentGenerator.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.athenz.instanceproviderservice; import com.google.inject.Inject; import com.yahoo.config.provision.Zone; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.athenz.api.AthenzService; import com.yahoo.vespa.athenz.identityprovider.api.IdentityType; import com.yahoo.vespa.athenz.identityprovider.api.SignedIdentityDocument; @@ -63,7 +63,7 @@ public class IdentityDocumentGenerator { PrivateKey privateKey = keyProvider.getPrivateKey(athenzProviderServiceConfig.secretVersion()); AthenzService providerService = new AthenzService(athenzProviderServiceConfig.domain(), athenzProviderServiceConfig.serviceName()); - String configServerHostname = Hostnames.getLocalhost(); + String configServerHostname = HostName.getLocalhost(); Instant createdAt = Instant.now(); String signature = signer.generateSignature( providerUniqueId, providerService, configServerHostname, diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java index 26ac426f935..4bd9b2fc9b8 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java @@ -16,7 +16,7 @@ import com.yahoo.jrt.slobrok.api.BackOffPolicy; import com.yahoo.jrt.slobrok.api.Register; import com.yahoo.jrt.slobrok.api.SlobrokList; import java.util.logging.Level; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vdslib.state.ClusterState; import com.yahoo.vdslib.state.Node; import com.yahoo.vdslib.state.NodeState; @@ -111,7 +111,7 @@ public class RpcServer { slobroks.append(" )"); SlobrokList slist = new SlobrokList(); slist.setup(slobrokConnectionSpecs); - Spec spec = new Spec(Hostnames.getLocalhost(), acceptor.port()); + Spec spec = new Spec(HostName.getLocalhost(), acceptor.port()); log.log(Level.INFO, "Registering " + spec + " with slobrok at " + slobroks); if (slobrokBackOffPolicy != null) { register = new Register(supervisor, slist, spec, slobrokBackOffPolicy); diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperTestServer.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperTestServer.java index b35ff6ebfd0..baaad164f8f 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperTestServer.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperTestServer.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.clustercontroller.core; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import org.apache.zookeeper.server.NIOServerCnxnFactory; import org.apache.zookeeper.server.ZooKeeperServer; @@ -52,7 +52,7 @@ public class ZooKeeperTestServer { } String getAddress() { - return Hostnames.getLocalhost() + ":" + getPort(); + return HostName.getLocalhost() + ":" + getPort(); } public void shutdown(boolean cleanupZooKeeperDir) { diff --git a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingMaintainer.java b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingMaintainer.java index 27d211e4bc5..afb491fa293 100644 --- a/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingMaintainer.java +++ b/clustercontroller-reindexer/src/main/java/ai/vespa/reindexing/ReindexingMaintainer.java @@ -12,7 +12,7 @@ import com.yahoo.concurrent.DaemonThreadFactory; import com.yahoo.document.DocumentTypeManager; import com.yahoo.documentapi.DocumentAccess; import com.yahoo.jdisc.Metric; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.config.content.AllClustersBucketSpacesConfig; import com.yahoo.vespa.config.content.reindexing.ReindexingConfig; import com.yahoo.vespa.curator.Curator; @@ -75,7 +75,7 @@ public class ReindexingMaintainer extends AbstractComponent { this.executor = new ScheduledThreadPoolExecutor(reindexingConfig.clusters().size(), new DaemonThreadFactory("reindexer-")); if (reindexingConfig.enabled()) scheduleStaggered((delayMillis, intervalMillis) -> executor.scheduleAtFixedRate(this::maintain, delayMillis, intervalMillis, TimeUnit.MILLISECONDS), - Duration.ofMinutes(1), clock.instant(), Hostnames.getLocalhost(), zookeepersConfig.zookeeperserverlist()); + Duration.ofMinutes(1), clock.instant(), HostName.getLocalhost(), zookeepersConfig.zookeeperserverlist()); } private void maintain() { diff --git a/config-model/src/main/java/com/yahoo/config/model/provision/Hosts.java b/config-model/src/main/java/com/yahoo/config/model/provision/Hosts.java index af1e94e14f2..c9a03dad65e 100644 --- a/config-model/src/main/java/com/yahoo/config/model/provision/Hosts.java +++ b/config-model/src/main/java/com/yahoo/config/model/provision/Hosts.java @@ -3,7 +3,7 @@ package com.yahoo.config.model.provision; import com.google.common.collect.ImmutableMap; import com.yahoo.config.model.builder.xml.XmlHelper; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.text.XML; import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder; import org.w3c.dom.Document; @@ -75,7 +75,7 @@ public class Hosts { throw new IllegalArgumentException("Missing 'name' attribute for host."); } if ("localhost".equals(name)) { - name = Hostnames.getLocalhost(); + name = HostName.getLocalhost(); } List<String> hostAliases = VespaDomBuilder.getHostAliases(hostE.getChildNodes()); if (hostAliases.isEmpty()) { diff --git a/config-model/src/main/java/com/yahoo/config/model/provision/SingleNodeProvisioner.java b/config-model/src/main/java/com/yahoo/config/model/provision/SingleNodeProvisioner.java index d3a6ad9897f..c3b91c5da0f 100644 --- a/config-model/src/main/java/com/yahoo/config/model/provision/SingleNodeProvisioner.java +++ b/config-model/src/main/java/com/yahoo/config/model/provision/SingleNodeProvisioner.java @@ -9,7 +9,7 @@ import com.yahoo.config.provision.Flavor; import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.NodeResources; import com.yahoo.config.provision.ProvisionLogger; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import java.util.ArrayList; import java.util.List; @@ -29,12 +29,12 @@ public class SingleNodeProvisioner implements HostProvisioner { private int counter = 0; public SingleNodeProvisioner() { - host = new Host(Hostnames.getLocalhost()); + host = new Host(HostName.getLocalhost()); this.hostSpec = new HostSpec(host.hostname(), host.aliases(), Optional.empty()); } public SingleNodeProvisioner(Flavor flavor) { - host = new Host(Hostnames.getLocalhost()); + host = new Host(HostName.getLocalhost()); this.hostSpec = new HostSpec(host.hostname(), flavor.resources(), flavor.resources(), flavor.resources(), ClusterMembership.from(ClusterSpec.specification(ClusterSpec.Type.content, ClusterSpec.Id.from("test")).group(ClusterSpec.Group.from(0)).vespaVersion("1").build(), 0), diff --git a/config-model/src/main/java/com/yahoo/vespa/model/HostSystem.java b/config-model/src/main/java/com/yahoo/vespa/model/HostSystem.java index 640210717b9..6e63a1d9e68 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/HostSystem.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/HostSystem.java @@ -9,7 +9,7 @@ import com.yahoo.config.provision.ClusterMembership; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.ProvisionLogger; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import java.net.UnknownHostException; import java.util.LinkedHashMap; @@ -78,7 +78,7 @@ public class HostSystem extends AbstractConfigProducer<Host> { HostResource hostResource = hostname2host.get(name); if (hostResource == null) { // Create a new HostResource if this is the host this code is running on (as it is when running tests) - if (Hostnames.getLocalhost().equals(name)) { + if (HostName.getLocalhost().equals(name)) { if (! getChildren().containsKey(localhost)) { new Host(this, localhost); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/configserver/ConfigserverCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/configserver/ConfigserverCluster.java index 6ad18e195a8..413c6f07efd 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/configserver/ConfigserverCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/configserver/ConfigserverCluster.java @@ -12,7 +12,7 @@ import com.yahoo.config.provision.Zone; import com.yahoo.container.StatisticsConfig; import com.yahoo.container.core.VipStatusConfig; import com.yahoo.container.jdisc.config.HealthMonitorConfig; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.defaults.Defaults; import com.yahoo.vespa.model.container.ContainerCluster; import com.yahoo.vespa.model.container.configserver.option.CloudConfigOptions; @@ -66,7 +66,7 @@ public class ConfigserverCluster extends AbstractConfigProducer configServers.length, zookeeperIds.length)); } - String myhostname = Hostnames.getLocalhost(); + String myhostname = HostName.getLocalhost(); // TODO: Server index should be in interval [1, 254] according to doc, // however, we cannot change this id for an existing server for (int i = 0; i < configServers.length; i++) { @@ -120,7 +120,7 @@ public class ConfigserverCluster extends AbstractConfigProducer builder.environment(options.system().get()); } - builder.serverId(Hostnames.getLocalhost()); + builder.serverId(HostName.getLocalhost()); if (!containerCluster.getHttp().getHttpServer().get().getConnectorFactories().isEmpty()) { builder.httpport(containerCluster.getHttp().getHttpServer().get().getConnectorFactories().get(0).getListenPort()); } @@ -150,7 +150,7 @@ public class ConfigserverCluster extends AbstractConfigProducer private ConfigServer[] getConfigServers() { return Optional.of(options.allConfigServers()) .filter(configServers -> configServers.length > 0) - .orElseGet(() -> new ConfigServer[]{new ConfigServer(Hostnames.getLocalhost(), Optional.empty())}); + .orElseGet(() -> new ConfigServer[]{new ConfigServer(HostName.getLocalhost(), Optional.empty())}); } private int[] getConfigServerZookeeperIds() { diff --git a/config-model/src/test/java/com/yahoo/config/model/deploy/SystemModelTestCase.java b/config-model/src/test/java/com/yahoo/config/model/deploy/SystemModelTestCase.java index 9fea2cee88c..66cbfbd537f 100644 --- a/config-model/src/test/java/com/yahoo/config/model/deploy/SystemModelTestCase.java +++ b/config-model/src/test/java/com/yahoo/config/model/deploy/SystemModelTestCase.java @@ -7,7 +7,7 @@ import com.yahoo.config.model.ConfigModel; import com.yahoo.config.model.ConfigModelRegistry; import com.yahoo.config.model.MapConfigModelRegistry; import com.yahoo.config.model.ApplicationConfigProducerRoot; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.model.ConfigProducer; import com.yahoo.vespa.model.HostResource; import com.yahoo.vespa.model.HostSystem; @@ -83,7 +83,7 @@ public class SystemModelTestCase { // Verify configIds from vespaModel assertTrue(12 <= vespaModel.getConfigIds().size()); - String localhost = Hostnames.getLocalhost(); + String localhost = HostName.getLocalhost(); String localhostConfigId = "hosts/" + localhost; Set<String> configIds = vespaModel.getConfigIds(); assertTrue(configIds.contains("client")); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java index e2c316a57c5..96f6c7999cc 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java @@ -16,7 +16,7 @@ import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.Zone; import com.yahoo.container.StatisticsConfig; import com.yahoo.container.jdisc.config.HealthMonitorConfig; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.config.core.StateserverConfig; import com.yahoo.vespa.model.Service; import com.yahoo.vespa.model.VespaModel; @@ -60,7 +60,7 @@ public class AdminTestCase { // Verify configIds Set<String> configIds = vespaModel.getConfigIds(); - String localhost = Hostnames.getLocalhost(); + String localhost = HostName.getLocalhost(); String localhostConfigId = "hosts/" + localhost; assertTrue(configIds.contains(localhostConfigId)); assertTrue(configIds.contains("admin/logserver")); @@ -124,7 +124,7 @@ public class AdminTestCase { // Verify configIds Set<String> configIds = vespaModel.getConfigIds(); - String localhost = Hostnames.getLocalhost(); + String localhost = HostName.getLocalhost(); String localhostConfigId = "hosts/" + localhost; assertTrue(configIds.contains(localhostConfigId)); assertTrue(configIds.contains("admin/logserver")); @@ -164,7 +164,7 @@ public class AdminTestCase { .build())) .build(); TestRoot root = new TestDriver().buildModel(state); - String localhost = Hostnames.getLocalhost(); + String localhost = HostName.getLocalhost(); SentinelConfig config = root.getConfig(SentinelConfig.class, "hosts/" + localhost); assertEquals("quux", config.application().tenant()); assertEquals("foo", config.application().name()); @@ -187,7 +187,7 @@ public class AdminTestCase { // Verify configIds Set<String> configIds = vespaModel.getConfigIds(); - String localhost = Hostnames.getLocalhost(); + String localhost = HostName.getLocalhost(); String localhostConfigId = "hosts/" + localhost; assertTrue(configIds.contains(localhostConfigId)); assertTrue(configIds.contains("admin/logserver")); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/HostProvisionerWithCustomRealResource.java b/config-model/src/test/java/com/yahoo/vespa/model/container/HostProvisionerWithCustomRealResource.java index e87388a0413..e8f30d59aa9 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/HostProvisionerWithCustomRealResource.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/HostProvisionerWithCustomRealResource.java @@ -9,7 +9,7 @@ import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.NodeResources; import com.yahoo.config.provision.ProvisionLogger; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import java.util.List; import java.util.Optional; @@ -26,7 +26,7 @@ public class HostProvisionerWithCustomRealResource implements HostProvisioner { @Override public HostSpec allocateHost(String alias) { - Host host = new Host(Hostnames.getLocalhost()); + Host host = new Host(HostName.getLocalhost()); ClusterMembership membership = ClusterMembership.from( ClusterSpec .specification( diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java index ecfade44f76..29cff23d3bd 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java @@ -11,7 +11,7 @@ import com.yahoo.config.model.test.MockRoot; import com.yahoo.container.StatisticsConfig; import com.yahoo.container.di.config.PlatformBundlesConfig; import com.yahoo.container.jdisc.config.HealthMonitorConfig; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.text.XML; import com.yahoo.vespa.defaults.Defaults; import com.yahoo.vespa.model.HostResource; @@ -108,7 +108,7 @@ public class ConfigserverClusterTest { assertEquals(Defaults.getDefaults().underVespaHome("lib/jars/config-models"), config.configModelPluginDir().get(0)); assertEquals(12345, config.rpcport()); assertEquals(1337, config.httpport()); - assertEquals(Hostnames.getLocalhost(), config.serverId()); + assertEquals(HostName.getLocalhost(), config.serverId()); assertTrue(config.useVespaVersionInRequest()); assertEquals(4, config.numParallelTenantLoaders()); assertFalse(config.multitenant()); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java index 04f1b418219..16b4a8bed9b 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java @@ -36,7 +36,7 @@ import com.yahoo.container.jdisc.JdiscBindingsConfig; import com.yahoo.container.jdisc.secretstore.SecretStoreConfig; import com.yahoo.container.usability.BindingsOverviewHandler; import com.yahoo.jdisc.http.ConnectorConfig; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.path.Path; import com.yahoo.prelude.cluster.QrMonitorConfig; import com.yahoo.search.config.QrStartConfig; @@ -645,7 +645,7 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase { @Test public void qrconfig_is_produced() throws IOException, SAXException { QrConfig qr = getQrConfig(new TestProperties()); - String hostname = Hostnames.getLocalhost(); // Using the same way of getting hostname as filedistribution model + String hostname = HostName.getLocalhost(); // Using the same way of getting hostname as filedistribution model assertEquals("default.container.0", qr.discriminator()); assertEquals(19102, qr.rpc().port()); assertEquals("vespa/service/default/container.0", qr.rpc().slobrokId()); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java index b8fbe960dc9..7f8bca825d2 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java @@ -22,7 +22,7 @@ import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.ApplicationId; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.messagebus.MessagebusConfig; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.config.UnknownConfigIdException; import com.yahoo.vespa.model.ConfigProducer; import com.yahoo.vespa.model.VespaModel; @@ -87,7 +87,7 @@ public class VespaModelTestCase { LogdConfig.Builder b = new LogdConfig.Builder(); b = (LogdConfig.Builder) model.getConfig(b, ""); LogdConfig c = new LogdConfig(b); - assertEquals(Hostnames.getLocalhost(), c.logserver().host()); + assertEquals(HostName.getLocalhost(), c.logserver().host()); SlobroksConfig.Builder sb = new SlobroksConfig.Builder(); sb = (com.yahoo.cloud.config.SlobroksConfig.Builder) model.getConfig(sb, ""); @@ -98,7 +98,7 @@ public class VespaModelTestCase { zb = (ZookeepersConfig.Builder) model.getConfig(zb, ""); ZookeepersConfig zc = new ZookeepersConfig(zb); assertEquals(zc.zookeeperserverlist().split(",").length, 2); - assertTrue(zc.zookeeperserverlist().startsWith(Hostnames.getLocalhost())); + assertTrue(zc.zookeeperserverlist().startsWith(HostName.getLocalhost())); ApplicationIdConfig.Builder appIdBuilder = new ApplicationIdConfig.Builder(); appIdBuilder = (ApplicationIdConfig.Builder) model.getConfig(appIdBuilder, ""); @@ -112,11 +112,11 @@ public class VespaModelTestCase { public void testHostsConfig() { VespaModel model = getVespaModel(TESTDIR + "app_qrserverandgw"); LogdConfig config = getLogdConfig(model, ""); - assertEquals(config.logserver().host(), Hostnames.getLocalhost()); + assertEquals(config.logserver().host(), HostName.getLocalhost()); assertNotNull(config); config = getLogdConfig(model, "hosts"); assertNotNull(config); - assertEquals(config.logserver().host(), Hostnames.getLocalhost()); + assertEquals(config.logserver().host(), HostName.getLocalhost()); } private static LogdConfig getLogdConfig(VespaModel model, String configId) { @@ -143,7 +143,7 @@ public class VespaModelTestCase { LogdConfig config = getLogdConfig(model, ""); assertNotNull(config); assertEquals(config.logserver().host(), "foo"); - config = getLogdConfig(model, "hosts/" + Hostnames.getLocalhost() + "/logd"); + config = getLogdConfig(model, "hosts/" + HostName.getLocalhost() + "/logd"); assertNotNull(config); assertEquals(config.logserver().host(), "foo"); } diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java index 4e7390163a4..d748ebb46e5 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java @@ -9,7 +9,7 @@ import com.yahoo.jrt.Request; import com.yahoo.jrt.StringArray; import com.yahoo.jrt.StringValue; import com.yahoo.jrt.Supervisor; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.filedistribution.FileDownloader; import com.yahoo.vespa.filedistribution.FileReferenceDownload; @@ -103,7 +103,7 @@ class FileDistributionRpcServer { private void downloadFile(Request req) { FileReference fileReference = new FileReference(req.parameters().get(0).asString()); log.log(Level.FINE, () -> "getFile() called for file reference '" + fileReference.value() + "'"); - Optional<File> file = downloader.getFile(new FileReferenceDownload(fileReference, Hostnames.getLocalhost())); + Optional<File> file = downloader.getFile(new FileReferenceDownload(fileReference, HostName.getLocalhost())); if (file.isPresent()) { new RequestTracker().trackRequest(file.get().getParentFile()); req.returnValues().add(new StringValue(file.get().getAbsolutePath())); diff --git a/config/src/main/java/com/yahoo/vespa/config/util/ConfigUtils.java b/config/src/main/java/com/yahoo/vespa/config/util/ConfigUtils.java index eca87bd29b0..ea92738cc26 100644 --- a/config/src/main/java/com/yahoo/vespa/config/util/ConfigUtils.java +++ b/config/src/main/java/com/yahoo/vespa/config/util/ConfigUtils.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.config.util; import com.yahoo.collections.Tuple2; import com.yahoo.io.HexDump; import com.yahoo.io.IOUtils; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.slime.JsonFormat; import com.yahoo.text.AbstractUtf8Array; import com.yahoo.text.Utf8; @@ -351,7 +351,7 @@ public class ConfigUtils { } public static String getCanonicalHostName() { - return Hostnames.getLocalhost(); + return HostName.getLocalhost(); } /** diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBRegistry.java index 7040cd5e8a3..3eeaa6598d3 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBRegistry.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBRegistry.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.config.server.filedistribution; import com.google.common.collect.ImmutableMap; import com.yahoo.config.FileReference; import com.yahoo.config.application.api.FileRegistry; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.text.Utf8; import net.jpountz.xxhash.XXHashFactory; @@ -130,7 +130,7 @@ public class FileDBRegistry implements FileRegistry { List<Entry> entries = registry.export(); StringBuilder builder = new StringBuilder(); - builder.append(Hostnames.getLocalhost()).append('\n'); + builder.append(HostName.getLocalhost()).append('\n'); for (FileRegistry.Entry entry : entries) { builder.append(entry.relativePath).append(entryDelimiter).append(entry.reference.value()).append('\n'); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionUtil.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionUtil.java index cbaa87c36ac..a1ddad7bfd4 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionUtil.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionUtil.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.config.server.filedistribution; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.FileReference; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.config.server.ConfigServerSpec; import java.io.File; @@ -35,7 +35,7 @@ public class FileDistributionUtil { public static List<String> getOtherConfigServersInCluster(ConfigserverConfig configserverConfig) { return ConfigServerSpec.fromConfig(configserverConfig) .stream() - .filter(spec -> !spec.getHostName().equals(Hostnames.getLocalhost())) + .filter(spec -> !spec.getHostName().equals(HostName.getLocalhost())) .map(spec -> "tcp/" + spec.getHostName() + ":" + spec.getConfigServerPort()) .collect(Collectors.toList()); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java index f63035cdd6e..55645d83b3c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java @@ -7,7 +7,7 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.TenantName; import com.yahoo.vespa.config.PayloadChecksums; import com.yahoo.jrt.Request; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.config.ConfigPayload; import com.yahoo.vespa.config.ErrorCode; import com.yahoo.vespa.config.UnknownConfigIdException; @@ -32,7 +32,7 @@ import static com.yahoo.vespa.config.protocol.SlimeConfigResponse.fromConfigPayl class GetConfigProcessor implements Runnable { private static final Logger log = Logger.getLogger(GetConfigProcessor.class.getName()); - private static final String localHostName = Hostnames.getLocalhost(); + private static final String localHostName = HostName.getLocalhost(); private final JRTServerConfigRequest request; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java index 18dbdaccfe7..8293871335d 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java @@ -24,7 +24,7 @@ import com.yahoo.config.provision.DockerImage; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.secretstore.SecretStore; import com.yahoo.lang.SettableOptional; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.path.Path; import com.yahoo.vespa.config.server.TimeoutBudget; import com.yahoo.vespa.config.server.application.ApplicationSet; @@ -236,7 +236,7 @@ public class SessionPreparer { applicationId + " (" + fileReference + ")"); properties.configServerSpecs() .stream() - .filter(spec -> !spec.getHostName().equals(Hostnames.getLocalhost())) + .filter(spec -> !spec.getHostName().equals(HostName.getLocalhost())) .forEach(spec -> fileDistribution.startDownload(spec.getHostName(), spec.getConfigServerPort(), Set.of(fileReference))); checkTimeout("startDistributionOfApplicationPackage"); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java index 2b6307f85b0..67c40f94b6a 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java @@ -6,7 +6,7 @@ import com.yahoo.config.FileReference; import com.yahoo.io.IOUtils; import com.yahoo.jrt.Supervisor; import com.yahoo.jrt.Transport; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.filedistribution.FileDownloader; import com.yahoo.vespa.filedistribution.FileReferenceData; import com.yahoo.vespa.filedistribution.FileReferenceDownload; @@ -91,7 +91,7 @@ public class FileServerTest { // Empty connection pool when only one server, no use in downloading from yourself List<ConfigserverConfig.Zookeeperserver.Builder> servers = new ArrayList<>(); ConfigserverConfig.Zookeeperserver.Builder serverBuilder = new ConfigserverConfig.Zookeeperserver.Builder(); - serverBuilder.hostname(Hostnames.getLocalhost()); + serverBuilder.hostname(HostName.getLocalhost()); serverBuilder.port(123456); servers.add(serverBuilder); builder.zookeeperserver(servers); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java index 198c646f6a7..40ed20b7969 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java @@ -10,7 +10,7 @@ import com.yahoo.jrt.Request; import com.yahoo.jrt.Spec; import com.yahoo.jrt.Supervisor; import com.yahoo.jrt.Transport; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.test.ManualClock; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.MemoryGenerationCounter; @@ -50,7 +50,7 @@ import static org.junit.Assert.assertTrue; public class RpcTester implements AutoCloseable { private final ManualClock clock = new ManualClock(Instant.ofEpochMilli(100)); - private final String myHostname = Hostnames.getLocalhost(); + private final String myHostname = HostName.getLocalhost(); private final HostLivenessTracker hostLivenessTracker = new ConfigRequestHostLivenessTracker(clock); private final Spec spec; diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java b/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java index 98a3e72ab90..2c25f38437a 100644 --- a/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java +++ b/container-disc/src/main/java/com/yahoo/container/jdisc/ConfiguredApplication.java @@ -44,7 +44,7 @@ import com.yahoo.jrt.slobrok.api.Register; import com.yahoo.jrt.slobrok.api.SlobrokList; import com.yahoo.log.LogSetup; import com.yahoo.messagebus.network.rpc.SlobrokConfigSubscriber; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.yolean.Exceptions; import com.yahoo.yolean.UncheckedInterruptedException; @@ -195,7 +195,7 @@ public final class ConfiguredApplication implements Application { private Register registerInSlobrok(QrConfig qrConfig) { SlobrokList slobrokList = getSlobrokList(); - Spec mySpec = new Spec(Hostnames.getLocalhost(), acceptor.port()); + Spec mySpec = new Spec(HostName.getLocalhost(), acceptor.port()); Register slobrokRegistrator = new Register(supervisor, slobrokList, mySpec); slobrokRegistrator.registerName(qrConfig.rpc().slobrokId()); log.log(Level.INFO, "Registered name '" + qrConfig.rpc().slobrokId() + diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java index f64a1be3251..f8c4627473d 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java @@ -4,7 +4,7 @@ package com.yahoo.search.dispatch.searchcluster; import com.google.common.collect.ImmutableMap; import com.google.common.math.Quantiles; import com.yahoo.container.handler.VipStatus; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.prelude.Pong; import com.yahoo.search.cluster.ClusterMonitor; import com.yahoo.search.cluster.NodeManager; @@ -70,7 +70,7 @@ public class SearchCluster implements NodeManager<Node> { this.orderedGroups = List.copyOf(groupIntroductionOrder.values()); hitEstimator = new TopKEstimator(30.0, dispatchConfig.topKProbability(), SKEW_FACTOR); - this.localCorpusDispatchTarget = findLocalCorpusDispatchTarget(Hostnames.getLocalhost(), nodes, groups); + this.localCorpusDispatchTarget = findLocalCorpusDispatchTarget(HostName.getLocalhost(), nodes, groups); } @Override diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java index fdbcfdab56a..af6374ba245 100644 --- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java +++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java @@ -26,7 +26,7 @@ import com.yahoo.jdisc.Request; import com.yahoo.language.Linguistics; import com.yahoo.language.process.Embedder; import com.yahoo.language.provider.DefaultEmbedderProvider; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.net.UriTools; import com.yahoo.prelude.query.parser.ParseException; import com.yahoo.processing.IllegalInputException; @@ -105,7 +105,7 @@ public class SearchHandler extends LoggingRequestHandler { /** If present, responses from this will set the HTTP response header with this key to the host name of this */ private final Optional<String> hostResponseHeaderKey; - private final String selfHostname = Hostnames.getLocalhost(); + private final String selfHostname = HostName.getLocalhost(); private final Map<String, Embedder> embedders; private final ExecutionFactory executionFactory; private final AtomicLong numRequestsLeftToTrace; diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java index 4dc85a4f3db..94df796b370 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java @@ -4,7 +4,7 @@ package com.yahoo.search.dispatch.searchcluster; import com.yahoo.container.QrSearchersConfig; import com.yahoo.container.handler.ClustersStatus; import com.yahoo.container.handler.VipStatus; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.prelude.Pong; import com.yahoo.search.cluster.ClusterMonitor; import com.yahoo.search.dispatch.MockSearchCluster; @@ -181,7 +181,7 @@ public class SearchClusterTest { @Test public void requireThatVipStatusIsDefaultDownWithLocalDispatch() { - try (State test = new State("cluster.1", 1, Hostnames.getLocalhost(), "b")) { + try (State test = new State("cluster.1", 1, HostName.getLocalhost(), "b")) { assertTrue(test.searchCluster.localCorpusDispatchTarget().isPresent()); assertFalse(test.vipStatus.isInRotation()); @@ -192,7 +192,7 @@ public class SearchClusterTest { @Test public void requireThatVipStatusStaysUpWithLocalDispatchAndClusterSize1() { - try (State test = new State("cluster.1", 1, Hostnames.getLocalhost())) { + try (State test = new State("cluster.1", 1, HostName.getLocalhost())) { assertTrue(test.searchCluster.localCorpusDispatchTarget().isPresent()); assertFalse(test.vipStatus.isInRotation()); @@ -206,7 +206,7 @@ public class SearchClusterTest { @Test public void requireThatVipStatusIsDefaultDownWithLocalDispatchAndClusterSize2() { - try (State test = new State("cluster.1", 1, Hostnames.getLocalhost(), "otherhost")) { + try (State test = new State("cluster.1", 1, HostName.getLocalhost(), "otherhost")) { assertTrue(test.searchCluster.localCorpusDispatchTarget().isPresent()); assertFalse(test.vipStatus.isInRotation()); @@ -220,7 +220,7 @@ public class SearchClusterTest { @Test public void requireThatVipStatusDownWhenLocalIsDown() { - try (State test = new State("cluster.1", 1, Hostnames.getLocalhost(), "b")) { + try (State test = new State("cluster.1", 1, HostName.getLocalhost(), "b")) { test.waitOneFullPingRound(); assertTrue(test.vipStatus.isInRotation()); diff --git a/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java b/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java index c71c6abd511..b1354106f19 100644 --- a/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java +++ b/container-search/src/test/java/com/yahoo/search/handler/SearchHandlerTest.java @@ -11,7 +11,7 @@ import com.yahoo.io.IOUtils; import com.yahoo.jdisc.Request; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.test.MockMetric; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; @@ -52,7 +52,7 @@ public class SearchHandlerTest { private static final String testDir = "src/test/java/com/yahoo/search/handler/test/config"; private static final String myHostnameHeader = "my-hostname-header"; - private static final String selfHostname = Hostnames.getLocalhost(); + private static final String selfHostname = HostName.getLocalhost(); private static String tempDir = ""; diff --git a/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java b/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java index 02102251e59..7811336823d 100644 --- a/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/handler/test/JSONSearchHandlerTestCase.java @@ -11,7 +11,7 @@ import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.RequestHandlerTestDriver; import com.yahoo.container.protect.Error; import com.yahoo.io.IOUtils; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.search.handler.SearchHandler; import com.yahoo.search.searchchain.config.test.SearchChainConfigurerTestCase; import com.yahoo.slime.Inspector; @@ -48,7 +48,7 @@ public class JSONSearchHandlerTestCase { private static final String testDir = "src/test/java/com/yahoo/search/handler/test/config"; private static final String myHostnameHeader = "my-hostname-header"; - private static final String selfHostname = Hostnames.getLocalhost(); + private static final String selfHostname = HostName.getLocalhost(); private static String tempDir = ""; private static String configId = null; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java index 8d3b0505603..6afeab9b4e6 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java @@ -7,12 +7,11 @@ import com.yahoo.component.Version; import com.yahoo.component.Vtag; import com.yahoo.concurrent.maintenance.JobControl; import com.yahoo.config.provision.CloudName; -import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.zone.ZoneApi; import com.yahoo.container.jdisc.secretstore.SecretStore; import com.yahoo.jdisc.Metric; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.curator.Lock; import com.yahoo.vespa.flags.FlagSource; import com.yahoo.vespa.hosted.controller.api.integration.ServiceRegistry; @@ -99,7 +98,7 @@ public class Controller extends AbstractComponent { public Controller(CuratorDb curator, RotationsConfig rotationsConfig, AccessControl accessControl, FlagSource flagSource, MavenRepository mavenRepository, ServiceRegistry serviceRegistry, Metric metric, SecretStore secretStore, ControllerConfig controllerConfig) { - this(curator, rotationsConfig, accessControl, Hostnames::getLocalhost, flagSource, + this(curator, rotationsConfig, accessControl, HostName::getLocalhost, flagSource, mavenRepository, serviceRegistry, metric, secretStore, controllerConfig, Sleeper.DEFAULT); } @@ -280,8 +279,8 @@ public class Controller extends AbstractComponent { } /** Returns the hostname of this controller */ - public HostName hostname() { - return HostName.from(hostnameSupplier.get()); + public com.yahoo.config.provision.HostName hostname() { + return com.yahoo.config.provision.HostName.from(hostnameSupplier.get()); } public SystemName system() { diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ConsoleLogListener.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ConsoleLogListener.java index b506da39731..2cfa604109b 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ConsoleLogListener.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ConsoleLogListener.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.core; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import org.osgi.service.log.LogEntry; import org.osgi.service.log.LogListener; @@ -72,6 +72,6 @@ class ConsoleLogListener implements LogListener { } static String getHostname() { - return Hostnames.getLocalhost(); + return HostName.getLocalhost(); } } diff --git a/messagebus/src/main/java/com/yahoo/messagebus/network/Identity.java b/messagebus/src/main/java/com/yahoo/messagebus/network/Identity.java index 9beb2deb909..1362052996a 100644 --- a/messagebus/src/main/java/com/yahoo/messagebus/network/Identity.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/network/Identity.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.messagebus.network; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; /** * This class encapsulates the identity of the application that uses this instance of message bus. This identity @@ -23,7 +23,7 @@ public class Identity { * @param configId The config identifier for the application. */ public Identity(String configId) { - hostname = Hostnames.getLocalhost(); // ... but fallback to hostname if we get an IPv6 address + hostname = HostName.getLocalhost(); // ... but fallback to hostname if we get an IPv6 address servicePrefix = configId; } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java index 32f2c985880..768fa51f029 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java @@ -8,7 +8,7 @@ import com.yahoo.config.provision.Flavor; import com.yahoo.config.provision.NodeResources; import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.SystemName; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.hosted.provision.Node; import com.yahoo.vespa.hosted.provision.NodeList; import com.yahoo.vespa.hosted.provision.NodeRepository; @@ -347,7 +347,7 @@ class NodeAllocation { // - cfg1 is starting and redeploys its infrastructure application during bootstrap. A deficit is detected // (itself, because cfg1 is only added to the repository *after* it is up) // - cfg1 tries to provision a new host for itself - Integer myIndex = parseIndex(Hostnames.getLocalhost()); + Integer myIndex = parseIndex(HostName.getLocalhost()); indices.remove(myIndex); return indices; } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java index 166b65e08ca..8a66a9394b2 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.provision.restapi; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.slime.Cursor; import com.yahoo.slime.JsonFormat; import com.yahoo.slime.Slime; @@ -33,7 +33,7 @@ public class LocksResponse extends HttpResponse { private final Slime slime = new Slime(); public LocksResponse() { - this(Hostnames.getLocalhost(), + this(HostName.getLocalhost(), new TreeMap<>(LockStats.getGlobal().getLockMetricsByPath()), LockStats.getGlobal().getThreadLockStats(), LockStats.getGlobal().getLockAttemptSamples()); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/DynamicProvisioningMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/DynamicProvisioningMaintainerTest.java index 326d4999bbe..68d75db8a4c 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/DynamicProvisioningMaintainerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/DynamicProvisioningMaintainerTest.java @@ -15,7 +15,7 @@ import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.Zone; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.flags.PermanentFlags; import com.yahoo.vespa.flags.custom.ClusterCapacity; @@ -503,12 +503,12 @@ public class DynamicProvisioningMaintainerTest { assertEquals(2, allNodes.nodeType(hostType.childNodeType()).size()); // Deployment by the removed host has no effect - Hostnames.setHostNameForTestingOnly("cfg2.example.com"); + HostName.setHostNameForTestingOnly("cfg2.example.com"); tester.prepareAndActivateInfraApplication(configSrvApp, hostType.childNodeType()); assertEquals(List.of(), dynamicProvisioningTester.hostProvisioner.provisionedHosts()); // Deployment on another config server starts provisioning a new host and child - Hostnames.setHostNameForTestingOnly("cfg3.example.com"); + HostName.setHostNameForTestingOnly("cfg3.example.com"); assertEquals(0, tester.nodeRepository().nodes().list(Node.State.reserved).nodeType(hostType.childNodeType()).size()); assertEquals(2, tester.prepareAndActivateInfraApplication(configSrvApp, hostType.childNodeType()).size()); assertEquals(1, tester.nodeRepository().nodes().list(Node.State.reserved).nodeType(hostType.childNodeType()).size()); diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java index 79381b8c99e..b9ab1dbe9b6 100644 --- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java +++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java @@ -58,7 +58,7 @@ public class NginxMetricsReporter extends AbstractComponent implements Runnable @Inject public NginxMetricsReporter(ApplicationIdConfig applicationId, Metric metric, HealthStatus healthStatus, RoutingGenerator routingGenerator) { - this(new ApplicationId(applicationId), metric, healthStatus, FileSystems.getDefault(), interval, routingGenerator::routingTable); + this(ApplicationId.from(applicationId), metric, healthStatus, FileSystems.getDefault(), interval, routingGenerator::routingTable); } NginxMetricsReporter(ApplicationId application, Metric metric, HealthStatus healthStatus, FileSystem fileSystem, Duration interval, diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java index ad91dc8c7b1..66955be2325 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java @@ -13,7 +13,7 @@ import com.yahoo.messagebus.Message; import com.yahoo.messagebus.ReplyHandler; import com.yahoo.messagebus.Result; import com.yahoo.messagebus.shared.SharedSourceSession; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.http.client.core.ErrorCode; import com.yahoo.vespa.http.client.core.Headers; import com.yahoo.vespa.http.client.core.OperationStatus; @@ -69,7 +69,7 @@ class ClientFeederV3 { this.feedReplyHandler = feedReplyHandler; this.metric = metric; this.streamReaderV3 = new StreamReaderV3(feedReaderFactory, docTypeManager); - this.hostName = Hostnames.getLocalhost(); + this.hostName = HostName.getLocalhost(); } boolean timedOut() { diff --git a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisitTarget.java b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisitTarget.java index 0138900046c..d1fbde7dd42 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisitTarget.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisitTarget.java @@ -12,7 +12,7 @@ import com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet; import java.util.logging.Level; import com.yahoo.log.LogSetup; import com.yahoo.messagebus.network.Identity; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; @@ -201,7 +201,7 @@ public class VdsVisitTarget { } private String getTcpAddress() { - String hostname = Hostnames.getLocalhost(); + String hostname = HostName.getLocalhost(); return "tcp/" + hostname + ":" + port + "/visit-destination"; } diff --git a/vespajlib/abi-spec.json b/vespajlib/abi-spec.json index bc7888aaac6..20c7d435964 100644 --- a/vespajlib/abi-spec.json +++ b/vespajlib/abi-spec.json @@ -349,14 +349,28 @@ ], "fields": [] }, + "com.yahoo.net.DomainName": { + "superClass": "ai.vespa.validation.PatternedStringWrapper", + "interfaces": [], + "attributes": [ + "public" + ], + "methods": [ + "public static com.yahoo.net.DomainName of(java.lang.String)", + "public static java.lang.String requireLabel(java.lang.String)" + ], + "fields": [ + "public static final com.yahoo.net.DomainName localhost" + ] + }, "com.yahoo.net.HostName": { - "superClass": "java.lang.Object", + "superClass": "ai.vespa.validation.PatternedStringWrapper", "interfaces": [], "attributes": [ "public" ], "methods": [ - "public void <init>()", + "public static com.yahoo.net.HostName of(java.lang.String)", "public static synchronized java.lang.String getLocalhost()", "public static void setHostNameForTestingOnly(java.lang.String)" ], diff --git a/vespajlib/src/main/java/ai/vespa/validation/Validation.java b/vespajlib/src/main/java/ai/vespa/validation/Validation.java index 2dc30efabe3..816ca931c80 100644 --- a/vespajlib/src/main/java/ai/vespa/validation/Validation.java +++ b/vespajlib/src/main/java/ai/vespa/validation/Validation.java @@ -29,6 +29,12 @@ public class Validation { } } + /** Requires the value to have a length in range lower to upper, inclusive. */ + public static String requireLength(String value, String description, int lower, int upper) { + requireInRange(value.length(), description, lower, upper); + return value; + } + /** Requires the value to match the given pattern. */ public static String requireMatch(String value, String description, Pattern pattern) { return require(pattern.matcher(value).matches(), value, description, "must match '" + pattern + "'"); diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java b/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java index 5421bd770bf..1edf8e4edbe 100644 --- a/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java +++ b/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java @@ -2,7 +2,7 @@ package com.yahoo.concurrent.maintenance; import com.yahoo.concurrent.UncheckedTimeoutException; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import java.math.BigDecimal; import java.math.RoundingMode; @@ -45,7 +45,7 @@ public abstract class Maintainer implements Runnable { this.ignoreCollision = ignoreCollision; Objects.requireNonNull(startedAt); Objects.requireNonNull(clusterHostnames); - Duration initialDelay = staggeredDelay(interval, startedAt, Hostnames.getLocalhost(), clusterHostnames) + Duration initialDelay = staggeredDelay(interval, startedAt, HostName.getLocalhost(), clusterHostnames) .plus(Duration.ofSeconds(30)); // Let the system stabilize before maintenance service = new ScheduledThreadPoolExecutor(1, r -> new Thread(r, name() + "-worker")); service.scheduleAtFixedRate(this, initialDelay.toMillis(), interval.toMillis(), TimeUnit.MILLISECONDS); diff --git a/vespajlib/src/main/java/com/yahoo/net/DomainName.java b/vespajlib/src/main/java/com/yahoo/net/DomainName.java index 1215757ee80..ff8ba204674 100644 --- a/vespajlib/src/main/java/com/yahoo/net/DomainName.java +++ b/vespajlib/src/main/java/com/yahoo/net/DomainName.java @@ -5,7 +5,7 @@ import ai.vespa.validation.PatternedStringWrapper; import java.util.regex.Pattern; -import static ai.vespa.validation.Validation.requireInRange; +import static ai.vespa.validation.Validation.requireLength; import static ai.vespa.validation.Validation.requireMatch; /** @@ -21,8 +21,7 @@ public class DomainName extends PatternedStringWrapper<DomainName> { public static final DomainName localhost = DomainName.of("localhost"); private DomainName(String value) { - super(value, domainNamePattern, "domain name"); - requireInRange(value.length(), "domain name length", 1, 255); + super(requireLength(value, "domain name length", 1, 255), domainNamePattern, "domain name"); } public static DomainName of(String value) { diff --git a/vespajlib/src/main/java/com/yahoo/net/Hostnames.java b/vespajlib/src/main/java/com/yahoo/net/HostName.java index c6e78d778e3..47bd8246bb3 100644 --- a/vespajlib/src/main/java/com/yahoo/net/Hostnames.java +++ b/vespajlib/src/main/java/com/yahoo/net/HostName.java @@ -1,19 +1,34 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.net; +import ai.vespa.validation.PatternedStringWrapper; + import java.util.Optional; +import static ai.vespa.validation.Validation.requireLength; + /** - * Utilities for getting the hostname of the system running the JVM. + * Hostnames match {@link DomainName#domainNamePattern}, but are restricted to 64 characters in length. + * + * This class also has utilities for getting the hostname of the system running the JVM. * Detection of the hostname is now done before starting any Vespa * programs and provided in the environment variable VESPA_HOSTNAME; * if that variable isn't set a default of "localhost" is always returned. * * @author arnej + * @author jonmv */ -public class Hostnames { +public class HostName extends PatternedStringWrapper<HostName> { + + private static HostName preferredHostName = null; - private static String preferredHostName = null; + private HostName(String value) { + super(requireLength(value, "hostname length", 1, 64), DomainName.domainNamePattern, "hostname"); + } + + public static HostName of(String value) { + return new HostName(value); + } /** * Return a public and fully qualified hostname for localhost that @@ -25,18 +40,19 @@ public class Hostnames { if (preferredHostName == null) { preferredHostName = getPreferredHostName(); } - return preferredHostName; + return preferredHostName.value(); } - static private String getPreferredHostName() { + static private HostName getPreferredHostName() { Optional<String> vespaHostEnv = Optional.ofNullable(System.getenv("VESPA_HOSTNAME")); if (vespaHostEnv.isPresent() && ! vespaHostEnv.get().trim().isEmpty()) { - return vespaHostEnv.get().trim(); + return of(vespaHostEnv.get().trim()); } - return "localhost"; + return of("localhost"); } public static void setHostNameForTestingOnly(String hostName) { - preferredHostName = hostName; + preferredHostName = HostName.of(hostName); } + } diff --git a/vespajlib/src/main/java/com/yahoo/net/Hostname.java b/vespajlib/src/main/java/com/yahoo/net/Hostname.java deleted file mode 100644 index cbf6fb8d1ca..00000000000 --- a/vespajlib/src/main/java/com/yahoo/net/Hostname.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.net; - -import ai.vespa.validation.PatternedStringWrapper; -import ai.vespa.validation.StringWrapper; - -import static ai.vespa.validation.Validation.requireInRange; -import static ai.vespa.validation.Validation.requireMatch; - -/** - * A valid hostname, matching {@link DomainName#domainNamePattern}, and no more than 64 characters in length. - * - * @author jonmv - */ -public class Hostname extends PatternedStringWrapper<Hostname> { - - private Hostname(String value) { - super(value, DomainName.domainNamePattern, "hostname"); - requireInRange(value.length(), "hostname length", 1, 64); - } - - public static Hostname of(String value) { - return new Hostname(value); - } - -} diff --git a/vespajlib/src/test/java/com/yahoo/net/HostNameTest.java b/vespajlib/src/test/java/com/yahoo/net/HostNameTest.java new file mode 100644 index 00000000000..fa756b31616 --- /dev/null +++ b/vespajlib/src/test/java/com/yahoo/net/HostNameTest.java @@ -0,0 +1,41 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.net; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @author jonmv + */ +public class HostNameTest { + + @Test + void testNames() { + HostName.of("name-123.0.321-eman"); + HostName.of(("." + "a".repeat(32)).repeat(2).substring(1, 65)); + HostName.of("123"); + + assertThrows(IllegalArgumentException.class, () -> HostName.of("_")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("-")); + assertThrows(IllegalArgumentException.class, () -> HostName.of(".")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("-foo")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo-")); + assertThrows(IllegalArgumentException.class, () -> HostName.of(".foo")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo.")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo..bar")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo.-.bar")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo/")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo%")); + assertThrows(IllegalArgumentException.class, () -> HostName.of(("." + "a".repeat(32)).repeat(2).substring(1, 66))); + assertThrows(IllegalArgumentException.class, () -> HostName.of("a".repeat(64))); + } + + @Test + void testHostnameIsFound() { + assertFalse(HostName.getLocalhost().isEmpty()); + } + +} diff --git a/vespajlib/src/test/java/com/yahoo/net/HostnameTest.java b/vespajlib/src/test/java/com/yahoo/net/HostnameTest.java deleted file mode 100644 index ef502aea2cd..00000000000 --- a/vespajlib/src/test/java/com/yahoo/net/HostnameTest.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.net; - -import com.yahoo.net.Hostname; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * @author jonmv - */ -public class HostnameTest { - - @Test - void testNames() { - Hostname.of("name-123.0.321-eman"); - Hostname.of(("." + "a".repeat(32)).repeat(2).substring(1, 65)); - Hostname.of("123"); - - assertThrows(IllegalArgumentException.class, () -> Hostname.of("_")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("-")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of(".")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("-foo")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo-")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of(".foo")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo.")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo..bar")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo.-.bar")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo/")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo%")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of(("." + "a".repeat(32)).repeat(2).substring(1, 66))); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("a".repeat(64))); - } - -} diff --git a/vespajlib/src/test/java/com/yahoo/net/HostnamesTestCase.java b/vespajlib/src/test/java/com/yahoo/net/HostnamesTestCase.java deleted file mode 100644 index 2e942605e3e..00000000000 --- a/vespajlib/src/test/java/com/yahoo/net/HostnamesTestCase.java +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.net; - -import org.junit.Test; - -import static org.junit.Assert.assertFalse; - -/** - * @author Ulf Lilleengen - */ -public class HostnamesTestCase { - - @Test - public void testHostnameIsFound() { - assertFalse(Hostnames.getLocalhost().isEmpty()); - } - -} diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/ConnectionSpec.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/ConnectionSpec.java index 73a46981c9b..022932bef89 100644 --- a/zkfacade/src/main/java/com/yahoo/vespa/curator/ConnectionSpec.java +++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/ConnectionSpec.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.curator; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import java.util.List; import java.util.Objects; @@ -75,7 +75,7 @@ class ConnectionSpec { Function<T, String> hostnameGetter, Function<T, Integer> portGetter, boolean localhostAffinity) { - String thisServer = Hostnames.getLocalhost(); + String thisServer = HostName.getLocalhost(); StringBuilder connectionSpec = new StringBuilder(); for (var server : servers) { if (localhostAffinity && !thisServer.equals(hostnameGetter.apply(server))) continue; diff --git a/zkfacade/src/test/java/com/yahoo/vespa/curator/ConnectionSpecTest.java b/zkfacade/src/test/java/com/yahoo/vespa/curator/ConnectionSpecTest.java index b4bf8bc1e73..6e833088f0d 100644 --- a/zkfacade/src/test/java/com/yahoo/vespa/curator/ConnectionSpecTest.java +++ b/zkfacade/src/test/java/com/yahoo/vespa/curator/ConnectionSpecTest.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.curator; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import org.junit.Test; import java.util.List; @@ -15,7 +15,7 @@ public class ConnectionSpecTest { @Test public void create() { - Hostnames.setHostNameForTestingOnly("host2"); + HostName.setHostNameForTestingOnly("host2"); Config config = new Config(List.of(new Config.Server("host1", 10001), new Config.Server("host2", 10002), new Config.Server("host3", 10003))); diff --git a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java index dbefda6282e..71eae121313 100644 --- a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java +++ b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.curator; import com.yahoo.cloud.config.CuratorConfig; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.path.Path; import com.yahoo.text.Utf8; import org.junit.Test; @@ -19,7 +19,7 @@ import static org.junit.Assert.fail; */ public class CuratorTest { - private static final String localhost = Hostnames.getLocalhost(); + private static final String localhost = HostName.getLocalhost(); private static final int port1 = 1; private static final int port2 = 2; diff --git a/zookeeper-server/zookeeper-server-3.7.0/src/test/java/com/yahoo/vespa/zookeper/VespaZooKeeperTest.java b/zookeeper-server/zookeeper-server-3.7.0/src/test/java/com/yahoo/vespa/zookeper/VespaZooKeeperTest.java index 123059a8a1f..db643d76e0d 100644 --- a/zookeeper-server/zookeeper-server-3.7.0/src/test/java/com/yahoo/vespa/zookeper/VespaZooKeeperTest.java +++ b/zookeeper-server/zookeeper-server-3.7.0/src/test/java/com/yahoo/vespa/zookeper/VespaZooKeeperTest.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.zookeper; import com.yahoo.cloud.config.ZookeeperServerConfig; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.vespa.zookeeper.ReconfigurableVespaZooKeeperServer; import com.yahoo.vespa.zookeeper.Reconfigurer; import com.yahoo.vespa.zookeeper.VespaZooKeeperAdminImpl; @@ -147,7 +147,7 @@ public class VespaZooKeeperTest { } static ZooKeeperAdmin createAdmin(ZookeeperServerConfig config) throws IOException { - return new ZooKeeperAdmin(Hostnames.getLocalhost() + ":" + config.clientPort(), + return new ZooKeeperAdmin(HostName.getLocalhost() + ":" + config.clientPort(), 10_000, System.err::println, new ZkClientConfigBuilder().toConfig()); diff --git a/zookeeper-server/zookeeper-server-common/src/main/java/com/yahoo/vespa/zookeeper/Reconfigurer.java b/zookeeper-server/zookeeper-server-common/src/main/java/com/yahoo/vespa/zookeeper/Reconfigurer.java index 229290c2f8b..389df340ca7 100644 --- a/zookeeper-server/zookeeper-server-common/src/main/java/com/yahoo/vespa/zookeeper/Reconfigurer.java +++ b/zookeeper-server/zookeeper-server-common/src/main/java/com/yahoo/vespa/zookeeper/Reconfigurer.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.zookeeper; import com.google.inject.Inject; import com.yahoo.cloud.config.ZookeeperServerConfig; import com.yahoo.component.AbstractComponent; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import com.yahoo.protect.Process; import com.yahoo.yolean.Exceptions; @@ -135,7 +135,7 @@ public class Reconfigurer extends AbstractComponent { } private static String localConnectionSpec(ZookeeperServerConfig config) { - return Hostnames.getLocalhost() + ":" + config.clientPort(); + return HostName.getLocalhost() + ":" + config.clientPort(); } private static List<String> servers(ZookeeperServerConfig config) { diff --git a/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ReconfigurerTest.java b/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ReconfigurerTest.java index f31d742884d..760c326cf5d 100644 --- a/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ReconfigurerTest.java +++ b/zookeeper-server/zookeeper-server-common/src/test/java/com/yahoo/vespa/zookeeper/ReconfigurerTest.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.zookeeper; import com.yahoo.cloud.config.ZookeeperServerConfig; -import com.yahoo.net.Hostnames; +import com.yahoo.net.HostName; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -150,7 +150,7 @@ public class ReconfigurerTest { } }); this.zooKeeperAdmin = zooKeeperAdmin; - Hostnames.setHostNameForTestingOnly("node1"); + HostName.setHostNameForTestingOnly("node1"); } void startOrReconfigure(ZookeeperServerConfig newConfig) { |