blob: 98cdc37147a554fb201685aeeec53e19d1e9ca78 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Copyright 2016 Yahoo Inc. 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.application.Xml;
import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.path.Path;
import com.yahoo.vespa.model.container.ContainerCluster;
import com.yahoo.vespa.model.container.ContainerModel;
import com.yahoo.vespa.model.container.configserver.option.CloudConfigOptions;
import com.yahoo.vespa.model.container.configserver.ConfigserverCluster;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import java.util.List;
/**
* Builds the config model for the standalone config server.
*
* @author lulf
* @since 5.16
*/
public class ConfigServerContainerModelBuilder extends ContainerModelBuilder {
private final CloudConfigOptions options;
private final static String HOSTED_VESPA_INCLUDE_DIR = "hosted-vespa";
public ConfigServerContainerModelBuilder(CloudConfigOptions options) {
super(true, Networking.enable);
this.options = options;
}
@Override
public void doBuild(ContainerModel model, Element spec, ConfigModelContext modelContext) {
ApplicationPackage app = modelContext.getDeployState().getApplicationPackage();
if ( ! app.getFiles(Path.fromString(HOSTED_VESPA_INCLUDE_DIR), ".xml").isEmpty()) {
app.validateIncludeDir(HOSTED_VESPA_INCLUDE_DIR);
List<Element> configModelElements = Xml.allElemsFromPath(app, HOSTED_VESPA_INCLUDE_DIR);
mergeInto(spec, configModelElements);
}
ConfigserverCluster cluster = new ConfigserverCluster(modelContext.getParentProducer(), "configserver", options);
super.doBuild(model, spec, modelContext.withParent(cluster));
cluster.setContainerCluster(model.getCluster());
}
private void mergeInto(Element destination, List<Element> configModelElements) {
for (Element jdiscElement: configModelElements) {
for (Node child = jdiscElement.getFirstChild(); child != null; child = child.getNextSibling()) {
Node copiedNode = destination.getOwnerDocument().importNode(child, true);
destination.appendChild(copiedNode);
}
}
}
@Override
protected void addDefaultComponents(ContainerCluster containerCluster) {
// To avoid search specific stuff.
}
@Override
protected void addDefaultHandlers(ContainerCluster containerCluster) {
addDefaultHandlersExceptStatus(containerCluster);
}
}
|