diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-03-17 14:15:37 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-03-21 16:44:05 +0100 |
commit | 2bcf361c8c2458d00b4711da65b099a59a266912 (patch) | |
tree | 48cbba9ccd45e40f18dfd9a82fd8d7c121144231 /server | |
parent | 3f8f3f9c4dbbe94d9a99a426aeabbba90f305555 (diff) | |
download | sonarqube-2bcf361c8c2458d00b4711da65b099a59a266912.tar.gz sonarqube-2bcf361c8c2458d00b4711da65b099a59a266912.zip |
SONAR-6732 asynchronous notification service runs only in Web Server
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/notification/NotificationService.java | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationService.java b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationService.java index ca619690bae..e44f313b79f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationService.java @@ -76,9 +76,11 @@ public class NotificationService implements Startable { private ScheduledExecutorService executorService; private boolean stopping = false; + private final boolean disabled; public NotificationService(Settings settings, DefaultNotificationManager manager, DbClient dbClient, NotificationDispatcher[] dispatchers) { + this.disabled = "ComputeEngineSettings".equals(settings.getClass().getSimpleName()); this.delayInSeconds = settings.getLong(PROPERTY_DELAY); this.delayBeforeReportingStatusInSeconds = settings.getLong(PROPERTY_DELAY_BEFORE_REPORTING_STATUS); this.manager = manager; @@ -95,35 +97,39 @@ public class NotificationService implements Startable { @Override public void start() { - executorService = - Executors.newSingleThreadScheduledExecutor( - new ThreadFactoryBuilder() - .setNameFormat(THREAD_NAME_PREFIX + "%d") - .setPriority(Thread.MIN_PRIORITY) - .build()); - executorService.scheduleWithFixedDelay(new Runnable() { - @Override - public void run() { - try { - processQueue(); - } catch (Exception e) { - LOG.error("Error in NotificationService", e); + if (!disabled) { + executorService = + Executors.newSingleThreadScheduledExecutor( + new ThreadFactoryBuilder() + .setNameFormat(THREAD_NAME_PREFIX + "%d") + .setPriority(Thread.MIN_PRIORITY) + .build()); + executorService.scheduleWithFixedDelay(new Runnable() { + @Override + public void run() { + try { + processQueue(); + } catch (Exception e) { + LOG.error("Error in NotificationService", e); + } } - } - }, 0, delayInSeconds, TimeUnit.SECONDS); - LOG.info("Notification service started (delay {} sec.)", delayInSeconds); + }, 0, delayInSeconds, TimeUnit.SECONDS); + LOG.info("Notification service started (delay {} sec.)", delayInSeconds); + } } @Override public void stop() { - try { - stopping = true; - executorService.shutdown(); - executorService.awaitTermination(5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - LOG.error("Error during stop of notification service", e); + if (!disabled) { + try { + stopping = true; + executorService.shutdown(); + executorService.awaitTermination(5, TimeUnit.SECONDS); + } catch (InterruptedException e) { + LOG.error("Error during stop of notification service", e); + } + LOG.info("Notification service stopped"); } - LOG.info("Notification service stopped"); } @VisibleForTesting |