diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-01-14 20:55:17 +0100 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2021-01-14 20:55:17 +0100 |
commit | 9417d760a664cdcc502223198c75226d852fc044 (patch) | |
tree | eeb97ed44d1261643b1775da730af38f279e3899 /configserver | |
parent | edf46fe1de4cd593f75f9e993b210de51d6c2545 (diff) |
Move zkWatcherExecutor out of GlobalComponentRegistry
Diffstat (limited to 'configserver')
12 files changed, 63 insertions, 44 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 01a0545dc31..b08d6d25ea9 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 @@ -2,15 +2,12 @@ package com.yahoo.vespa.config.server; import com.yahoo.cloud.config.ConfigserverConfig; -import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.model.api.ConfigDefinitionRepo; import com.yahoo.config.provision.Provisioner; -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.modelfactory.ModelFactoryRegistry; -import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.session.SessionPreparer; import com.yahoo.vespa.config.server.tenant.TenantListener; import com.yahoo.vespa.flags.FlagSource; @@ -37,7 +34,6 @@ public interface GlobalComponentRegistry { Zone getZone(); Clock getClock(); ConfigServerDB getConfigServerDB(); - StripedExecutor<TenantName> getZkWatcherExecutor(); FlagSource getFlagSource(); ExecutorService getZkCacheExecutor(); SecretStore getSecretStore(); 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 a272af69e0a..8ebc84d8fd4 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 @@ -3,11 +3,9 @@ package com.yahoo.vespa.config.server; import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; -import com.yahoo.concurrent.StripedExecutor; import com.yahoo.concurrent.ThreadFactoryFactory; import com.yahoo.config.model.api.ConfigDefinitionRepo; import com.yahoo.config.provision.Provisioner; -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; @@ -42,7 +40,6 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry private final ConfigServerDB configServerDB; private final FlagSource flagSource; private final SecretStore secretStore; - private final StripedExecutor<TenantName> zkWatcherExecutor; private final ExecutorService zkCacheExecutor; @SuppressWarnings("WeakerAccess") @@ -69,7 +66,6 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry this.configServerDB = configServerDB; this.flagSource = flagSource; this.secretStore = secretStore; - this.zkWatcherExecutor = new StripedExecutor<>(); this.zkCacheExecutor = Executors.newFixedThreadPool(1, ThreadFactoryFactory.getThreadFactory(TenantRepository.class.getName())); } @@ -105,11 +101,6 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry public ConfigServerDB getConfigServerDB() { return configServerDB; } @Override - public StripedExecutor<TenantName> getZkWatcherExecutor() { - return zkWatcherExecutor; - } - - @Override public FlagSource getFlagSource() { return flagSource; } @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 786f59925b5..34e199e388b 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 @@ -3,6 +3,7 @@ package com.yahoo.vespa.config.server.application; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; +import com.yahoo.concurrent.InThreadExecutorService; import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.FileReference; import com.yahoo.config.provision.ApplicationId; @@ -93,7 +94,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica Curator curator) { return new TenantApplications(tenantName, curator, - componentRegistry.getZkWatcherExecutor(), + new StripedExecutor<>(new InThreadExecutorService()), componentRegistry.getZkCacheExecutor(), Metrics.createTestMetrics(), componentRegistry.getReloadListener(), diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java index 4fc0a52ff9b..be048633bca 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java @@ -3,6 +3,7 @@ package com.yahoo.vespa.config.server.session; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; +import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.FileReference; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; @@ -98,7 +99,8 @@ public class SessionRepository { TenantApplications applicationRepo, SessionPreparer sessionPreparer, Curator curator, - Metrics metrics) { + Metrics metrics, + StripedExecutor<TenantName> zkWatcherExecutor) { this.tenantName = tenantName; this.componentRegistry = componentRegistry; this.configCurator = ConfigCurator.create(curator); @@ -107,7 +109,7 @@ public class SessionRepository { this.clock = componentRegistry.getClock(); this.curator = curator; this.sessionLifetime = Duration.ofSeconds(componentRegistry.getConfigserverConfig().sessionLifetime()); - this.zkWatcherExecutor = command -> componentRegistry.getZkWatcherExecutor().execute(tenantName, command); + this.zkWatcherExecutor = command -> zkWatcherExecutor.execute(tenantName, command); this.tenantFileSystemDirs = new TenantFileSystemDirs(componentRegistry.getConfigServerDB(), tenantName); this.applicationRepo = applicationRepo; this.sessionPreparer = sessionPreparer; 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 3bd40c6b01d..305157524d6 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 @@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableSet; import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.concurrent.DaemonThreadFactory; +import com.yahoo.concurrent.InThreadExecutorService; import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; @@ -102,7 +103,8 @@ public class TenantRepository { public TenantRepository(GlobalComponentRegistry componentRegistry, HostRegistry hostRegistry, Curator curator, - Metrics metrics) { + Metrics metrics, + StripedExecutor<TenantName> zkWatcherExecutor) { this.componentRegistry = componentRegistry; this.hostRegistry = hostRegistry; ConfigserverConfig configserverConfig = componentRegistry.getConfigserverConfig(); @@ -113,7 +115,7 @@ public class TenantRepository { metricUpdater = metrics.getOrCreateMetricUpdater(Collections.emptyMap()); this.tenantListeners.add(componentRegistry.getTenantListener()); this.zkCacheExecutor = componentRegistry.getZkCacheExecutor(); - this.zkWatcherExecutor = componentRegistry.getZkWatcherExecutor(); + this.zkWatcherExecutor = zkWatcherExecutor; curator.framework().getConnectionStateListenable().addListener(this::stateChanged); curator.create(tenantsPath); @@ -140,7 +142,11 @@ public class TenantRepository { // For testing only public TenantRepository(GlobalComponentRegistry componentRegistry, HostRegistry hostRegistry) { - this(componentRegistry, hostRegistry, new MockCurator(), Metrics.createTestMetrics()); + this(componentRegistry, + hostRegistry, + new MockCurator(), + Metrics.createTestMetrics(), + new StripedExecutor<>(new InThreadExecutorService())); } private void notifyTenantsLoaded() { @@ -243,7 +249,7 @@ public class TenantRepository { TenantApplications applicationRepo = new TenantApplications(tenantName, curator, - componentRegistry.getZkWatcherExecutor(), + zkWatcherExecutor, componentRegistry.getZkCacheExecutor(), metrics, componentRegistry.getReloadListener(), @@ -256,7 +262,8 @@ public class TenantRepository { applicationRepo, componentRegistry.getSessionPreparer(), curator, - metrics); + metrics, + zkWatcherExecutor); log.log(Level.INFO, "Adding tenant '" + tenantName + "'" + ", created " + created); Tenant tenant = new Tenant(tenantName, sessionRepository, applicationRepo, applicationRepo, created); notifyNewTenant(tenant); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index 2fc81dd847c..0cffb874c82 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -3,6 +3,8 @@ package com.yahoo.vespa.config.server; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; +import com.yahoo.concurrent.InThreadExecutorService; +import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.ConfigInstance; import com.yahoo.config.SimpletypesConfig; import com.yahoo.config.application.api.ApplicationMetaData; @@ -129,7 +131,11 @@ public class ApplicationRepositoryTest { .flagSource(flagSource) .clock(clock) .build(); - tenantRepository = new TenantRepository(componentRegistry, new HostRegistry(), curator, Metrics.createTestMetrics()); + tenantRepository = new TenantRepository(componentRegistry, + new HostRegistry(), + curator, + Metrics.createTestMetrics(), + new StripedExecutor<>(new InThreadExecutorService())); tenantRepository.addTenant(TenantRepository.HOSTED_VESPA_TENANT); tenantRepository.addTenant(tenant1); tenantRepository.addTenant(tenant2); 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 0b265fde27e..34ab5853085 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 @@ -3,11 +3,9 @@ package com.yahoo.vespa.config.server; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.concurrent.InThreadExecutorService; -import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.model.NullConfigModelRegistry; import com.yahoo.config.model.api.ConfigDefinitionRepo; import com.yahoo.config.provision.Provisioner; -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; @@ -50,7 +48,6 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private final Zone zone; private final Clock clock; private final ConfigServerDB configServerDB; - private final StripedExecutor<TenantName> zkWatcherExecutor; private final ExecutorService zkCacheExecutor; private final SecretStore secretStore; private final FlagSource flagSource; @@ -80,7 +77,6 @@ public class TestComponentRegistry implements GlobalComponentRegistry { this.zone = zone; this.clock = clock; this.configServerDB = new ConfigServerDB(configserverConfig); - this.zkWatcherExecutor = new StripedExecutor<>(new InThreadExecutorService()); this.zkCacheExecutor = new InThreadExecutorService(); this.secretStore = secretStore; this.flagSource = flagSource; @@ -97,7 +93,6 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private ConfigDefinitionRepo defRepo = new StaticConfigDefinitionRepo(); private ReloadListener reloadListener = new TenantApplicationsTest.MockReloadListener(); private final MockTenantListener tenantListener = new MockTenantListener(); - private Optional<PermanentApplicationPackage> permanentApplicationPackage = Optional.empty(); private final Optional<FileDistributionFactory> fileDistributionFactory = Optional.empty(); private ModelFactoryRegistry modelFactoryRegistry = new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry()))); private Optional<Provisioner> hostProvisioner = Optional.empty(); @@ -120,11 +115,6 @@ public class TestComponentRegistry implements GlobalComponentRegistry { return this; } - public Builder permanentApplicationPackage(PermanentApplicationPackage permanentApplicationPackage) { - this.permanentApplicationPackage = Optional.ofNullable(permanentApplicationPackage); - return this; - } - public Builder provisioner(Provisioner provisioner) { this.hostProvisioner = Optional.ofNullable(provisioner); return this; @@ -156,7 +146,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { } public TestComponentRegistry build() { - final PermanentApplicationPackage permApp = this.permanentApplicationPackage + final PermanentApplicationPackage permApp = Optional.<PermanentApplicationPackage>empty() .orElse(new PermanentApplicationPackage(configserverConfig)); FileDistributionFactory fileDistributionProvider = this.fileDistributionFactory .orElse(new MockFileDistributionFactory(configserverConfig)); @@ -211,11 +201,6 @@ public class TestComponentRegistry implements GlobalComponentRegistry { public ConfigServerDB getConfigServerDB() { return configServerDB;} @Override - public StripedExecutor<TenantName> getZkWatcherExecutor() { - return zkWatcherExecutor; - } - - @Override public FlagSource getFlagSource() { return flagSource; } @Override diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java index 25cfd67dd05..39329d4a870 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java @@ -3,6 +3,8 @@ package com.yahoo.vespa.config.server.application; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; +import com.yahoo.concurrent.InThreadExecutorService; +import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.model.NullConfigModelRegistry; import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.config.provision.ApplicationId; @@ -79,7 +81,11 @@ public class TenantApplicationsTest { .reloadListener(listener) .build(); HostRegistry hostRegistry = new HostRegistry(); - TenantRepository tenantRepository = new TenantRepository(componentRegistry, hostRegistry, curator, Metrics.createTestMetrics()); + TenantRepository tenantRepository = new TenantRepository(componentRegistry, + hostRegistry, + curator, + Metrics.createTestMetrics(), + new StripedExecutor<>(new InThreadExecutorService())); tenantRepository.addTenant(TenantRepository.HOSTED_VESPA_TENANT); tenantRepository.addTenant(tenantName); applications = TenantApplications.create(componentRegistry, hostRegistry, tenantName, curator); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java index 2d6e0f9ed97..1967860a4cc 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java @@ -3,6 +3,8 @@ package com.yahoo.vespa.config.server.deploy; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; +import com.yahoo.concurrent.InThreadExecutorService; +import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.model.ConfigModelRegistry; import com.yahoo.config.model.NullConfigModelRegistry; @@ -292,7 +294,8 @@ public class DeployTester { TenantRepository tenantRepository = new TenantRepository(testComponentRegistryBuilder.build(), new HostRegistry(), curator, - Optional.ofNullable(metrics).orElseGet(Metrics::createTestMetrics)); + Optional.ofNullable(metrics).orElseGet(Metrics::createTestMetrics), + new StripedExecutor<>(new InThreadExecutorService())); tenantRepository.addTenant(tenantName); ApplicationRepository applicationRepository = new ApplicationRepository.Builder() diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java index 1baca9fd698..ae662bb45ff 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java @@ -3,6 +3,8 @@ package com.yahoo.vespa.config.server.http.v2; import com.google.common.util.concurrent.UncheckedTimeoutException; import com.yahoo.cloud.config.ConfigserverConfig; +import com.yahoo.concurrent.InThreadExecutorService; +import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationLockException; import com.yahoo.config.provision.ApplicationName; @@ -83,7 +85,11 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest { .build(); Clock clock = componentRegistry.getClock(); timeoutBudget = new TimeoutBudget(clock, Duration.ofSeconds(10)); - tenantRepository = new TenantRepository(componentRegistry, new HostRegistry(), curator, Metrics.createTestMetrics()); + tenantRepository = new TenantRepository(componentRegistry, + new HostRegistry(), + curator, + Metrics.createTestMetrics(), + new StripedExecutor<>(new InThreadExecutorService())); tenantRepository.addTenant(tenant); applicationRepository = new ApplicationRepository.Builder() .withTenantRepository(tenantRepository) diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java index 7602c7a805f..1c4c68ba39f 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java @@ -3,6 +3,8 @@ package com.yahoo.vespa.config.server.session; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; +import com.yahoo.concurrent.InThreadExecutorService; +import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.model.api.Model; import com.yahoo.config.model.api.ModelContext; @@ -93,7 +95,11 @@ public class SessionRepositoryTest { .build()) .flagSource(flagSource) .build(); - tenantRepository = new TenantRepository(globalComponentRegistry, new HostRegistry(), curator, Metrics.createTestMetrics()); + tenantRepository = new TenantRepository(globalComponentRegistry, + new HostRegistry(), + curator, + Metrics.createTestMetrics(), + new StripedExecutor<>(new InThreadExecutorService())); tenantRepository.addTenant(SessionRepositoryTest.tenantName); applicationRepository = new ApplicationRepository.Builder() .withTenantRepository(tenantRepository) diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java index 71bff0b9492..efc5824842a 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java @@ -3,6 +3,8 @@ package com.yahoo.vespa.config.server.tenant; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; +import com.yahoo.concurrent.InThreadExecutorService; +import com.yahoo.concurrent.StripedExecutor; import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; @@ -67,7 +69,11 @@ public class TenantRepositoryTest { listener = (TenantApplicationsTest.MockReloadListener) globalComponentRegistry.getReloadListener(); tenantListener = (MockTenantListener) globalComponentRegistry.getTenantListener(); assertFalse(tenantListener.tenantsLoaded); - tenantRepository = new TenantRepository(globalComponentRegistry, new HostRegistry(), curator, Metrics.createTestMetrics()); + tenantRepository = new TenantRepository(globalComponentRegistry, + new HostRegistry(), + curator, + Metrics.createTestMetrics(), + new StripedExecutor<>(new InThreadExecutorService())); assertTrue(tenantListener.tenantsLoaded); tenantRepository.addTenant(tenant1); tenantRepository.addTenant(tenant2); @@ -201,7 +207,11 @@ public class TenantRepositoryTest { private static class FailingDuringBootstrapTenantRepository extends TenantRepository { public FailingDuringBootstrapTenantRepository(GlobalComponentRegistry globalComponentRegistry, Curator curator) { - super(globalComponentRegistry, new HostRegistry(), curator, Metrics.createTestMetrics()); + super(globalComponentRegistry, + new HostRegistry(), + curator, + Metrics.createTestMetrics(), + new StripedExecutor<>(new InThreadExecutorService())); } @Override |