summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-08-12 09:38:25 +0200
committerHarald Musum <musum@verizonmedia.com>2021-08-12 09:38:25 +0200
commit1e6b648da6803f407d8e4b601178071af260453e (patch)
tree8efb24b80db39ca9a47ff5b6e999b1f3504db7ac /configserver
parent4a96669b25874280bf49419ebe58edd6114237f8 (diff)
Split out methods for creating and shutting down executor
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java
index 7ea6f5f8504..5290dee32bb 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java
@@ -221,10 +221,9 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable
return true;
}
- // Returns the set of applications that failed to redeploy
+ // Returns applications that failed to redeploy
private List<ApplicationId> redeployApplications(List<ApplicationId> applicationIds) throws InterruptedException {
- ExecutorService executor = Executors.newFixedThreadPool(configserverConfig.numRedeploymentThreads(),
- new DaemonThreadFactory("redeploy-apps-"));
+ ExecutorService executor = getExecutor();
log.log(Level.INFO, () -> "Redeploying " + applicationIds.size() + " apps: " + applicationIds);
PreparedApplications preparedApplications = prepare(applicationIds, executor);
@@ -235,13 +234,21 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable
List<ApplicationId> failed = activate(preparedApplications.deploymentInfos());
+ shutdownExecutor(executor);
+ return failed;
+ }
+
+ private void shutdownExecutor(ExecutorService executor) throws InterruptedException {
executor.shutdown();
if ( ! executor.awaitTermination(1, TimeUnit.HOURS)) {
log.log(Level.WARNING, "Awaiting termination of executor failed");
executor.shutdownNow();
}
+ }
- return failed;
+ private ExecutorService getExecutor() {
+ return Executors.newFixedThreadPool(configserverConfig.numRedeploymentThreads(),
+ new DaemonThreadFactory("redeploy-apps-"));
}
private PreparedApplications prepare(List<ApplicationId> applicationIds, ExecutorService executor) {