diff options
author | Harald Musum <musum@oath.com> | 2018-06-05 14:55:09 +0200 |
---|---|---|
committer | Harald Musum <musum@oath.com> | 2018-06-05 14:55:09 +0200 |
commit | eeb39b8c511cf4f04441d6c1c26ff9c20db8ccb2 (patch) | |
tree | e27c813804adfa51645348f95fcbadb93c6bbdc5 /container-core | |
parent | d7e4a45dfcce14abba9acc93edd417aa502dccc3 (diff) |
Add initiallyInRotation to vip status config and inject config into VipStatus
Use config value for inital value of isInRotation() when nothing
is known about backend clusters
Diffstat (limited to 'container-core')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/handler/VipStatus.java | 18 | ||||
-rw-r--r-- | container-core/src/main/resources/configdefinitions/vip-status.def | 7 |
2 files changed, 18 insertions, 7 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/VipStatus.java b/container-core/src/main/java/com/yahoo/container/handler/VipStatus.java index bcd6e930ee3..d7457140dae 100644 --- a/container-core/src/main/java/com/yahoo/container/handler/VipStatus.java +++ b/container-core/src/main/java/com/yahoo/container/handler/VipStatus.java @@ -6,6 +6,7 @@ import java.util.Map; import com.google.inject.Inject; import com.yahoo.container.QrSearchersConfig; +import com.yahoo.container.core.VipStatusConfig; /** * API for programmatically removing the container from VIP rotation. @@ -15,15 +16,22 @@ import com.yahoo.container.QrSearchersConfig; public class VipStatus { private final Map<Object, Boolean> clusters = new IdentityHashMap<>(); + private final VipStatusConfig vipStatusConfig; public VipStatus() { - this(null); + this(null, new VipStatusConfig(new VipStatusConfig.Builder())); } - @Inject public VipStatus(QrSearchersConfig dispatchers) { + this(dispatchers, new VipStatusConfig(new VipStatusConfig.Builder())); + } + + // TODO: Why use QrSearchersConfig here? Remove and inject ComponentRegistry<ClusterSearcher> instead? + @Inject + public VipStatus(QrSearchersConfig dispatchers, VipStatusConfig vipStatusConfig) { // the config is not used for anything, it's just a dummy to create a // dependency link to which dispatchers are used + this.vipStatusConfig = vipStatusConfig; } /** @@ -55,14 +63,14 @@ public class VipStatus { /** * Tell whether the container is connected to any active services at all. * - * @return true if at least one service or cluster is up, or if no services + * @return true if at least one service or cluster is up, or value is taken from config if no services * are registered (yet) */ public boolean isInRotation() { synchronized (clusters) { - // if no stored state, try serving + // if no stored state, use config to decide whether to serve or not if (clusters.size() == 0) { - return true; + return vipStatusConfig.initiallyInRotation(); } for (Boolean inRotation : clusters.values()) { if (inRotation) { diff --git a/container-core/src/main/resources/configdefinitions/vip-status.def b/container-core/src/main/resources/configdefinitions/vip-status.def index 44da7292f05..1e364419ab8 100644 --- a/container-core/src/main/resources/configdefinitions/vip-status.def +++ b/container-core/src/main/resources/configdefinitions/vip-status.def @@ -6,9 +6,12 @@ namespace=container.core ## rotation, ignoring any status file. noSearchBackendsImpliesOutOfService bool default=true -## Whether to return hard coded reply or serve "status.html" from disk +## Whether to return hard-coded reply or serve "status.html" from disk accessdisk bool default=false ## The file to serve as the status file. -## If the paht is relative vespa home is prepended +## If the path is relative vespa home is prepended statusfile string default="share/qrsdocs/status.html" + +## The initial rotation state when no information is known about backend clusters +initiallyInRotation bool default=true |