diff options
author | Harald Musum <musum@oath.com> | 2018-02-15 13:56:23 +0100 |
---|---|---|
committer | Harald Musum <musum@oath.com> | 2018-02-15 13:56:23 +0100 |
commit | 083855be00cbf5d5f81376b664613a5c6a4c6c87 (patch) | |
tree | 7082b8f146c02fc1531a3000fa3e5a97f064e2cd /node-admin | |
parent | e25932fc7c2b35ec98c3c2cf7728c4a282c4571b (diff) |
Add node type configserverhost and use it in Environment
Diffstat (limited to 'node-admin')
-rw-r--r-- | node-admin/pom.xml | 7 | ||||
-rw-r--r-- | node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/Environment.java | 45 |
2 files changed, 35 insertions, 17 deletions
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 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>com.yahoo.vespa</groupId> + <groupId>com.yahoo.vespa</groupId> + <artifactId>config-provisioning</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> <artifactId>node-repository</artifactId> <version>${project.version}</version> </dependency> 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<URI> configServerHosts; + private final List<URI> configServerURIs; private final String environment; private final String region; private final String parentHostHostname; @@ -52,6 +53,7 @@ public class Environment { private final Optional<KeyStoreOptions> keyStoreOptions; private final Optional<KeyStoreOptions> trustStoreOptions; private final Optional<AthenzIdentity> 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<String> coreDumpFeedEndpoint) { + Optional<String> 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<URI> configServerHosts, + public Environment(List<URI> configServerURIs, String environment, String region, String parentHostHostname, @@ -107,8 +112,9 @@ public class Environment { Optional<String> feedEndpoint, Optional<KeyStoreOptions> keyStoreOptions, Optional<KeyStoreOptions> trustStoreOptions, - Optional<AthenzIdentity> athenzIdentity) { - this.configServerHosts = configServerHosts; + Optional<AthenzIdentity> 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<URI> getConfigServerUris() { return configServerHosts; } + public List<URI> getConfigServerUris() { return configServerURIs; } public String getEnvironment() { return environment; @@ -147,7 +154,7 @@ public class Environment { return getEnvironment() + "." + getRegion(); } - private static List<URI> createConfigServerUris(String scheme, List<String> configServerHosts, int port) { + public static List<URI> createConfigServerUris(String scheme, List<String> 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<URI> configServerHosts = Collections.emptyList(); + private List<URI> 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<URI> 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); } } } |