aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-05-09 08:52:08 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-05-12 14:11:19 +0200
commit0411a04805221c350bc9507757d3d9b2cdacd408 (patch)
treebf7551462ef176099949dfcaa62d403c5e477e64
parentb5ea54e92dd0d86d0d159c31813a2f884e256d66 (diff)
downloadsonarqube-0411a04805221c350bc9507757d3d9b2cdacd408.tar.gz
sonarqube-0411a04805221c350bc9507757d3d9b2cdacd408.zip
Remove dead code in CE notifications
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java6
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDaemon.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcher.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/notification/NotificationManager.java9
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/notification/NotificationService.java18
8 files changed, 13 insertions, 47 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
index fceab035a97..992df9f4a30 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
@@ -40,9 +40,11 @@ import org.sonar.api.utils.System2;
import org.sonar.api.utils.UriReader;
import org.sonar.api.utils.Version;
import org.sonar.ce.CeConfigurationModule;
+import org.sonar.ce.CeDistributedInformationImpl;
import org.sonar.ce.CeHttpModule;
import org.sonar.ce.CeQueueModule;
import org.sonar.ce.CeTaskCommonsModule;
+import org.sonar.ce.StandaloneCeDistributedInformation;
import org.sonar.ce.cleaning.CeCleaningModule;
import org.sonar.ce.cluster.HazelcastClientWrapperImpl;
import org.sonar.ce.db.ReadOnlyPropertiesDao;
@@ -53,8 +55,6 @@ import org.sonar.ce.queue.PurgeCeActivities;
import org.sonar.ce.settings.ProjectSettingsFactory;
import org.sonar.ce.taskprocessor.CeTaskProcessorModule;
import org.sonar.ce.user.CeUserSession;
-import org.sonar.ce.CeDistributedInformationImpl;
-import org.sonar.ce.StandaloneCeDistributedInformation;
import org.sonar.core.component.DefaultResourceTypes;
import org.sonar.core.config.CorePropertyDefinitions;
import org.sonar.core.i18n.DefaultI18n;
@@ -97,7 +97,6 @@ import org.sonar.server.measure.index.ProjectMeasuresIndexer;
import org.sonar.server.metric.CoreCustomMetrics;
import org.sonar.server.metric.DefaultMetricFinder;
import org.sonar.server.notification.DefaultNotificationManager;
-import org.sonar.server.notification.NotificationCenter;
import org.sonar.server.notification.NotificationService;
import org.sonar.server.notification.email.AlertsEmailTemplate;
import org.sonar.server.notification.email.EmailNotificationChannel;
@@ -385,7 +384,6 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
AlertsEmailTemplate.class,
EmailSettings.class,
NotificationService.class,
- NotificationCenter.class,
DefaultNotificationManager.class,
EmailNotificationChannel.class,
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
index 4dd55fabb19..1e4445ed39f 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
@@ -113,7 +113,7 @@ public class ComputeEngineContainerImplTest {
assertThat(picoContainer.getComponentAdapters())
.hasSize(
CONTAINER_ITSELF
- + 74 // level 4
+ + 73 // level 4
+ 4 // content of CeConfigurationModule
+ 4 // content of CeQueueModule
+ 3 // content of CeHttpModule
diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java b/server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java
index f620b576087..fa819e856c8 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java
@@ -38,6 +38,8 @@ import org.sonar.db.notification.NotificationQueueDao;
import org.sonar.db.notification.NotificationQueueDto;
import org.sonar.db.property.PropertiesDao;
+import static java.util.Collections.singletonList;
+
public class DefaultNotificationManager implements NotificationManager {
private static final Logger LOG = Loggers.get(DefaultNotificationManager.class);
@@ -72,14 +74,8 @@ public class DefaultNotificationManager implements NotificationManager {
@Override
public void scheduleForSending(Notification notification) {
NotificationQueueDto dto = NotificationQueueDto.toNotificationQueueDto(notification);
- notificationQueueDao.insert(Arrays.asList(dto));
+ notificationQueueDao.insert(singletonList(dto));
}
-
- @Override
- public void scheduleForSending(List<Notification> notification) {
- notificationQueueDao.insert(Lists.transform(notification, NotificationQueueDto::toNotificationQueueDto));
- }
-
/**
* Give the notification queue so that it can be processed
*/
diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDaemon.java b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDaemon.java
index 001acbad771..c32c9a4dec6 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDaemon.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDaemon.java
@@ -99,8 +99,7 @@ public class NotificationDaemon implements Startable {
LOG.info("Notification service stopped");
}
- @VisibleForTesting
- synchronized void processQueue() {
+ private synchronized void processQueue() {
long start = now();
long lastLog = start;
long notifSentCount = 0;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcher.java b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcher.java
index e80a5afd716..46304325d0d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcher.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcher.java
@@ -52,14 +52,6 @@ public abstract class NotificationDispatcher {
*/
public interface Context {
/**
- * This method is not used any longer. Calling it will result in an {@link UnsupportedOperationException}.
- *
- * @deprecated Use {@link #addUser(String, NotificationChannel)} instead.
- */
- @Deprecated
- void addUser(String userLogin);
-
- /**
* Adds a user that will be notified through the given notification channel.
*
* @param userLogin the user login
diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java
index cc58f15eff4..bf0ce10f6af 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java
@@ -25,11 +25,11 @@ import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.server.ServerSide;
/**
- * <p>
* Notification dispatchers (see {@link NotificationDispatcher}) can define their own metadata class in order
* to tell more about them.
- * <p/>
+ * <p>
* Instances of these classes must be declared by {@link org.sonar.api.Plugin}.
+ * </p>
*/
@ServerSide
@ComputeEngineSide
diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationManager.java b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationManager.java
index e9cffa59fb6..181c6bce56a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationManager.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationManager.java
@@ -20,7 +20,6 @@
package org.sonar.server.notification;
import com.google.common.collect.Multimap;
-import java.util.List;
import javax.annotation.Nullable;
import org.sonar.api.notifications.Notification;
import org.sonar.api.notifications.NotificationChannel;
@@ -42,14 +41,6 @@ public interface NotificationManager {
void scheduleForSending(Notification notification);
/**
- * Receives notifications and stores them so that they are processed by the notification service.
- *
- * @param notifications the notifications.
- * @since 3.7.1
- */
- void scheduleForSending(List<Notification> notifications);
-
- /**
* <p>
* Returns the list of users who subscribed to the given dispatcher, along with the notification channels (email, twitter, ...) that they choose
* for this dispatcher.
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 908a2e80530..06c5b48733d 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
@@ -59,13 +59,8 @@ public class NotificationService {
this(dbClient, new NotificationDispatcher[0]);
}
- @VisibleForTesting
- long now() {
- return System.currentTimeMillis();
- }
-
public void deliver(Notification notification) {
- final SetMultimap<String, NotificationChannel> recipients = HashMultimap.create();
+ SetMultimap<String, NotificationChannel> recipients = HashMultimap.create();
for (NotificationDispatcher dispatcher : dispatchers) {
NotificationDispatcher.Context context = new ContextImpl(recipients);
try {
@@ -78,7 +73,7 @@ public class NotificationService {
dispatch(notification, recipients);
}
- private void dispatch(Notification notification, SetMultimap<String, NotificationChannel> recipients) {
+ private static void dispatch(Notification notification, SetMultimap<String, NotificationChannel> recipients) {
for (Map.Entry<String, Collection<NotificationChannel>> entry : recipients.asMap().entrySet()) {
String username = entry.getKey();
Collection<NotificationChannel> userChannels = entry.getValue();
@@ -95,7 +90,7 @@ public class NotificationService {
}
@VisibleForTesting
- protected List<NotificationDispatcher> getDispatchers() {
+ List<NotificationDispatcher> getDispatchers() {
return dispatchers;
}
@@ -117,16 +112,11 @@ public class NotificationService {
private static class ContextImpl implements NotificationDispatcher.Context {
private final Multimap<String, NotificationChannel> recipients;
- public ContextImpl(Multimap<String, NotificationChannel> recipients) {
+ ContextImpl(Multimap<String, NotificationChannel> recipients) {
this.recipients = recipients;
}
@Override
- public void addUser(String username) {
- // This method is not used anymore
- }
-
- @Override
public void addUser(@Nullable String userLogin, NotificationChannel notificationChannel) {
if (userLogin != null) {
recipients.put(userLogin, notificationChannel);