diff options
author | Valerij Fredriksen <valerij92@gmail.com> | 2019-06-01 19:10:39 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerijf@verizonmedia.com> | 2019-06-03 21:09:45 +0200 |
commit | 8587e088b0f1fda759fb1a394f15f9f0aa415e06 (patch) | |
tree | 8e1bcf13894c278cc1b9f6610e9b897eaac4563e /service-monitor | |
parent | 0a69e56037309cec06cd39e0b466fc0944d41fee (diff) |
Make tenant host application supported in DuperModel with feature flag
Diffstat (limited to 'service-monitor')
-rw-r--r-- | service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java | 25 | ||||
-rw-r--r-- | service-monitor/src/main/java/com/yahoo/vespa/service/duper/TenantHostApplication.java | 10 |
2 files changed, 30 insertions, 5 deletions
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java index c9cd4528bec..eb90b2f56d7 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java @@ -9,7 +9,10 @@ import com.yahoo.config.model.api.SuperModelListener; import com.yahoo.config.model.api.SuperModelProvider; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.HostName; +import com.yahoo.config.provision.NodeType; +import com.yahoo.vespa.flags.BooleanFlag; import com.yahoo.vespa.flags.FlagSource; +import com.yahoo.vespa.flags.Flags; import com.yahoo.vespa.service.monitor.DuperModelInfraApi; import com.yahoo.vespa.service.monitor.InfraApplicationApi; @@ -34,14 +37,18 @@ public class DuperModelManager implements DuperModelInfraApi { static final ConfigServerHostApplication configServerHostApplication = new ConfigServerHostApplication(); static final ConfigServerApplication configServerApplication = new ConfigServerApplication(); static final ProxyHostApplication proxyHostApplication = new ProxyHostApplication(); + static final TenantHostApplication tenantHostApplication = new TenantHostApplication(); private final Map<ApplicationId, InfraApplication> supportedInfraApplications; + private final Map<ApplicationId, InfraApplication> supportedMinusTenantHostInfraApplications; private final Object monitor = new Object(); private final DuperModel duperModel; // The set of active infrastructure ApplicationInfo. Not all are necessarily in the DuperModel for historical reasons. private final Set<ApplicationId> activeInfraInfos = new HashSet<>(10); + private final BooleanFlag tenantHostApplicationEnabled; + @Inject public DuperModelManager(ConfigserverConfig configServerConfig, FlagSource flagSource, SuperModelProvider superModelProvider) { this(configServerConfig.multitenant(), @@ -52,16 +59,20 @@ public class DuperModelManager implements DuperModelInfraApi { /** For testing */ DuperModelManager(boolean multitenant, boolean isController, SuperModelProvider superModelProvider, DuperModel duperModel, FlagSource flagSource) { this.duperModel = duperModel; + this.tenantHostApplicationEnabled = Flags.ENABLE_TENANT_HOST_APP.bindTo(flagSource); if (multitenant) { supportedInfraApplications = (isController ? Stream.of(controllerHostApplication, controllerApplication) : - Stream.of(configServerHostApplication, configServerApplication, proxyHostApplication) + Stream.of(configServerHostApplication, configServerApplication, proxyHostApplication, tenantHostApplication) ).collect(Collectors.toUnmodifiableMap(InfraApplication::getApplicationId, Function.identity())); } else { supportedInfraApplications = Map.of(); } + supportedMinusTenantHostInfraApplications = supportedInfraApplications.entrySet().stream() + .filter(app -> app.getValue().getCapacity().type() != NodeType.host) + .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue)); superModelProvider.registerListener(new SuperModelListener() { @Override @@ -92,19 +103,23 @@ public class DuperModelManager implements DuperModelInfraApi { @Override public List<InfraApplicationApi> getSupportedInfraApplications() { - return new ArrayList<>(supportedInfraApplications.values()); + return new ArrayList<>(getSupportedApps().values()); } @Override public Optional<InfraApplicationApi> getInfraApplication(ApplicationId applicationId) { - return Optional.ofNullable(supportedInfraApplications.get(applicationId)); + return Optional.ofNullable(getSupportedApps().get(applicationId)); + } + + private Map<ApplicationId, InfraApplication> getSupportedApps() { + return tenantHostApplicationEnabled.value() ? supportedInfraApplications : supportedMinusTenantHostInfraApplications; } /** * Returns true if application is considered an infrastructure application by the DuperModel. * - * <p>Note: The tenant host "application" is NOT considered an infrastructure application: It is just a - * cluster in the {@link ZoneApplication zone application}. + * <p>Note: Unless enable-tenant-host-app flag is enabled, the tenant host "application" is NOT considered an + * infrastructure application: It is just a cluster in the {@link ZoneApplication zone application}. */ public boolean isSupportedInfraApplication(ApplicationId applicationId) { return supportedInfraApplications.containsKey(applicationId); diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/TenantHostApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/TenantHostApplication.java new file mode 100644 index 00000000000..ee6ac94cba2 --- /dev/null +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/TenantHostApplication.java @@ -0,0 +1,10 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.service.duper; + +import com.yahoo.config.provision.NodeType; + +public class TenantHostApplication extends HostAdminApplication { + public TenantHostApplication() { + super("tenant-host", NodeType.host); + } +} |