]> source.dussan.org Git - sonarqube.git/commitdiff
SONARCLOUD-193 no Hazelcast in CE on SonarCloud
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 14 Dec 2018 08:39:57 +0000 (09:39 +0100)
committerSonarTech <sonartech@sonarsource.com>
Fri, 21 Dec 2018 19:21:02 +0000 (20:21 +0100)
which implies that the cleaning job is no more run by the Compute Engine nodes on SonarCloud

server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java
server/sonar-ce/src/main/java/org/sonar/ce/cleaning/NoopCeCleaningSchedulerImpl.java [new file with mode: 0644]
server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-ce/src/test/java/org/sonar/ce/queue/CeQueueInitializerTest.java

index bfc2eff67b0b81cc2d762316ce7c92ba2510d0c7..ce5735413d322494d2e58d93b62329f7cbe26176 100644 (file)
@@ -48,10 +48,6 @@ public class CeDistributedInformationImpl implements CeDistributedInformation, S
     this.ceCeWorkerFactory = ceCeWorkerFactory;
   }
 
-  public CeDistributedInformationImpl(CeWorkerFactory ceCeWorkerFactory) {
-    this(null, ceCeWorkerFactory);
-  }
-
   @Override
   public Set<String> getWorkerUUIDs() {
     Set<String> connectedWorkerUUIDs = hazelcastMember.getMemberUuids();
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/cleaning/NoopCeCleaningSchedulerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/cleaning/NoopCeCleaningSchedulerImpl.java
new file mode 100644 (file)
index 0000000..ce08344
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.ce.cleaning;
+
+public class NoopCeCleaningSchedulerImpl implements CeCleaningScheduler {
+  @Override
+  public void startScheduling() {
+    // do nothing
+  }
+}
index c594863638438e38a687691445a0b5196ee059ea..a8b8bd97bae23ceb994cc0e307d5e43f7e5af52a 100644 (file)
@@ -50,6 +50,7 @@ import org.sonar.ce.CeTaskCommonsModule;
 import org.sonar.ce.StandaloneCeDistributedInformation;
 import org.sonar.ce.async.SynchronousAsyncExecution;
 import org.sonar.ce.cleaning.CeCleaningModule;
+import org.sonar.ce.cleaning.NoopCeCleaningSchedulerImpl;
 import org.sonar.ce.db.ReadOnlyPropertiesDao;
 import org.sonar.ce.logging.CeProcessLogging;
 import org.sonar.ce.monitoring.CEQueueStatusImpl;
@@ -162,6 +163,7 @@ import static org.sonar.core.extension.CoreExtensionsInstaller.noAdditionalSideF
 import static org.sonar.core.extension.PlatformLevelPredicates.hasPlatformLevel;
 import static org.sonar.core.extension.PlatformLevelPredicates.hasPlatformLevel4OrNone;
 import static org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED;
+import static org.sonar.process.ProcessProperties.Property.SONARCLOUD_ENABLED;
 
 public class ComputeEngineContainerImpl implements ComputeEngineContainer {
 
@@ -452,13 +454,20 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
       WebhookModule.class,
 
       QualityGateFinder.class,
-      QualityGateEvaluatorImpl.class,
+      QualityGateEvaluatorImpl.class
 
-      // cleaning
-      CeCleaningModule.class);
+    );
 
-    if (props.valueAsBoolean(CLUSTER_ENABLED.getKey())) {
+    if (props.valueAsBoolean(SONARCLOUD_ENABLED.getKey())) {
+      // no cleaning job on sonarcloud and no distributed information
+      container.add(
+        NoopCeCleaningSchedulerImpl.class,
+        StandaloneCeDistributedInformation.class,
+        CEQueueStatusImpl.class);
+    } else if (props.valueAsBoolean(CLUSTER_ENABLED.getKey())) {
       container.add(
+        CeCleaningModule.class,
+
         // system health
         CeDistributedInformationImpl.class,
 
@@ -466,20 +475,17 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
         DbSection.class,
         ProcessInfoProvider.class,
 
-        DistributedCEQueueStatusImpl.class
-
-      );
+        DistributedCEQueueStatusImpl.class);
     } else {
       container.add(
+        CeCleaningModule.class,
         StandaloneCeDistributedInformation.class,
-        CEQueueStatusImpl.class
-
-      );
+        CEQueueStatusImpl.class);
     }
   }
 
   private static Object[] startupComponents() {
-    return new Object[]{
+    return new Object[] {
       ServerLifecycleNotifier.class,
       PurgeCeActivities.class,
       CeQueueCleaner.class
index fb3337fd66cadc4b2d5572572b47fc7e2fa6c852..af986304e9d9738cab2c21038e957189e7bf40ea 100644 (file)
  */
 package org.sonar.ce.queue;
 
-import java.io.IOException;
 import org.junit.Test;
 import org.sonar.api.platform.Server;
-import org.sonar.ce.cleaning.CeCleaningScheduler;
 import org.sonar.ce.CeDistributedInformation;
+import org.sonar.ce.cleaning.CeCleaningScheduler;
 import org.sonar.ce.taskprocessor.CeProcessingScheduler;
 
 import static org.mockito.Mockito.mock;