diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-11-06 13:51:06 +0100 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2020-11-06 13:51:06 +0100 |
commit | 14e371e3ff8bc4392e8b2cfc28d6c7d093ad3eea (patch) | |
tree | 857cbc5c5bdef359b83342b810d98999e3dcdc3d | |
parent | 58b015f069738f90f6f01b9c728f831d13dfc4f2 (diff) |
Simplify
4 files changed, 23 insertions, 43 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java index 6fb17e7cb72..536d75a9b94 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java @@ -1,6 +1,7 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. 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.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; @@ -195,12 +196,7 @@ public class ModelContextImpl implements ModelContext { private final int mergeChunkSize; public Properties(ApplicationId applicationId, - boolean multitenantFromConfig, - List<ConfigServerSpec> configServerSpecs, - HostName loadBalancerName, - URI ztsUrl, - String athenzDnsSuffix, - boolean hostedVespa, + ConfigserverConfig configserverConfig, Zone zone, Set<ContainerEndpoint> endpoints, boolean isBootstrap, @@ -212,12 +208,12 @@ public class ModelContextImpl implements ModelContext { Optional<Quota> maybeQuota) { this.featureFlags = new FeatureFlags(flagSource, applicationId); 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.multitenant = configserverConfig.multitenant() || configserverConfig.hostedVespa() || Boolean.getBoolean("multitenant"); + this.configServerSpecs = com.yahoo.vespa.config.server.ConfigServerSpec.fromConfig(configserverConfig); + this.loadBalancerName = HostName.from(configserverConfig.loadBalancerAddress()); + this.ztsUrl = configserverConfig.ztsUrl() != null ? URI.create(configserverConfig.ztsUrl()) : null; + this.athenzDnsSuffix = configserverConfig.athenzDnsSuffix(); + this.hostedVespa = configserverConfig.hostedVespa(); this.zone = zone; this.endpoints = endpoints; this.isBootstrap = isBootstrap; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java index acdea54edbc..a3a8bba567a 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.modelfactory; import com.google.common.collect.ImmutableSet; @@ -12,10 +12,8 @@ import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.DockerImage; -import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.TenantName; import com.yahoo.container.jdisc.secretstore.SecretStore; -import com.yahoo.vespa.config.server.ConfigServerSpec; import com.yahoo.vespa.config.server.GlobalComponentRegistry; import com.yahoo.vespa.config.server.ServerCache; import com.yahoo.vespa.config.server.application.Application; @@ -35,7 +33,6 @@ import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.curator.Curator; import com.yahoo.vespa.flags.FlagSource; -import java.net.URI; import java.util.Map; import java.util.Optional; import java.util.logging.Level; @@ -132,12 +129,7 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> { private ModelContext.Properties createModelContextProperties(ApplicationId applicationId) { return new ModelContextImpl.Properties(applicationId, - configserverConfig.multitenant(), - ConfigServerSpec.fromConfig(configserverConfig), - HostName.from(configserverConfig.loadBalancerAddress()), - configserverConfig.ztsUrl() != null ? URI.create(configserverConfig.ztsUrl()) : null, - configserverConfig.athenzDnsSuffix(), - configserverConfig.hostedVespa(), + configserverConfig, zone(), ImmutableSet.copyOf(new ContainerEndpointsCache(TenantRepository.getTenantPath(tenant), curator).read(applicationId)), false, // We may be bootstrapping, but we only know and care during prepare @@ -150,7 +142,6 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> { new ApplicationRolesStore(curator, TenantRepository.getTenantPath(tenant)) .readApplicationRoles(applicationId), zkClient.readQuota()); - } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java index 941f52d0830..9b82cafcb49 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; import com.google.common.collect.ImmutableList; @@ -23,14 +23,11 @@ import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.AthenzDomain; import com.yahoo.config.provision.DockerImage; -import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.secretstore.SecretStore; import com.yahoo.lang.SettableOptional; import com.yahoo.path.Path; -import com.yahoo.vespa.config.server.ConfigServerSpec; import com.yahoo.vespa.config.server.TimeoutBudget; -import com.yahoo.vespa.config.server.application.ApplicationCuratorDatabase; import com.yahoo.vespa.config.server.application.ApplicationSet; import com.yahoo.vespa.config.server.application.PermanentApplicationPackage; import com.yahoo.vespa.config.server.configchange.ConfigChangeActions; @@ -57,7 +54,6 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import java.io.File; import java.io.IOException; -import java.net.URI; import java.time.Instant; import java.util.Collection; import java.util.List; @@ -202,19 +198,15 @@ public class SessionPreparer { this.applicationRoles = params.applicationRoles() .or(() -> applicationRolesStore.readApplicationRoles(applicationId)); this.properties = new ModelContextImpl.Properties(params.getApplicationId(), - configserverConfig.multitenant(), - ConfigServerSpec.fromConfig(configserverConfig), - HostName.from(configserverConfig.loadBalancerAddress()), - configserverConfig.ztsUrl() != null ? URI.create(configserverConfig.ztsUrl()) : null, - configserverConfig.athenzDnsSuffix(), - configserverConfig.hostedVespa(), + configserverConfig, zone, Set.copyOf(containerEndpoints), params.isBootstrap(), currentActiveApplicationSet.isEmpty(), flagSource, endpointCertificateSecrets, - athenzDomain, applicationRoles, + athenzDomain, + applicationRoles, params.quota()); this.fileDistributionProvider = fileDistributionFactory.createProvider(serverDbSessionDir); this.preparedModelsBuilder = new PreparedModelsBuilder(modelFactoryRegistry, diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java index 120736fba51..a86a6cb2a96 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java @@ -1,6 +1,7 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server; +import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; import com.yahoo.config.model.api.ContainerEndpoint; import com.yahoo.config.model.api.ModelContext; @@ -39,6 +40,11 @@ public class ModelContextImplTest { Set<ContainerEndpoint> endpoints = Collections.singleton(endpoint); InMemoryFlagSource flagSource = new InMemoryFlagSource(); + ConfigserverConfig configserverConfig = new ConfigserverConfig.Builder() + .multitenant(true) + .hostedVespa(false) + .build(); + ModelContext context = new ModelContextImpl( MockApplicationPackage.createEmpty(), Optional.empty(), @@ -51,12 +57,7 @@ public class ModelContextImplTest { new Provisioned(), new ModelContextImpl.Properties( ApplicationId.defaultId(), - true, - Collections.emptyList(), - null, - null, - null, - false, + configserverConfig, Zone.defaultZone(), endpoints, false, |