aboutsummaryrefslogtreecommitdiffstats
path: root/standalone-container/src
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-09-12 12:26:47 +0200
committerHarald Musum <musum@oath.com>2018-09-12 12:26:47 +0200
commitea54ce508fbddbeab3481193794aa843dd821d73 (patch)
tree7c96a12a57f318e473f6e3d8aed19805122a4e96 /standalone-container/src
parent7f00722a620ed17116253d61d89728e63bed2299 (diff)
Set hosted property if container is a config server
Diffstat (limited to 'standalone-container/src')
-rw-r--r--standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneContainerApplication.java35
1 files changed, 27 insertions, 8 deletions
diff --git a/standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneContainerApplication.java b/standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneContainerApplication.java
index d88245587d2..7ac4b64488a 100644
--- a/standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneContainerApplication.java
+++ b/standalone-container/src/main/java/com/yahoo/container/standalone/StandaloneContainerApplication.java
@@ -20,6 +20,7 @@ import com.yahoo.config.model.application.provider.FilesApplicationPackage;
import com.yahoo.config.model.application.provider.StaticConfigDefinitionRepo;
import com.yahoo.config.model.builder.xml.ConfigModelId;
import com.yahoo.config.model.builder.xml.XmlHelper;
+import com.yahoo.config.model.deploy.DeployProperties;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.provision.Zone;
import com.yahoo.container.di.config.SubscriberFactory;
@@ -209,17 +210,22 @@ public class StandaloneContainerApplication implements Application {
}
private static ContainerModelBuilder newContainerModelBuilder(Networking networkingOption) {
+ return isConfigServer() ?
+ new ConfigServerContainerModelBuilder(new CloudConfigInstallVariables()) :
+ new ContainerModelBuilder(true, networkingOption);
+ }
+
+ private static boolean isConfigServer() {
Optional<String> profile = optionalInstallVariable(DEPLOYMENT_PROFILE_INSTALL_VARIABLE);
if (profile.isPresent()) {
String profileName = profile.get();
- if ("configserver".equals(profileName)) {
- return new ConfigServerContainerModelBuilder(new CloudConfigInstallVariables());
- } else {
+ if (profileName.equals("configserver"))
+ return true;
+ else
throw new RuntimeException("Invalid deployment profile '" + profileName + "'");
- }
- } else {
- return new ContainerModelBuilder(true, networkingOption);
}
+
+ return false;
}
static Pair<VespaModel, Container> createContainerModel(Path applicationPath, FileRegistry fileRegistry,
@@ -229,8 +235,7 @@ public class StandaloneContainerApplication implements Application {
.includeSourceFiles(true).preprocessedDir(preprocessedApplicationDir).build();
ApplicationPackage applicationPackage = rawApplicationPackage.preprocess(Zone.defaultZone(), logger);
validateApplication(applicationPackage);
- DeployState deployState = new DeployState.Builder().applicationPackage(applicationPackage).fileRegistry(fileRegistry)
- .deployLogger(logger).configDefinitionRepo(configDefinitionRepo).build();
+ DeployState deployState = createDeployState(applicationPackage, fileRegistry, logger);
VespaModel root = VespaModel.createIncomplete(deployState);
ApplicationConfigProducerRoot vespaRoot = new ApplicationConfigProducerRoot(root, "vespa", deployState.getDocumentModel(),
@@ -252,6 +257,20 @@ public class StandaloneContainerApplication implements Application {
return new Pair<>(root, container);
}
+ private static DeployState createDeployState(ApplicationPackage applicationPackage, FileRegistry fileRegistry, DeployLogger logger) {
+ DeployState.Builder builder = new DeployState.Builder()
+ .applicationPackage(applicationPackage)
+ .fileRegistry(fileRegistry)
+ .deployLogger(logger)
+ .configDefinitionRepo(configDefinitionRepo);
+ if (isConfigServer())
+ builder.properties(new DeployProperties.Builder()
+ .hostedVespa(new CloudConfigInstallVariables().hostedVespa().orElse(Boolean.FALSE))
+ .build());
+
+ return builder.build();
+ }
+
private static void initializeContainer(Container container, Element spec) {
HostResource host = container.getRoot().getHostSystem().getHost(Container.SINGLENODE_CONTAINER_SERVICESPEC);