From 083855be00cbf5d5f81376b664613a5c6a4c6c87 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Thu, 15 Feb 2018 13:56:23 +0100 Subject: Add node type configserverhost and use it in Environment --- node-admin/pom.xml | 7 +++- .../hosted/node/admin/component/Environment.java | 45 ++++++++++++++-------- 2 files changed, 35 insertions(+), 17 deletions(-) (limited to 'node-admin') diff --git a/node-admin/pom.xml b/node-admin/pom.xml index 3bd7eb04e8b..015d26ce5d4 100644 --- a/node-admin/pom.xml +++ b/node-admin/pom.xml @@ -25,7 +25,12 @@ provided - com.yahoo.vespa + com.yahoo.vespa + config-provisioning + ${project.version} + + + com.yahoo.vespa node-repository ${project.version} diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/Environment.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/Environment.java index 7376a59bd5c..82011811506 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/Environment.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/Environment.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.node.admin.component; import com.google.common.base.Strings; +import com.yahoo.config.provision.NodeType; import com.yahoo.vespa.athenz.api.AthenzIdentity; import com.yahoo.vespa.athenz.api.AthenzService; import com.yahoo.vespa.defaults.Defaults; @@ -41,7 +42,7 @@ public class Environment { private static final String LOGSTASH_NODES = "LOGSTASH_NODES"; private static final String COREDUMP_FEED_ENDPOINT = "COREDUMP_FEED_ENDPOINT"; - private final List configServerHosts; + private final List configServerURIs; private final String environment; private final String region; private final String parentHostHostname; @@ -52,6 +53,7 @@ public class Environment { private final Optional keyStoreOptions; private final Optional trustStoreOptions; private final Optional athenzIdentity; + private final NodeType nodeType; static { filenameFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); @@ -62,14 +64,16 @@ public class Environment { getEnvironmentVariable(ENVIRONMENT), getEnvironmentVariable(REGION), new PathResolver(), - Optional.of(getEnvironmentVariable(COREDUMP_FEED_ENDPOINT))); + Optional.of(getEnvironmentVariable(COREDUMP_FEED_ENDPOINT)), + NodeType.host); } public Environment(ConfigServerConfig configServerConfig, String hostedEnvironment, String hostedRegion, PathResolver pathResolver, - Optional coreDumpFeedEndpoint) { + Optional coreDumpFeedEndpoint, + NodeType nodeType) { this(createConfigServerUris( configServerConfig.scheme(), configServerConfig.hosts(), @@ -93,11 +97,12 @@ public class Environment { configServerConfig.trustStoreConfig().type().name()), createAthenzIdentity( configServerConfig.athenzDomain(), - configServerConfig.serviceName()) + configServerConfig.serviceName()), + nodeType ); } - public Environment(List configServerHosts, + public Environment(List configServerURIs, String environment, String region, String parentHostHostname, @@ -107,8 +112,9 @@ public class Environment { Optional feedEndpoint, Optional keyStoreOptions, Optional trustStoreOptions, - Optional athenzIdentity) { - this.configServerHosts = configServerHosts; + Optional athenzIdentity, + NodeType nodeType) { + this.configServerURIs = configServerURIs; this.environment = environment; this.region = region; this.parentHostHostname = parentHostHostname; @@ -119,9 +125,10 @@ public class Environment { this.keyStoreOptions = keyStoreOptions; this.trustStoreOptions = trustStoreOptions; this.athenzIdentity = athenzIdentity; + this.nodeType = nodeType; } - public List getConfigServerUris() { return configServerHosts; } + public List getConfigServerUris() { return configServerURIs; } public String getEnvironment() { return environment; @@ -147,7 +154,7 @@ public class Environment { return getEnvironment() + "." + getRegion(); } - private static List createConfigServerUris(String scheme, List configServerHosts, int port) { + public static List createConfigServerUris(String scheme, List configServerHosts, int port) { return configServerHosts.stream() .map(hostname -> URI.create(scheme + "://" + hostname + ":" + port)) .collect(Collectors.toList()); @@ -250,9 +257,10 @@ public class Environment { return athenzIdentity; } + public NodeType getNodeType() { return nodeType; } public static class Builder { - private List configServerHosts = Collections.emptyList(); + private List configServerURIs = Collections.emptyList(); private String environment; private String region; private String parentHostHostname; @@ -263,11 +271,10 @@ public class Environment { private KeyStoreOptions keyStoreOptions; private KeyStoreOptions trustStoreOptions; private AthenzIdentity athenzIdentity; + private NodeType nodeType = NodeType.tenant; - public Builder configServerUris(String... hosts) { - configServerHosts = Arrays.stream(hosts) - .map(URI::create) - .collect(Collectors.toList()); + public Builder configServerUris(List uris) { + configServerURIs = uris; return this; } @@ -321,11 +328,17 @@ public class Environment { return this; } + public Builder nodeType(NodeType nodeType) { + this.nodeType = nodeType; + return this; + } + public Environment build() { - return new Environment(configServerHosts, environment, region, parentHostHostname, inetAddressResolver, + return new Environment(configServerURIs, environment, region, parentHostHostname, inetAddressResolver, pathResolver, logstashNodes, feedEndpoint, Optional.ofNullable(keyStoreOptions), Optional.ofNullable(trustStoreOptions), - Optional.ofNullable(athenzIdentity)); + Optional.ofNullable(athenzIdentity), + nodeType); } } } -- cgit v1.2.3