diff options
author | Harald Musum <musum@yahoo-inc.com> | 2017-03-20 13:03:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-20 13:03:59 +0100 |
commit | a64fdc01aa355e31a9ed069798ac91d8c0703c0b (patch) | |
tree | 9b70d5ae8b395f47c4e8ae7e2474c8c676d80fb8 /node-admin/src | |
parent | 085a863a5da351ab46fabd28169dae6255f759ce (diff) | |
parent | 0824143f5f56686f95c50104d2253d8fdfe4eedb (diff) |
Merge pull request #2034 from yahoo/mortent/propagate-logstash-env
Initialize environment with logstash nodes from environment
Diffstat (limited to 'node-admin/src')
-rw-r--r-- | node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/Environment.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/Environment.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/Environment.java index df7fe151cae..cdf473263cf 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/Environment.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/util/Environment.java @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.node.admin.util; +import com.google.common.base.Strings; import com.yahoo.net.HostName; import com.yahoo.vespa.hosted.dockerapi.ContainerName; @@ -32,6 +33,7 @@ public class Environment { private static final String ENV_CONFIGSERVERS = "services__addr_configserver"; private static final String ENVIRONMENT = "ENVIRONMENT"; private static final String REGION = "REGION"; + private static final String LOGSTASH_NODES = "LOGSTASH_NODES"; private final Set<String> configServerHosts; private final String environment; @@ -53,7 +55,7 @@ public class Environment { HostName.getLocalhost(), new InetAddressResolver(), new PathResolver(), - Collections.emptyList() + getLogstashNodesFromEnvironment() ); } @@ -107,6 +109,14 @@ public class Environment { return hostNameStrings.stream().collect(Collectors.toSet()); } + private static List<String> getLogstashNodesFromEnvironment() { + String logstashNodes = System.getenv(LOGSTASH_NODES); + if(Strings.isNullOrEmpty(logstashNodes)) { + return Collections.emptyList(); + } + return Arrays.asList(logstashNodes.split("[,\\s]+")); + } + public InetAddress getInetAddressForHost(String hostname) throws UnknownHostException { return inetAddressResolver.getInetAddressForHost(hostname); } |