aboutsummaryrefslogtreecommitdiffstats
path: root/config-provisioning/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-03-02 12:29:46 +0100
committerMartin Polden <mpolden@mpolden.no>2020-03-02 13:09:05 +0100
commit8dc031111d0ec7ff77273a3a21e0f23c7d4aceca (patch)
tree38855a8dfc04fd1203efaf5f979973f1c3c733ea /config-provisioning/src/main/java/com/yahoo
parent9ac4f3d18e1dbb11678b8d61fa50c9ad1cdf61d2 (diff)
Add combined ID to ClusterSpec
Diffstat (limited to 'config-provisioning/src/main/java/com/yahoo')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java14
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java31
2 files changed, 36 insertions, 9 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java
index f041823bf04..0fb78b59aaf 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java
@@ -3,9 +3,11 @@ package com.yahoo.config.provision;
import com.yahoo.component.Version;
+import java.util.Optional;
+
/**
* A node's membership in a cluster. This is a value object.
- * The format is "clusterType/clusterId/groupId/index[/exclusive][/retired]"
+ * The format is "clusterType/clusterId/groupId/index[/exclusive][/retired][/combinedId]"
*
* @author bratseth
*/
@@ -22,21 +24,24 @@ public class ClusterMembership {
String[] components = stringValue.split("/");
if (components.length < 4)
throw new RuntimeException("Could not parse '" + stringValue + "' to a cluster membership. " +
- "Expected 'clusterType/clusterId/groupId/index[/retired][/exclusive]'");
+ "Expected 'clusterType/clusterId/groupId/index[/retired][/exclusive][/combinedId]'");
boolean exclusive = false;
+ var combinedId = Optional.<String>empty();
if (components.length > 4) {
for (int i = 4; i < components.length; i++) {
String component = components[i];
switch (component) {
case "exclusive": exclusive = true; break;
case "retired": retired = true; break;
+ default: combinedId = Optional.of(component); break;
}
}
}
this.cluster = ClusterSpec.from(ClusterSpec.Type.valueOf(components[0]), ClusterSpec.Id.from(components[1]),
- ClusterSpec.Group.from(Integer.valueOf(components[2])), vespaVersion, exclusive);
+ ClusterSpec.Group.from(Integer.parseInt(components[2])), vespaVersion,
+ exclusive, combinedId.map(ClusterSpec.Id::from));
this.index = Integer.parseInt(components[3]);
this.stringValue = toStringValue();
}
@@ -54,7 +59,8 @@ public class ClusterMembership {
(cluster.group().isPresent() ? "/" + cluster.group().get().index() : "") +
"/" + index +
( cluster.isExclusive() ? "/exclusive" : "") +
- ( retired ? "/retired" : "");
+ ( retired ? "/retired" : "") +
+ ( cluster.combinedId().isPresent() ? "/" + cluster.combinedId().get().value() : "");
}
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java
index 5aed5d8e2e7..e1a28e3f8d7 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java
@@ -21,13 +21,19 @@ public final class ClusterSpec {
private final Optional<Group> groupId;
private final Version vespaVersion;
private boolean exclusive;
+ private final Optional<Id> combinedId;
- private ClusterSpec(Type type, Id id, Optional<Group> groupId, Version vespaVersion, boolean exclusive) {
+ private ClusterSpec(Type type, Id id, Optional<Group> groupId, Version vespaVersion, boolean exclusive, Optional<Id> combinedId) {
this.type = type;
this.id = id;
this.groupId = groupId;
this.vespaVersion = vespaVersion;
this.exclusive = exclusive;
+ // TODO(mpolden): Require combinedId to always be present for type combined after April 2020
+ if (type != Type.combined && combinedId.isPresent()) {
+ throw new IllegalArgumentException("combinedId must be empty for cluster of type " + type);
+ }
+ this.combinedId = combinedId;
}
/** Returns the cluster type */
@@ -42,6 +48,11 @@ public final class ClusterSpec {
/** Returns the group within the cluster this specifies, or empty to specify the whole cluster */
public Optional<Group> group() { return groupId; }
+ /** Returns the ID of the container cluster that is combined with this. This is only present for combined clusters */
+ public Optional<Id> combinedId() {
+ return combinedId;
+ }
+
/**
* Returns whether the physical hosts running the nodes of this application can
* also run nodes of other applications. Using exclusive nodes for containers increases security
@@ -50,19 +61,29 @@ public final class ClusterSpec {
public boolean isExclusive() { return exclusive; }
public ClusterSpec with(Optional<Group> newGroup) {
- return new ClusterSpec(type, id, newGroup, vespaVersion, exclusive);
+ return new ClusterSpec(type, id, newGroup, vespaVersion, exclusive, combinedId);
}
public ClusterSpec exclusive(boolean exclusive) {
- return new ClusterSpec(type, id, groupId, vespaVersion, exclusive);
+ return new ClusterSpec(type, id, groupId, vespaVersion, exclusive, combinedId);
}
+ // TODO(mpolden): Remove after April 2020
public static ClusterSpec request(Type type, Id id, Version vespaVersion, boolean exclusive) {
- return new ClusterSpec(type, id, Optional.empty(), vespaVersion, exclusive);
+ return request(type, id, vespaVersion, exclusive, Optional.empty());
}
+ public static ClusterSpec request(Type type, Id id, Version vespaVersion, boolean exclusive, Optional<Id> combinedId) {
+ return new ClusterSpec(type, id, Optional.empty(), vespaVersion, exclusive, combinedId);
+ }
+
+ // TODO(mpolden): Remove after April 2020
public static ClusterSpec from(Type type, Id id, Group groupId, Version vespaVersion, boolean exclusive) {
- return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion, exclusive);
+ return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion, exclusive, Optional.empty());
+ }
+
+ public static ClusterSpec from(Type type, Id id, Group groupId, Version vespaVersion, boolean exclusive, Optional<Id> combinedId) {
+ return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion, exclusive, combinedId);
}
@Override