aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2021-01-05 21:29:13 +0100
committerGitHub <noreply@github.com>2021-01-05 21:29:13 +0100
commit82f3c2b944a5dfc082aefe8fb8d53597475705d2 (patch)
treeaa5c3ed3f8222eaeecca9c0839a1c2c1a78fe721 /vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
parent6eb07d7086eacc5cf1db773f5c4ac9964349a377 (diff)
parent56f4cf889caf4802ae0ed4d403e3c5b08bb341d0 (diff)
Merge pull request #15918 from vespa-engine/jonmv/reapply-remove-storage-plicy
Jonmv/reapply remove storage plicy
Diffstat (limited to 'vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java')
-rw-r--r--vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java26
1 files changed, 12 insertions, 14 deletions
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 4525ffcae39..2c3a0b72ed5 100644
--- a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
+++ b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
@@ -4,40 +4,38 @@ 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 {
- List<ClusterDef> contentClusters = new ArrayList<>();
+ private final List<ClusterDef> contentClusters;
public ClusterList() {
- this(new ArrayList<>());
+ this(List.of());
}
public ClusterList(List<ClusterDef> contentClusters) {
- this.contentClusters = contentClusters;
+ this.contentClusters = List.copyOf(contentClusters);
}
public ClusterList(String configId) {
- configure(new ConfigGetter<>(ClusterListConfig.class).getConfig(configId));
+ this(new ConfigGetter<>(ClusterListConfig.class).getConfig(configId));
}
public ClusterList(ClusterListConfig config) {
- configure(config);
+ this(parse(config));
}
- 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()));
+ public List<ClusterDef> getStorageClusters() {
+ return contentClusters;
}
- /** Returns a reference to the mutable list */
- public List<ClusterDef> getStorageClusters() {
- return contentClusters; // TODO: Use immutable list
+ private static List<ClusterDef> parse(ClusterListConfig config) {
+ return config.storage().stream()
+ .map(storage -> new ClusterDef(storage.name()))
+ .collect(Collectors.toUnmodifiableList());
}
}