blob: 236172dc5fd7c22dbf6eaebfb8627c71a394ec1e (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.model;
import com.yahoo.cloud.config.LbServicesConfig;
import com.yahoo.config.ConfigurationRuntimeException;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.SuperModel;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.ConfigPayload;
import com.yahoo.vespa.flags.FlagSource;
import java.util.Collections;
import java.util.Map;
/**
* A config model that provides config containing information from all known tenants and applications.
*
* @author Vegard Havdal
*/
public class SuperModelConfigProvider implements LbServicesConfig.Producer {
private final SuperModel superModel;
private final LbServicesProducer lbProd;
public SuperModelConfigProvider(SuperModel superModel, Zone zone, FlagSource flagSource) {
this.superModel = superModel;
this.lbProd = new LbServicesProducer(Collections.unmodifiableMap(superModel.getModelsPerTenant()), zone, flagSource);
}
public SuperModel getSuperModel() {
return superModel;
}
public ConfigPayload getConfig(ConfigKey<?> configKey) {
// TODO: Override not applied, but not really necessary here
if (configKey.equals(new ConfigKey<>(LbServicesConfig.class, configKey.getConfigId()))) {
LbServicesConfig.Builder builder = new LbServicesConfig.Builder();
getConfig(builder);
return ConfigPayload.fromInstance(new LbServicesConfig(builder));
} else {
throw new ConfigurationRuntimeException(configKey + " is not valid when asking for config from SuperModel");
}
}
public Map<ApplicationId, ApplicationInfo> applicationModels() { return superModel.getModels(); }
@Override
public void getConfig(LbServicesConfig.Builder builder) {
lbProd.getConfig(builder);
}
}
|