]> source.dussan.org Git - sonarqube.git/commitdiff
Remove dead code in CE notifications
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 9 May 2017 06:52:08 +0000 (08:52 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 12 May 2017 12:11:19 +0000 (14:11 +0200)
server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java
server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDaemon.java
server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcher.java
server/sonar-server/src/main/java/org/sonar/server/notification/NotificationDispatcherMetadata.java
server/sonar-server/src/main/java/org/sonar/server/notification/NotificationManager.java
server/sonar-server/src/main/java/org/sonar/server/notification/NotificationService.java

index fceab035a976bf97912df4a14126bfb51f10eec7..992df9f4a30b84e38487568d009b92f50c6238eb 100644 (file)
@@ -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,
 
index 4dd55fabb199ba6a17c17836c494df8ab4311d54..1e4445ed39f4c9214f8c8d66e5191c01d62af725 100644 (file)
@@ -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
index f620b5760876a934d15532cc0e7b919cffeec2d2..fa819e856c8d116860e5e259a81d51e4c9ca99de 100644 (file)
@@ -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
    */
index 001acbad771cbb2dde6ffca91713e77682f0f0a0..c32c9a4dec650f737c3e6ad3b6803914086dbf84 100644 (file)
@@ -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;
index e80a5afd7160872accd15e1b4b75775ea9b7edfd..46304325d0d1b852d7e0b1d07750dd873252ceea 100644 (file)
@@ -51,14 +51,6 @@ public abstract class NotificationDispatcher {
    * to know who should receive the notification.
    */
   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.
      * 
index cc58f15eff4b5c0717ea1c637ca8b88d2d50e55c..bf0ce10f6afe04c4549764958afc5722209f1d67 100644 (file)
@@ -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
index e9cffa59fb6a02038951b88310fc5e6c77209f95..181c6bce56a525a281a6b500cb86db0d706b0a62 100644 (file)
@@ -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;
@@ -41,14 +40,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
index 908a2e805305bcc5c1315b172127c1e26ae8fe28..06c5b48733d24aa7169b8f0aad9e9ea202b47a51 100644 (file)
@@ -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,15 +112,10 @@ 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) {