diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-01-20 08:34:10 +0100 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2021-01-20 08:34:10 +0100 |
commit | b7f7b0f32d02160601f3dac94050192c8b374ee7 (patch) | |
tree | 779a368e158bbeee1b5195b70c1f2209c47b5057 /configserver | |
parent | 64e28d6625c0b517d75a2a9eb4295048717a1ca9 (diff) |
Remove zkCacheExecutor from GlobalComponentRegistry
Diffstat (limited to 'configserver')
10 files changed, 32 insertions, 36 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 da114e89f00..093898edc23 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 @@ -29,6 +29,5 @@ public interface GlobalComponentRegistry { Zone getZone(); Clock getClock(); ConfigServerDB getConfigServerDB(); - 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 dbd477c0b93..de681a32818 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,7 +3,6 @@ package com.yahoo.vespa.config.server; import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; -import com.yahoo.concurrent.ThreadFactoryFactory; import com.yahoo.config.model.api.ConfigDefinitionRepo; import com.yahoo.config.provision.Provisioner; import com.yahoo.config.provision.Zone; @@ -12,12 +11,9 @@ import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.provision.HostProvisionerProvider; import com.yahoo.vespa.config.server.rpc.RpcServer; import com.yahoo.vespa.config.server.tenant.TenantListener; -import com.yahoo.vespa.config.server.tenant.TenantRepository; import java.time.Clock; import java.util.Optional; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; /** * Registry containing all the "static"/"global" components in a config server in one place. @@ -34,7 +30,6 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry private final Zone zone; private final ConfigServerDB configServerDB; private final SecretStore secretStore; - private final ExecutorService zkCacheExecutor; @SuppressWarnings("WeakerAccess") @Inject @@ -54,7 +49,6 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry this.zone = zone; this.configServerDB = configServerDB; this.secretStore = secretStore; - this.zkCacheExecutor = Executors.newFixedThreadPool(1, ThreadFactoryFactory.getThreadFactory(TenantRepository.class.getName())); } @Override @@ -85,11 +79,6 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry public ConfigServerDB getConfigServerDB() { return configServerDB; } @Override - public ExecutorService getZkCacheExecutor() { - return zkCacheExecutor; - } - - @Override public SecretStore getSecretStore() { return secretStore; } 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 3d979ebd3b8..2b9488b7fc7 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 @@ -95,7 +95,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica return new TenantApplications(tenantName, curator, new StripedExecutor<>(new InThreadExecutorService()), - componentRegistry.getZkCacheExecutor(), + new InThreadExecutorService(), Metrics.createTestMetrics(), componentRegistry.getReloadListener(), componentRegistry.getConfigserverConfig(), 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 51a1b6f9d57..9a4a67b7750 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 @@ -57,6 +57,7 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -97,6 +98,7 @@ public class SessionRepository { private final GlobalComponentRegistry componentRegistry; private final ConfigCurator configCurator; private final SessionCounter sessionCounter; + private final ExecutorService zkCacheExecutor; public SessionRepository(TenantName tenantName, GlobalComponentRegistry componentRegistry, @@ -106,7 +108,8 @@ public class SessionRepository { Metrics metrics, StripedExecutor<TenantName> zkWatcherExecutor, PermanentApplicationPackage permanentApplicationPackage, - FlagSource flagSource) { + FlagSource flagSource, + ExecutorService zkCacheExecutor) { this.tenantName = tenantName; this.componentRegistry = componentRegistry; this.configCurator = ConfigCurator.create(curator); @@ -123,8 +126,10 @@ public class SessionRepository { this.sessionPreparer = sessionPreparer; this.metrics = metrics; this.metricUpdater = metrics.getOrCreateMetricUpdater(Metrics.createDimensions(tenantName)); + this.zkCacheExecutor = zkCacheExecutor; + loadSessions(); // Needs to be done before creating cache below - this.directoryCache = curator.createDirectoryCache(sessionsPath.getAbsolute(), false, false, componentRegistry.getZkCacheExecutor()); + this.directoryCache = curator.createDirectoryCache(sessionsPath.getAbsolute(), false, false, zkCacheExecutor); this.directoryCache.addListener(this::childEvent); this.directoryCache.start(); } 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 76fb7d29a43..edfd78f63b7 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 @@ -6,6 +6,7 @@ import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.concurrent.DaemonThreadFactory; import com.yahoo.concurrent.StripedExecutor; +import com.yahoo.concurrent.ThreadFactoryFactory; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; import com.yahoo.path.Path; @@ -116,7 +117,8 @@ public class TenantRepository { metrics, new StripedExecutor<>(), new FileDistributionFactory(componentRegistry.getConfigserverConfig()), - flagSource); + flagSource, + Executors.newFixedThreadPool(1, ThreadFactoryFactory.getThreadFactory(TenantRepository.class.getName()))); } public TenantRepository(GlobalComponentRegistry componentRegistry, @@ -125,7 +127,8 @@ public class TenantRepository { Metrics metrics, StripedExecutor<TenantName> zkWatcherExecutor, FileDistributionFactory fileDistributionFactory, - FlagSource flagSource) { + FlagSource flagSource, + ExecutorService zkCacheExecutor) { this.componentRegistry = componentRegistry; this.hostRegistry = hostRegistry; ConfigserverConfig configserverConfig = componentRegistry.getConfigserverConfig(); @@ -135,7 +138,7 @@ public class TenantRepository { this.metrics = metrics; metricUpdater = metrics.getOrCreateMetricUpdater(Collections.emptyMap()); this.tenantListeners.add(componentRegistry.getTenantListener()); - this.zkCacheExecutor = componentRegistry.getZkCacheExecutor(); + this.zkCacheExecutor = zkCacheExecutor; this.zkWatcherExecutor = zkWatcherExecutor; this.fileDistributionFactory = fileDistributionFactory; this.flagSource = flagSource; @@ -259,7 +262,7 @@ public class TenantRepository { new TenantApplications(tenantName, curator, zkWatcherExecutor, - componentRegistry.getZkCacheExecutor(), + zkCacheExecutor, metrics, componentRegistry.getReloadListener(), componentRegistry.getConfigserverConfig(), @@ -285,7 +288,8 @@ public class TenantRepository { metrics, zkWatcherExecutor, permanentApplicationPackage, - flagSource); + flagSource, + zkCacheExecutor); 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/TestComponentRegistry.java b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java index 38310e5b20d..3681444b719 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 @@ -2,7 +2,6 @@ package com.yahoo.vespa.config.server; import com.yahoo.cloud.config.ConfigserverConfig; -import com.yahoo.concurrent.InThreadExecutorService; import com.yahoo.config.model.NullConfigModelRegistry; import com.yahoo.config.model.api.ConfigDefinitionRepo; import com.yahoo.config.provision.Provisioner; @@ -18,7 +17,6 @@ import java.nio.file.Files; import java.time.Clock; import java.util.Collections; import java.util.Optional; -import java.util.concurrent.ExecutorService; import static com.yahoo.yolean.Exceptions.uncheck; @@ -36,7 +34,6 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private final Zone zone; private final Clock clock; private final ConfigServerDB configServerDB; - private final ExecutorService zkCacheExecutor; private final SecretStore secretStore; private TestComponentRegistry(ModelFactoryRegistry modelFactoryRegistry, @@ -57,7 +54,6 @@ public class TestComponentRegistry implements GlobalComponentRegistry { this.zone = zone; this.clock = clock; this.configServerDB = new ConfigServerDB(configserverConfig); - this.zkCacheExecutor = new InThreadExecutorService(); this.secretStore = secretStore; } @@ -147,10 +143,6 @@ public class TestComponentRegistry implements GlobalComponentRegistry { @Override public ConfigServerDB getConfigServerDB() { return configServerDB;} @Override - public ExecutorService getZkCacheExecutor() { - return zkCacheExecutor; - } - @Override public SecretStore getSecretStore() { return secretStore; } 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 61db4e96c92..c385dcd37ef 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 @@ -83,13 +83,15 @@ public class TenantApplicationsTest { .reloadListener(listener) .build(); HostRegistry hostRegistry = new HostRegistry(); + InThreadExecutorService zkCacheExecutor = new InThreadExecutorService(); TenantRepository tenantRepository = new TenantRepository(componentRegistry, hostRegistry, curator, Metrics.createTestMetrics(), new StripedExecutor<>(new InThreadExecutorService()), new MockFileDistributionFactory(configserverConfig), - new InMemoryFlagSource()); + new InMemoryFlagSource(), + zkCacheExecutor); 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 bc668f8f1a1..19552d3e2d0 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 @@ -298,7 +298,8 @@ public class DeployTester { Optional.ofNullable(metrics).orElseGet(Metrics::createTestMetrics), new StripedExecutor<>(new InThreadExecutorService()), new MockFileDistributionFactory(configserverConfig), - new InMemoryFlagSource()); + new InMemoryFlagSource(), + new InThreadExecutorService()); tenantRepository.addTenant(tenantName); ApplicationRepository applicationRepository = new ApplicationRepository.Builder() 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 6c5415416e7..8d2c37e98c0 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 @@ -212,7 +212,8 @@ public class TenantRepositoryTest { Metrics.createTestMetrics(), new StripedExecutor<>(new InThreadExecutorService()), new FileDistributionFactory(new ConfigserverConfig.Builder().build()), - new InMemoryFlagSource()); + new InMemoryFlagSource(), + new InThreadExecutorService()); } @Override diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestTenantRepository.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestTenantRepository.java index 2c9c35f65e1..2a3e2dad265 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestTenantRepository.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestTenantRepository.java @@ -3,7 +3,6 @@ package com.yahoo.vespa.config.server.tenant; import com.yahoo.concurrent.InThreadExecutorService; import com.yahoo.concurrent.StripedExecutor; -import com.yahoo.config.provision.TenantName; import com.yahoo.vespa.config.server.GlobalComponentRegistry; import com.yahoo.vespa.config.server.filedistribution.FileDistributionFactory; import com.yahoo.vespa.config.server.host.HostRegistry; @@ -23,10 +22,16 @@ public class TestTenantRepository extends TenantRepository { HostRegistry hostRegistry, Curator curator, Metrics metrics, - StripedExecutor<TenantName> zkWatcherExecutor, FileDistributionFactory fileDistributionFactory, FlagSource flagSource) { - super(componentRegistry, hostRegistry, curator, metrics, zkWatcherExecutor, fileDistributionFactory, flagSource); + super(componentRegistry, + hostRegistry, + curator, + metrics, + new StripedExecutor<>(new InThreadExecutorService()), + fileDistributionFactory, + flagSource, + new InThreadExecutorService()); } public static class Builder { @@ -35,7 +40,6 @@ public class TestTenantRepository extends TenantRepository { HostRegistry hostRegistry = new HostRegistry(); Curator curator = new MockCurator(); Metrics metrics = Metrics.createTestMetrics(); - StripedExecutor<TenantName> zkWatcherExecutor = new StripedExecutor<>(new InThreadExecutorService()); FileDistributionFactory fileDistributionFactory = null; FlagSource flagSource = new InMemoryFlagSource(); @@ -72,7 +76,6 @@ public class TestTenantRepository extends TenantRepository { hostRegistry, curator, metrics, - zkWatcherExecutor, fileDistributionFactory, flagSource); } |