blob: 2c3a0b72ed5fcf3349348c22728d5ee60faa3dd9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespaclient;
import com.yahoo.cloud.config.ClusterListConfig;
import com.yahoo.config.subscription.ConfigGetter;
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;
public ClusterList() {
this(List.of());
}
public ClusterList(List<ClusterDef> contentClusters) {
this.contentClusters = List.copyOf(contentClusters);
}
public ClusterList(String configId) {
this(new ConfigGetter<>(ClusterListConfig.class).getConfig(configId));
}
public ClusterList(ClusterListConfig config) {
this(parse(config));
}
public List<ClusterDef> getStorageClusters() {
return contentClusters;
}
private static List<ClusterDef> parse(ClusterListConfig config) {
return config.storage().stream()
.map(storage -> new ClusterDef(storage.name()))
.collect(Collectors.toUnmodifiableList());
}
}
|