From c7f8cb11ea781d59145f4699e06ce8611ad1ec56 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Wed, 7 Jun 2017 19:55:38 +0200 Subject: Deploy using a fixed size thread pool --- .../vespa/config/server/ApplicationRepository.java | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'configserver/src') diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index 76d37f44fbf..229f24152c3 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -71,6 +71,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye private final HttpProxy httpProxy; private final Clock clock; private final DeployLogger logger = new SilentDeployLogger(); + private final ConfigserverConfig configserverConfig; private final Environment environment; @Inject @@ -88,6 +89,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye this.convergeChecker = applicationConvergenceChecker; this.httpProxy = httpProxy; this.clock = Clock.systemUTC(); + this.configserverConfig = configserverConfig; this.environment = Environment.from(configserverConfig.environment()); } @@ -333,22 +335,9 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye } void redeployAllApplications(Deployer deployer) { - ExecutorService deploymentExecutor = Executors.newCachedThreadPool(); - Set applicationIds = new HashSet<>(); - - tenants.getAllTenants().forEach(tenant -> applicationIds.addAll(tenant.getApplicationRepo().listApplications())); - - int applicationsRedeployed = 0; - for (ApplicationId applicationId : applicationIds) { - redeployApplication(applicationId, deployer, deploymentExecutor); - log.log(LogLevel.INFO, String.format("Redeployed %s of %s applications", ++applicationsRedeployed, applicationIds.size())); - // Throttle deployments - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - throw new RuntimeException("Failed to deploy application " + applicationId, e); - } - } + ExecutorService deploymentExecutor = Executors.newFixedThreadPool(configserverConfig.numParallelTenantLoaders()); + tenants.getAllTenants().forEach(tenant -> listApplicationIds(tenant) + .forEach(applicationId -> redeployApplication(applicationId, deployer, deploymentExecutor))); } private void redeployApplication(ApplicationId applicationId, Deployer deployer, ExecutorService deploymentExecutor) { -- cgit v1.2.3