diff options
author | Valerij Fredriksen <valerijf@oath.com> | 2018-10-23 09:43:54 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerijf@oath.com> | 2018-10-23 09:43:54 +0200 |
commit | 775f400b2a4dde3ebcc3c51035f8b08aa9455702 (patch) | |
tree | 88d484fd1fea5f7666a6aea7f7dcf11072eb36fe /config-provisioning/src/main/java/com/yahoo/config/provision | |
parent | f77121c5e9cff27f81ce5a3a39955855bc544c27 (diff) |
Add a method to get child type from host
Diffstat (limited to 'config-provisioning/src/main/java/com/yahoo/config/provision')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java index d56a7c3e298..44bd7ec3708 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java @@ -9,43 +9,53 @@ package com.yahoo.config.provision; public enum NodeType { /** A node to be assigned to a tenant to run application workloads */ - tenant(false, "Tenant node"), + tenant(null, "Tenant node"), /** A host of a set of (Docker) tenant nodes */ - host(true, "Tenant docker host"), + host(tenant, "Tenant docker host"), /** Nodes running the shared proxy layer */ - proxy(false, "Proxy node"), + proxy(null, "Proxy node"), /** A host of a (Docker) proxy node */ - proxyhost(true, "Proxy docker host"), + proxyhost(proxy, "Proxy docker host"), /** A config server */ - config(false, "Config server"), + config(null, "Config server"), /** A host of a (Docker) config server node */ - confighost(true, "Config docker host"), + confighost(config, "Config docker host"), /** A controller */ - controller(false, "Controller"), + controller(null, "Controller"), /** A host of a (Docker) controller node */ - controllerhost(true, "Controller host"); + controllerhost(controller, "Controller host"); - private final boolean isDockerHost; + private final NodeType childNodeType; private final String description; - NodeType(boolean isDockerHost, String description) { - this.isDockerHost = isDockerHost; + NodeType(NodeType childNodeType, String description) { + this.childNodeType = childNodeType; this.description = description; } public boolean isDockerHost() { - return isDockerHost; + return childNodeType != null; } public String description() { return description; } + /** + * @return {@link NodeType} of the node(s) that run on this host + * @throws IllegalStateException if this type is not a host + */ + public NodeType childNodeType() { + if (! isDockerHost()) + throw new IllegalStateException(this + " has no children"); + + return childNodeType; + } } |