diff options
author | Jon Bratseth <bratseth@oath.com> | 2021-01-10 21:14:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-10 21:14:17 +0100 |
commit | 01c884d143d1f9ee996a56d58c8c539d087cd095 (patch) | |
tree | 70ded848fdd9d7925541f864b53a455899285497 | |
parent | 5efb6c3f8366993c07ce3248f1ecf1c44dad246e (diff) | |
parent | 70be87b26e60fe7b74e512fd0797b54c29b99c90 (diff) |
Merge pull request #15978 from vespa-engine/revert-15977-hmusum/remove-unnecessary-component
Revert "Remove unnecessary component"
12 files changed, 90 insertions, 31 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java index 454366e8fae..1eb18773898 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2017 Yahoo Holdings. 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; @@ -9,6 +9,7 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.secretstore.SecretStore; import com.yahoo.vespa.config.server.application.PermanentApplicationPackage; +import com.yahoo.vespa.config.server.host.HostRegistries; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.session.SessionPreparer; @@ -37,6 +38,7 @@ public interface GlobalComponentRegistry { ReloadListener getReloadListener(); ConfigDefinitionRepo getStaticConfigDefinitionRepo(); PermanentApplicationPackage getPermanentApplicationPackage(); + HostRegistries getHostRegistries(); ModelFactoryRegistry getModelFactoryRegistry(); Optional<Provisioner> getHostProvisioner(); Zone getZone(); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java index ce0641a7b47..9badd19009f 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server; import com.google.inject.Inject; @@ -11,6 +11,7 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.secretstore.SecretStore; import com.yahoo.vespa.config.server.application.PermanentApplicationPackage; +import com.yahoo.vespa.config.server.host.HostRegistries; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.provision.HostProvisionerProvider; @@ -43,6 +44,7 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry private final ConfigserverConfig configserverConfig; private final ConfigDefinitionRepo staticConfigDefinitionRepo; private final PermanentApplicationPackage permanentApplicationPackage; + private final HostRegistries hostRegistries; private final Optional<Provisioner> hostProvisioner; private final Zone zone; private final ConfigServerDB configServerDB; @@ -60,8 +62,10 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry SessionPreparer sessionPreparer, RpcServer rpcServer, ConfigserverConfig configserverConfig, + SuperModelGenerationCounter superModelGenerationCounter, ConfigDefinitionRepo staticConfigDefinitionRepo, PermanentApplicationPackage permanentApplicationPackage, + HostRegistries hostRegistries, HostProvisionerProvider hostProvisionerProvider, Zone zone, ConfigServerDB configServerDB, @@ -76,6 +80,7 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry this.configserverConfig = configserverConfig; this.staticConfigDefinitionRepo = staticConfigDefinitionRepo; this.permanentApplicationPackage = permanentApplicationPackage; + this.hostRegistries = hostRegistries; this.hostProvisioner = hostProvisionerProvider.getHostProvisioner(); this.zone = zone; this.configServerDB = configServerDB; @@ -104,6 +109,8 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry @Override public PermanentApplicationPackage getPermanentApplicationPackage() { return permanentApplicationPackage; } @Override + public HostRegistries getHostRegistries() { return hostRegistries; } + @Override public ModelFactoryRegistry getModelFactoryRegistry() { return modelFactoryRegistry; } @Override diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java index 2616f270bf8..5a34217dbdd 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java @@ -27,6 +27,7 @@ import com.yahoo.vespa.curator.Curator; import com.yahoo.vespa.curator.Lock; import com.yahoo.vespa.curator.transaction.CuratorTransaction; import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.recipes.cache.ChildData; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; import java.nio.file.Files; @@ -95,7 +96,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica componentRegistry.getMetrics(), componentRegistry.getReloadListener(), componentRegistry.getConfigserverConfig(), - new HostRegistry<>(), + componentRegistry.getHostRegistries().createApplicationHostRegistry(tenantName), new TenantFileSystemDirs(componentRegistry.getConfigServerDB(), tenantName), componentRegistry.getClock()); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistries.java b/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistries.java new file mode 100644 index 00000000000..c25ab0315a3 --- /dev/null +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistries.java @@ -0,0 +1,34 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.config.server.host; + +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.TenantName; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Component to hold host registries. + * + * @author hmusum + */ +public class HostRegistries { + + private final HostRegistry<TenantName> tenantHostRegistry = new HostRegistry<>(); + private final Map<TenantName, HostRegistry<ApplicationId>> applicationHostRegistries = new ConcurrentHashMap<>(); + + public HostRegistry<TenantName> getTenantHostRegistry() { + return tenantHostRegistry; + } + + public HostRegistry<ApplicationId> getApplicationHostRegistry(TenantName tenant) { + return applicationHostRegistries.get(tenant); + } + + public HostRegistry<ApplicationId> createApplicationHostRegistry(TenantName tenant) { + HostRegistry<ApplicationId> applicationIdHostRegistry = new HostRegistry<>(); + applicationHostRegistries.put(tenant, applicationIdHostRegistry); + return applicationIdHostRegistry; + } + +} diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java index 8e589537ced..e64859e7267 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java @@ -34,6 +34,7 @@ import com.yahoo.vespa.config.server.RequestHandler; import com.yahoo.vespa.config.server.SuperModelRequestHandler; import com.yahoo.vespa.config.server.application.ApplicationSet; import com.yahoo.vespa.config.server.filedistribution.FileServer; +import com.yahoo.vespa.config.server.host.HostRegistries; import com.yahoo.vespa.config.server.host.HostRegistry; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; import com.yahoo.vespa.config.server.monitoring.MetricUpdaterFactory; @@ -121,7 +122,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { */ @Inject public RpcServer(ConfigserverConfig config, SuperModelRequestHandler superModelRequestHandler, - MetricUpdaterFactory metrics, HostRegistry<TenantName> hostRegistry, + MetricUpdaterFactory metrics, HostRegistries hostRegistries, HostLivenessTracker hostLivenessTracker, FileServer fileServer, RpcAuthorizer rpcAuthorizer, RpcRequestHandlerProvider handlerProvider) { this.superModelRequestHandler = superModelRequestHandler; @@ -135,7 +136,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { 0, TimeUnit.SECONDS, workQueue, ThreadFactoryFactory.getDaemonThreadFactory(THREADPOOL_NAME)); delayedConfigResponses = new DelayedConfigResponses(this, config.numDelayedResponseThreads()); spec = new Spec(null, config.rpcport()); - this.hostRegistry = hostRegistry; + hostRegistry = hostRegistries.getTenantHostRegistry(); this.useRequestVersion = config.useVespaVersionInRequest(); this.hostedVespa = config.hostedVespa(); this.canReturnEmptySentinelConfig = config.canReturnEmptySentinelConfig(); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/DefaultRpcAuthorizerProvider.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/DefaultRpcAuthorizerProvider.java index 5e2eb56c542..8d1d4f58e37 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/DefaultRpcAuthorizerProvider.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/DefaultRpcAuthorizerProvider.java @@ -1,13 +1,12 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.rpc.security; import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; -import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.security.NodeIdentifier; import com.yahoo.container.di.componentgraph.Provider; import com.yahoo.security.tls.TransportSecurityUtils; -import com.yahoo.vespa.config.server.host.HostRegistry; +import com.yahoo.vespa.config.server.host.HostRegistries; import com.yahoo.vespa.config.server.rpc.RequestHandlerProvider; /** @@ -22,13 +21,13 @@ public class DefaultRpcAuthorizerProvider implements Provider<RpcAuthorizer> { @Inject public DefaultRpcAuthorizerProvider(ConfigserverConfig config, NodeIdentifier nodeIdentifier, - HostRegistry<TenantName> hostRegistry, + HostRegistries hostRegistries, RequestHandlerProvider handlerProvider) { boolean useMultiTenantAuthorizer = TransportSecurityUtils.isTransportSecurityEnabled() && config.multitenant() && config.hostedVespa(); this.rpcAuthorizer = useMultiTenantAuthorizer - ? new MultiTenantRpcAuthorizer(nodeIdentifier, hostRegistry, handlerProvider, getThreadPoolSize(config)) + ? new MultiTenantRpcAuthorizer(nodeIdentifier, hostRegistries, handlerProvider, getThreadPoolSize(config)) : new NoopRpcAuthorizer(); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizer.java index 9e2ea0b34c3..49a8df3d0e4 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizer.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.rpc.security; import com.yahoo.cloud.config.SentinelConfig; @@ -16,6 +16,7 @@ import com.yahoo.security.tls.TransportSecurityUtils; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3; import com.yahoo.vespa.config.server.RequestHandler; +import com.yahoo.vespa.config.server.host.HostRegistries; import com.yahoo.vespa.config.server.host.HostRegistry; import com.yahoo.vespa.config.server.rpc.RequestHandlerProvider; @@ -33,6 +34,7 @@ import java.util.logging.Logger; import static com.yahoo.vespa.config.server.rpc.security.AuthorizationException.Type; import static com.yahoo.yolean.Exceptions.throwUnchecked; + /** * A {@link RpcAuthorizer} that perform access control for configserver RPC methods when TLS and multi-tenant mode are enabled. * @@ -48,11 +50,11 @@ public class MultiTenantRpcAuthorizer implements RpcAuthorizer { private final Executor executor; public MultiTenantRpcAuthorizer(NodeIdentifier nodeIdentifier, - HostRegistry<TenantName> hostRegistry, + HostRegistries hostRegistries, RequestHandlerProvider handlerProvider, int threadPoolSize) { this(nodeIdentifier, - hostRegistry, + hostRegistries.getTenantHostRegistry(), handlerProvider, Executors.newFixedThreadPool(threadPoolSize, new DaemonThreadFactory("multi-tenant-rpc-authorizer-"))); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java index 471b1b15920..5c15b72eaac 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.tenant; import com.google.common.collect.ImmutableSet; @@ -14,7 +14,6 @@ import com.yahoo.transaction.Transaction; import com.yahoo.vespa.config.server.GlobalComponentRegistry; import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; -import com.yahoo.vespa.config.server.host.HostRegistry; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; import com.yahoo.vespa.config.server.session.SessionRepository; import com.yahoo.vespa.curator.Curator; @@ -229,7 +228,7 @@ public class TenantRepository { componentRegistry.getMetrics(), componentRegistry.getReloadListener(), componentRegistry.getConfigserverConfig(), - new HostRegistry<>(), + componentRegistry.getHostRegistries().createApplicationHostRegistry(tenantName), new TenantFileSystemDirs(componentRegistry.getConfigServerDB(), tenantName), componentRegistry.getClock()); SessionRepository sessionRepository = new SessionRepository(tenantName, diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java index 2be18674e44..bf54c2b309e 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java @@ -8,12 +8,12 @@ import com.yahoo.config.provision.Zone; import com.yahoo.vespa.config.server.application.PermanentApplicationPackage; import com.yahoo.vespa.config.server.filedistribution.FileServer; import com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker; -import com.yahoo.vespa.config.server.host.HostRegistry; +import com.yahoo.vespa.config.server.host.HostRegistries; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.provision.HostProvisionerProvider; -import com.yahoo.vespa.config.server.rpc.RpcRequestHandlerProvider; import com.yahoo.vespa.config.server.rpc.RpcServer; +import com.yahoo.vespa.config.server.rpc.RpcRequestHandlerProvider; import com.yahoo.vespa.config.server.rpc.security.NoopRpcAuthorizer; import com.yahoo.vespa.config.server.session.SessionPreparer; import com.yahoo.vespa.config.server.session.SessionTest; @@ -46,6 +46,7 @@ public class InjectedGlobalComponentRegistryTest { private RpcServer rpcServer; private ConfigDefinitionRepo defRepo; private PermanentApplicationPackage permanentApplicationPackage; + private HostRegistries hostRegistries; private GlobalComponentRegistry globalComponentRegistry; private ModelFactoryRegistry modelFactoryRegistry; private Zone zone; @@ -65,16 +66,18 @@ public class InjectedGlobalComponentRegistryTest { .configDefinitionsDir(temporaryFolder.newFolder("configdefinitions").getAbsolutePath())); sessionPreparer = new SessionTest.MockSessionPreparer(); rpcServer = new RpcServer(configserverConfig, null, Metrics.createTestMetrics(), - new HostRegistry<>(), new ConfigRequestHostLivenessTracker(), + new HostRegistries(), new ConfigRequestHostLivenessTracker(), new FileServer(temporaryFolder.newFolder("filereferences")), new NoopRpcAuthorizer(), new RpcRequestHandlerProvider()); + SuperModelGenerationCounter generationCounter = new SuperModelGenerationCounter(curator); defRepo = new StaticConfigDefinitionRepo(); permanentApplicationPackage = new PermanentApplicationPackage(configserverConfig); + hostRegistries = new HostRegistries(); HostProvisionerProvider hostProvisionerProvider = HostProvisionerProvider.withProvisioner(new MockProvisioner()); zone = Zone.defaultZone(); globalComponentRegistry = new InjectedGlobalComponentRegistry(curator, configCurator, metrics, modelFactoryRegistry, sessionPreparer, rpcServer, configserverConfig, - defRepo, permanentApplicationPackage, hostProvisionerProvider, zone, + generationCounter, defRepo, permanentApplicationPackage, hostRegistries, hostProvisionerProvider, zone, new ConfigServerDB(configserverConfig), new InMemoryFlagSource(), new MockSecretStore()); } @@ -89,6 +92,7 @@ public class InjectedGlobalComponentRegistryTest { assertThat(globalComponentRegistry.getTenantListener().hashCode(), is(rpcServer.hashCode())); assertThat(globalComponentRegistry.getStaticConfigDefinitionRepo(), is(defRepo)); assertThat(globalComponentRegistry.getPermanentApplicationPackage(), is(permanentApplicationPackage)); + assertThat(globalComponentRegistry.getHostRegistries(), is(hostRegistries)); assertThat(globalComponentRegistry.getZone(), is (zone)); assertTrue(globalComponentRegistry.getHostProvisioner().isPresent()); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java index 3bc68533d02..e6652c3c5e1 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2017 Yahoo Holdings. 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; @@ -12,11 +12,12 @@ import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.secretstore.SecretStore; import com.yahoo.vespa.config.server.application.PermanentApplicationPackage; import com.yahoo.vespa.config.server.application.TenantApplicationsTest; -import com.yahoo.vespa.config.server.filedistribution.FileDistributionFactory; -import com.yahoo.vespa.config.server.filedistribution.MockFileDistributionFactory; +import com.yahoo.vespa.config.server.host.HostRegistries; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.provision.HostProvisionerProvider; +import com.yahoo.vespa.config.server.filedistribution.FileDistributionFactory; +import com.yahoo.vespa.config.server.filedistribution.MockFileDistributionFactory; import com.yahoo.vespa.config.server.session.SessionPreparer; import com.yahoo.vespa.config.server.tenant.MockTenantListener; import com.yahoo.vespa.config.server.tenant.TenantListener; @@ -49,6 +50,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private final ReloadListener reloadListener; private final TenantListener tenantListener; private final PermanentApplicationPackage permanentApplicationPackage; + private final HostRegistries hostRegistries; private final FileDistributionFactory fileDistributionFactory; private final ModelFactoryRegistry modelFactoryRegistry; private final Optional<Provisioner> hostProvisioner; @@ -64,6 +66,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { ModelFactoryRegistry modelFactoryRegistry, PermanentApplicationPackage permanentApplicationPackage, FileDistributionFactory fileDistributionFactory, + HostRegistries hostRegistries, ConfigserverConfig configserverConfig, SessionPreparer sessionPreparer, Optional<Provisioner> hostProvisioner, @@ -82,6 +85,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { this.tenantListener = tenantListener; this.defRepo = defRepo; this.permanentApplicationPackage = permanentApplicationPackage; + this.hostRegistries = hostRegistries; this.fileDistributionFactory = fileDistributionFactory; this.modelFactoryRegistry = modelFactoryRegistry; this.hostProvisioner = hostProvisioner; @@ -108,6 +112,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private ReloadListener reloadListener = new TenantApplicationsTest.MockReloadListener(); private final MockTenantListener tenantListener = new MockTenantListener(); private Optional<PermanentApplicationPackage> permanentApplicationPackage = Optional.empty(); + private final HostRegistries hostRegistries = new HostRegistries(); private final Optional<FileDistributionFactory> fileDistributionFactory = Optional.empty(); private ModelFactoryRegistry modelFactoryRegistry = new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry()))); private Optional<Provisioner> hostProvisioner = Optional.empty(); @@ -183,7 +188,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { configserverConfig, defRepo, curator, zone, flagSource, secretStore); return new TestComponentRegistry(curator, ConfigCurator.create(curator), metrics, modelFactoryRegistry, - permApp, fileDistributionProvider, configserverConfig, + permApp, fileDistributionProvider, hostRegistries, configserverConfig, sessionPreparer, hostProvisioner, defRepo, reloadListener, tenantListener, zone, clock, secretStore, flagSource); } @@ -208,6 +213,8 @@ public class TestComponentRegistry implements GlobalComponentRegistry { @Override public PermanentApplicationPackage getPermanentApplicationPackage() { return permanentApplicationPackage; } @Override + public HostRegistries getHostRegistries() { return hostRegistries;} + @Override public ModelFactoryRegistry getModelFactoryRegistry() { return modelFactoryRegistry; } @Override public Optional<Provisioner> getHostProvisioner() { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpcServer.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpcServer.java index 6db2e8006ed..7f4733f0b7c 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpcServer.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpcServer.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.rpc; import com.yahoo.cloud.config.ConfigserverConfig; @@ -8,7 +8,7 @@ import com.yahoo.vespa.config.protocol.JRTServerConfigRequest; import com.yahoo.vespa.config.server.GetConfigContext; import com.yahoo.vespa.config.server.filedistribution.FileServer; import com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker; -import com.yahoo.vespa.config.server.host.HostRegistry; +import com.yahoo.vespa.config.server.host.HostRegistries; import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.rpc.security.NoopRpcAuthorizer; @@ -37,7 +37,7 @@ public class MockRpcServer extends RpcServer { super(createConfig(port), null, Metrics.createTestMetrics(), - new HostRegistry<>(), + new HostRegistries(), new ConfigRequestHostLivenessTracker(), new FileServer(tempDir), new NoopRpcAuthorizer(), diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java index c044978ab42..2b2ed13fcfe 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java @@ -24,7 +24,7 @@ import com.yahoo.vespa.config.server.TestConfigDefinitionRepo; import com.yahoo.vespa.config.server.application.OrchestratorMock; import com.yahoo.vespa.config.server.filedistribution.FileServer; import com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker; -import com.yahoo.vespa.config.server.host.HostRegistry; +import com.yahoo.vespa.config.server.host.HostRegistries; import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.rpc.security.NoopRpcAuthorizer; import com.yahoo.vespa.config.server.tenant.Tenant; @@ -61,6 +61,7 @@ public class RpcTester implements AutoCloseable { private RpcServer rpcServer; private Thread t; private Supervisor sup; + private final ApplicationId applicationId; private final TenantName tenantName; private final TenantRepository tenantRepository; @@ -75,6 +76,7 @@ public class RpcTester implements AutoCloseable { RpcTester(ApplicationId applicationId, TemporaryFolder temporaryFolder, ConfigserverConfig.Builder configBuilder) throws InterruptedException, IOException { this.temporaryFolder = temporaryFolder; + this.applicationId = applicationId; this.tenantName = applicationId.tenant(); int port = allocatePort(); spec = createSpec(port); @@ -112,8 +114,9 @@ public class RpcTester implements AutoCloseable { } void createAndStartRpcServer() throws IOException { - HostRegistry<TenantName> hostRegistry = new HostRegistry<>(); - hostRegistry.update(tenantName, List.of("localhost")); + HostRegistries hostRegistries = new HostRegistries(); + hostRegistries.createApplicationHostRegistry(tenantName).update(applicationId, List.of("localhost")); + hostRegistries.getTenantHostRegistry().update(tenantName, List.of("localhost")); rpcServer = new RpcServer(configserverConfig, new SuperModelRequestHandler(new TestConfigDefinitionRepo(), configserverConfig, @@ -123,7 +126,7 @@ public class RpcTester implements AutoCloseable { generationCounter, new InMemoryFlagSource())), Metrics.createTestMetrics(), - hostRegistry, + hostRegistries, hostLivenessTracker, new FileServer(temporaryFolder.newFolder()), new NoopRpcAuthorizer(), |