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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.xml;
import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.container.logging.FileConnectionLog;
import com.yahoo.vespa.model.container.ApplicationContainerCluster;
import com.yahoo.vespa.model.container.ContainerModel;
import com.yahoo.vespa.model.container.component.AccessLogComponent;
import com.yahoo.vespa.model.container.component.ConnectionLogComponent;
import com.yahoo.vespa.model.container.configserver.ConfigserverCluster;
import com.yahoo.vespa.model.container.configserver.option.CloudConfigOptions;
import org.w3c.dom.Element;
/**
* Builds the config model for the standalone config server.
*
* @author Ulf Lilleengen
*/
public class ConfigServerContainerModelBuilder extends ContainerModelBuilder {
private final CloudConfigOptions options;
public ConfigServerContainerModelBuilder(CloudConfigOptions options) {
super(true, Networking.enable);
this.options = options;
}
@Override
public void doBuild(ContainerModel model, Element spec, ConfigModelContext modelContext) {
ConfigserverCluster cluster = new ConfigserverCluster(modelContext.getParentProducer(), "configserver",
options);
super.doBuild(model, spec, modelContext.withParent(cluster));
cluster.setContainerCluster(model.getCluster());
}
// Need to override this method since we need to use the values in CloudConfigOptions (the ones
// in ConfigModelContext.DeployState.properties are not set)
@Override
protected void addStatusHandlers(ApplicationContainerCluster cluster, boolean isHostedVespa) {
super.addStatusHandlers(cluster, isHosted());
}
// Override access log configuration for hosted configserver/controller
@Override
protected void addAccessLogs(DeployState deployState, ApplicationContainerCluster cluster, Element spec) {
if (isHosted()){
cluster.addComponent(
new AccessLogComponent(
AccessLogComponent.AccessLogType.jsonAccessLog, "zstd",
"logs/vespa/configserver/access-json.log.%Y%m%d%H%M%S", null, true, true, "access-json.log", 1024,256*1024));
cluster.addComponent(new ConnectionLogComponent(cluster, FileConnectionLog.class, "configserver"));
} else {
super.addAccessLogs(deployState, cluster, spec);
}
}
@Override
protected void addHttp(DeployState deployState, Element spec, ApplicationContainerCluster cluster, ConfigModelContext context) {
super.addHttp(deployState, spec, cluster, context);
cluster.getHttp().getHttpServer().get().setHostedVespa(isHosted());
}
@Override
protected void addModelEvaluationRuntime(ApplicationContainerCluster cluster) {
// Model evaluation bundles are pre-installed in the standalone container.
}
/** Note: using {@link CloudConfigOptions} as {@link DeployState#isHosted()} returns <em>false</em> for hosted configserver/controller */
private boolean isHosted() { return options.hostedVespa().orElse(Boolean.FALSE); }
}
|