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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.deploy;
import com.yahoo.component.Version;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.config.application.api.FileRegistry;
import com.yahoo.config.model.api.ConfigDefinitionRepo;
import com.yahoo.config.model.api.ConfigServerSpec;
import com.yahoo.config.model.api.ContainerEndpoint;
import com.yahoo.config.model.api.HostProvisioner;
import com.yahoo.config.model.api.Model;
import com.yahoo.config.model.api.ModelContext;
import com.yahoo.config.model.api.EndpointCertificateSecrets;
import com.yahoo.config.model.api.TlsSecrets;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.flags.FetchVector;
import com.yahoo.vespa.flags.FlagSource;
import com.yahoo.vespa.flags.Flags;
import java.io.File;
import java.net.URI;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/**
* Implementation of {@link ModelContext} for configserver.
*
* @author Ulf Lilleengen
*/
public class ModelContextImpl implements ModelContext {
private final ApplicationPackage applicationPackage;
private final Optional<Model> previousModel;
private final Optional<ApplicationPackage> permanentApplicationPackage;
private final DeployLogger deployLogger;
private final ConfigDefinitionRepo configDefinitionRepo;
private final FileRegistry fileRegistry;
private final Optional<HostProvisioner> hostProvisioner;
private final ModelContext.Properties properties;
private final Optional<File> appDir;
/** The version of Vespa we are building a model for */
private final Version modelVespaVersion;
/**
* The Version of Vespa this model should specify that nodes should use. Note that this
* is separate from the version of this model, as upgrades are not immediate.
* We may build a config model of Vespa version "a" which specifies that nodes should
* use Vespa version "b". The "a" model will then be used by nodes who have not yet
* upgraded to version "b".
*/
private final Version wantedNodeVespaVersion;
public ModelContextImpl(ApplicationPackage applicationPackage,
Optional<Model> previousModel,
Optional<ApplicationPackage> permanentApplicationPackage,
DeployLogger deployLogger,
ConfigDefinitionRepo configDefinitionRepo,
FileRegistry fileRegistry,
Optional<HostProvisioner> hostProvisioner,
ModelContext.Properties properties,
Optional<File> appDir,
Version modelVespaVersion,
Version wantedNodeVespaVersion) {
this.applicationPackage = applicationPackage;
this.previousModel = previousModel;
this.permanentApplicationPackage = permanentApplicationPackage;
this.deployLogger = deployLogger;
this.configDefinitionRepo = configDefinitionRepo;
this.fileRegistry = fileRegistry;
this.hostProvisioner = hostProvisioner;
this.properties = properties;
this.appDir = appDir;
this.modelVespaVersion = modelVespaVersion;
this.wantedNodeVespaVersion = wantedNodeVespaVersion;
}
@Override
public ApplicationPackage applicationPackage() { return applicationPackage; }
@Override
public Optional<Model> previousModel() { return previousModel; }
@Override
public Optional<ApplicationPackage> permanentApplicationPackage() { return permanentApplicationPackage; }
/**
* Returns the host provisioner to use, or empty to use the default provisioner,
* creating hosts from the application package defined hosts
*/
// TODO: Don't allow empty here but create the right provisioner when this is set up instead
@Override
public Optional<HostProvisioner> hostProvisioner() { return hostProvisioner; }
@Override
public DeployLogger deployLogger() { return deployLogger; }
@Override
public ConfigDefinitionRepo configDefinitionRepo() { return configDefinitionRepo; }
@Override
public FileRegistry getFileRegistry() { return fileRegistry; }
@Override
public ModelContext.Properties properties() { return properties; }
@Override
public Optional<File> appDir() { return appDir; }
@Override
public Version modelVespaVersion() { return modelVespaVersion; }
@Override
public Version wantedNodeVespaVersion() { return wantedNodeVespaVersion; }
public static class Properties implements ModelContext.Properties {
private final ApplicationId applicationId;
private final boolean multitenant;
private final List<ConfigServerSpec> configServerSpecs;
private final HostName loadBalancerName;
private final URI ztsUrl;
private final String athenzDnsSuffix;
private final boolean hostedVespa;
private final Zone zone;
private final Set<ContainerEndpoint> endpoints;
private final boolean isBootstrap;
private final boolean isFirstTimeDeployment;
private final boolean useAdaptiveDispatch;
private final Optional<EndpointCertificateSecrets> endpointCertificateSecrets;
private final double defaultTermwiseLimit;
public Properties(ApplicationId applicationId,
boolean multitenantFromConfig,
List<ConfigServerSpec> configServerSpecs,
HostName loadBalancerName,
URI ztsUrl,
String athenzDnsSuffix,
boolean hostedVespa,
Zone zone,
Set<ContainerEndpoint> endpoints,
boolean isBootstrap,
boolean isFirstTimeDeployment,
FlagSource flagSource,
Optional<EndpointCertificateSecrets> endpointCertificateSecrets) {
this.applicationId = applicationId;
this.multitenant = multitenantFromConfig || hostedVespa || Boolean.getBoolean("multitenant");
this.configServerSpecs = configServerSpecs;
this.loadBalancerName = loadBalancerName;
this.ztsUrl = ztsUrl;
this.athenzDnsSuffix = athenzDnsSuffix;
this.hostedVespa = hostedVespa;
this.zone = zone;
this.endpoints = endpoints;
this.isBootstrap = isBootstrap;
this.isFirstTimeDeployment = isFirstTimeDeployment;
this.useAdaptiveDispatch = Flags.USE_ADAPTIVE_DISPATCH.bindTo(flagSource)
.with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value();
this.endpointCertificateSecrets = endpointCertificateSecrets;
defaultTermwiseLimit = Flags.DEFAULT_TERM_WISE_LIMIT.bindTo(flagSource)
.with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value();
}
@Override
public boolean multitenant() { return multitenant; }
@Override
public ApplicationId applicationId() { return applicationId; }
@Override
public List<ConfigServerSpec> configServerSpecs() { return configServerSpecs; }
@Override
public HostName loadBalancerName() { return loadBalancerName; }
@Override
public URI ztsUrl() {
return ztsUrl;
}
@Override
public String athenzDnsSuffix() {
return athenzDnsSuffix;
}
@Override
public boolean hostedVespa() { return hostedVespa; }
@Override
public Zone zone() { return zone; }
@Override
public Set<ContainerEndpoint> endpoints() { return endpoints; }
@Override
public boolean isBootstrap() { return isBootstrap; }
@Override
public boolean isFirstTimeDeployment() { return isFirstTimeDeployment; }
@Override
public boolean useAdaptiveDispatch() { return useAdaptiveDispatch; }
@Override
public Optional<TlsSecrets> tlsSecrets() { return endpointCertificateSecrets.map(TlsSecrets::new); }
@Override
public Optional<EndpointCertificateSecrets> endpointCertificateSecrets() { return endpointCertificateSecrets; }
@Override
public double defaultTermwiseLimit() { return defaultTermwiseLimit; }
// TODO: Remove
@Override
public boolean useBucketSpaceMetric() { return true; }
}
}
|