summaryrefslogtreecommitdiffstats
path: root/vespaclient-core
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2021-01-05 12:29:17 +0100
committerGitHub <noreply@github.com>2021-01-05 12:29:17 +0100
commit75b2e4c11ea6463c335f1c77dab3fdb5493e5600 (patch)
tree1c01f7e4d6492ed9e508d8841f975e2c1fc177c6 /vespaclient-core
parent25f217ff7f0c4f8ae921b71788a083c6b6acf2cc (diff)
Revert "Jonmv/remove storage policy"
Diffstat (limited to 'vespaclient-core')
-rw-r--r--vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterDef.java12
-rw-r--r--vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java26
2 files changed, 23 insertions, 15 deletions
diff --git a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterDef.java b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterDef.java
index f3b8c189fc5..95bd9cf1cb5 100644
--- a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterDef.java
+++ b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterDef.java
@@ -2,8 +2,14 @@
package com.yahoo.vespaclient;
public class ClusterDef {
- private final String name;
- public ClusterDef(String name) { this.name = name; }
+ public ClusterDef(String name, String configId) {
+ this.name = name;
+ this.configId = configId;
+ }
+
+ String name;
+ String configId;
+
public String getName() { return name; }
- public String getRoute() { return name + "-direct"; }
+ public String getConfigId() { return configId; }
}
diff --git a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
index 2c3a0b72ed5..4525ffcae39 100644
--- a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
+++ b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
@@ -4,38 +4,40 @@ package com.yahoo.vespaclient;
import com.yahoo.cloud.config.ClusterListConfig;
import com.yahoo.config.subscription.ConfigGetter;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-import java.util.stream.Collectors;
/** A list of content clusters, either obtained from a list, a given config or by self-subscribing */
public class ClusterList {
- private final List<ClusterDef> contentClusters;
+ List<ClusterDef> contentClusters = new ArrayList<>();
public ClusterList() {
- this(List.of());
+ this(new ArrayList<>());
}
public ClusterList(List<ClusterDef> contentClusters) {
- this.contentClusters = List.copyOf(contentClusters);
+ this.contentClusters = contentClusters;
}
public ClusterList(String configId) {
- this(new ConfigGetter<>(ClusterListConfig.class).getConfig(configId));
+ configure(new ConfigGetter<>(ClusterListConfig.class).getConfig(configId));
}
public ClusterList(ClusterListConfig config) {
- this(parse(config));
+ configure(config);
}
- public List<ClusterDef> getStorageClusters() {
- return contentClusters;
+ private void configure(ClusterListConfig config) {
+ contentClusters.clear(); // TODO: Create a new
+ for (int i = 0; i < config.storage().size(); i++)
+ contentClusters.add(new ClusterDef(config.storage(i).name(), config.storage(i).configid()));
}
- private static List<ClusterDef> parse(ClusterListConfig config) {
- return config.storage().stream()
- .map(storage -> new ClusterDef(storage.name()))
- .collect(Collectors.toUnmodifiableList());
+ /** Returns a reference to the mutable list */
+ public List<ClusterDef> getStorageClusters() {
+ return contentClusters; // TODO: Use immutable list
}
}